|
1 | | -# 🦀 MCP Rust Server |
| 1 | +# mcp-rust-server |
2 | 2 |
|
3 | | -> High-performance Model Context Protocol (MCP) server for code analysis, security scanning, and project insights. |
| 3 | +[](https://crates.io/crates/mcp-rust-server) |
| 4 | +[](https://docs.rs/mcp-rust-server) |
| 5 | +[](LICENSE) |
4 | 6 |
|
5 | | -[](https://www.rust-lang.org/) |
6 | | -[](https://crates.io/crates/mcp-rust-server) |
7 | | -[](../LICENSE) |
| 7 | +High-performance **Model Context Protocol** (MCP) server for code analysis, security scanning, and project insights—written in Rust 🦀. |
8 | 8 |
|
9 | 9 | --- |
10 | 10 |
|
11 | | -## ✨ Features |
| 11 | +## Table of Contents |
12 | 12 |
|
13 | | -- **Fast & Scalable**: Built with async Rust for maximum performance |
14 | | -- **Flexible Protocols**: Supports both stdio and SSE communication |
15 | | -- **Security & Vulnerability Scanning**: Analyze codebases for risks and vulnerabilities |
16 | | -- **Extensible**: Add new handlers and endpoints easily |
17 | | -- **Production Ready**: Optimized release profile and logging |
| 13 | +* [Features](#features) |
| 14 | +* [Installation](#installation) |
| 15 | + |
| 16 | + * [CLI Binaries](#cli-binaries) |
| 17 | + * [Library](#library) |
| 18 | +* [Usage](#usage) |
| 19 | +* [Examples](#examples) |
| 20 | +* [Documentation](#documentation) |
| 21 | +* [Contributing](#contributing) |
| 22 | +* [License](#license) |
| 23 | +* [Acknowledgments](#acknowledgments) |
18 | 24 |
|
19 | 25 | --- |
20 | 26 |
|
21 | | -## 🚀 Quick Start |
| 27 | +## Features |
22 | 28 |
|
23 | | -### Build |
| 29 | +* **Fast & Scalable**: Built with async Rust on the Tokio runtime |
| 30 | +* **Multi-Protocol**: Supports both stdio and SSE (Server-Sent Events) transports |
| 31 | +* **Security Scanning**: Static analysis and vulnerability detection |
| 32 | +* **Extensible**: Easily add new MCP handlers and custom tools |
| 33 | +* **Production-Ready**: Optimized release profile, structured logging, and CI integration |
24 | 34 |
|
25 | | -```bash |
26 | | -cargo build --release |
27 | | -``` |
| 35 | +--- |
28 | 36 |
|
29 | | -### Run (Stdio Mode) |
| 37 | +## Installation |
| 38 | + |
| 39 | +mcp-rust-server is published on [crates.io]. You need a recent Rust toolchain (1.70+ recommended). |
| 40 | + |
| 41 | +### CLI Binaries |
30 | 42 |
|
31 | 43 | ```bash |
32 | | -cargo run --release --bin mcp-stdio |
| 44 | +cargo install mcp-rust-server |
33 | 45 | ``` |
34 | 46 |
|
35 | | -### Run (SSE Mode) |
| 47 | +This installs two binaries into your Cargo `bin` directory (usually `~/.cargo/bin`): |
36 | 48 |
|
37 | | -```bash |
38 | | -cargo run --release --bin mcp-sse |
| 49 | +* `mcp-stdio` — stdin/stdout-based MCP server |
| 50 | +* `mcp-sse` — HTTP/SSE-based MCP server |
| 51 | + |
| 52 | +### Library |
| 53 | + |
| 54 | +Add to your project’s `Cargo.toml`: |
| 55 | + |
| 56 | +```toml |
| 57 | +[dependencies] |
| 58 | +mcp-rust-server = "0.1.0" |
39 | 59 | ``` |
40 | 60 |
|
41 | 61 | --- |
42 | 62 |
|
43 | | -## 📦 Installation (from crates.io) |
| 63 | +## Usage |
| 64 | + |
| 65 | +### CLI Binaries |
44 | 66 |
|
45 | 67 | ```bash |
46 | | -cargo install mcp-rust-server |
| 68 | +# Run the stdio-based server |
| 69 | +mcp-stdio |
| 70 | + |
| 71 | +# Run the SSE-based server |
| 72 | +mcp-sse |
| 73 | +``` |
| 74 | + |
| 75 | +By default, both servers will: |
| 76 | + |
| 77 | +1. Read framed MCP requests (JSON-RPC) from the chosen transport |
| 78 | +2. Dispatch to your registered handlers |
| 79 | +3. Write framed MCP responses |
| 80 | + |
| 81 | +### Library |
| 82 | + |
| 83 | +```rust |
| 84 | +use mcp_rust_server::{start_stdio, start_sse}; |
| 85 | + |
| 86 | +#[tokio::main] |
| 87 | +async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 88 | + // Run as a stdio server |
| 89 | + start_stdio().await?; |
| 90 | + |
| 91 | + // Or run as an HTTP/SSE server |
| 92 | + // start_sse().await?; |
| 93 | + |
| 94 | + Ok(()) |
| 95 | +} |
47 | 96 | ``` |
48 | 97 |
|
| 98 | +* `start_stdio()` initializes logging, registers tools, and listens on stdin/stdout. |
| 99 | +* `start_sse()` spins up an HTTP server at `http://0.0.0.0:8000/mcp` and streams MCP responses. |
| 100 | + |
49 | 101 | --- |
50 | 102 |
|
51 | | -## 🛠️ Usage |
| 103 | +## Examples |
| 104 | + |
| 105 | +See the \[`examples/`] directory for full end-to-end demos: |
52 | 106 |
|
53 | | -- Use as a standalone server for MCP protocol |
54 | | -- Integrate with Syncable CLI or other tools |
55 | | -- Communicate via stdio or SSE endpoints |
| 107 | +* `examples/stdio_client.rs` — launch `mcp-stdio` and send sample requests |
| 108 | +* `examples/sse_client.html` — web page that connects to `mcp-sse` and renders events |
56 | 109 |
|
57 | 110 | --- |
58 | 111 |
|
59 | | -## 🧪 Testing |
| 112 | +## Documentation |
| 113 | + |
| 114 | +Full API documentation is generated on [docs.rs]: |
60 | 115 |
|
61 | 116 | ```bash |
62 | | -cargo test |
| 117 | +cargo doc --open |
63 | 118 | ``` |
64 | 119 |
|
| 120 | +Or browse online: |
| 121 | +[https://docs.rs/mcp-rust-server](https://docs.rs/mcp-rust-server) |
| 122 | + |
65 | 123 | --- |
66 | 124 |
|
67 | | -## 📄 License |
| 125 | +## Contributing |
68 | 126 |
|
69 | | -MIT License - see [LICENSE](../LICENSE) for details. |
| 127 | +Contributions are welcome! Please: |
70 | 128 |
|
71 | | ---- |
| 129 | +1. Fork the repo |
| 130 | +2. Create a feature branch (`git checkout -b feat/your-feature`) |
| 131 | +3. Commit your changes (`git commit -m "Add feature"`) |
| 132 | +4. Push to your fork (`git push origin feat/your-feature`) |
| 133 | +5. Open a pull request |
72 | 134 |
|
73 | | -## 🤝 Contributing |
| 135 | +Run tests and lint before submitting: |
74 | 136 |
|
75 | | -Contributions are welcome! Please open issues or pull requests for improvements. |
| 137 | +```bash |
| 138 | +cargo test |
| 139 | +cargo fmt -- --check |
| 140 | +cargo clippy -- -D warnings |
| 141 | +``` |
76 | 142 |
|
77 | 143 | --- |
78 | 144 |
|
79 | | -## 📚 Documentation |
| 145 | +## License |
80 | 146 |
|
81 | | -- See the main project [README](../README.md) for integration and usage examples. |
82 | | -- API docs: Run `cargo doc --open` |
| 147 | +Licensed under the [MIT License]. See \[LICENSE] for details. |
83 | 148 |
|
84 | 149 | --- |
85 | 150 |
|
86 | | -## Ref |
87 | | -- [Rust-mcp-sdk](https://lib.rs/crates/rust-mcp-sdk) |
88 | | -- [Release tool](https://github.com/release-plz/release-plz) |
| 151 | +## Acknowledgments |
| 152 | + |
| 153 | +* Built on top of the [rust-mcp-sdk] |
| 154 | +* Inspired by the [Syncable CLI MCP Server] |
| 155 | +* Thanks to the Rust community and all contributors |
89 | 156 |
|
90 | | -**Built with Rust 🦀 and the open-source community.** |
| 157 | +[crates.io]: https://crates.io/crates/mcp-rust-server |
| 158 | +[docs.rs]: https://docs.rs/mcp-rust-server |
| 159 | +[examples/]: https://github.com/syncable-dev/syncable-cli-mcp-server/tree/main/examples |
| 160 | +[MIT License]: LICENSE |
| 161 | +[rust-mcp-sdk]: https://crates.io/crates/rust-mcp-sdk |
| 162 | +[Syncable CLI MCP Server]: https://github.com/syncable-dev/syncable-cli-mcp-server |
0 commit comments