modelcontextprotocol/rust-sdk
Tokio-based Rust SDK for building typed MCP clients and servers
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
RMCP splits the protocol and async service implementation (crates/rmcp) from procedural macros for tool wiring (crates/rmcp-macros). Tokio runs the async services, Serde handles serialization, and schemars generates JSON Schema 2020-12. Applications implement ServerHandler or ClientHandler and bind the handler to a transport; crates/rmcp/src/handler/server.rs and crates/rmcp/src/handler/client.rs are the corresponding extension points.
On the server, ServiceExt::serve() waits for peer input that establishes the protocol lifecycle before returning a handle to the background service. The application can then issue requests or notifications through that handle and await shutdown with waiting() or initiate it with cancel(). The same handler-and-transport model supports a local server over Tokio stdio and a client that launches a subprocess with TokioChildProcess.
Key Capabilities & Differentiators
RMCP implements MCP 2026-07-28 while retaining the legacy 2025-11-25 lifecycle and compatibility with earlier versions. The new revision covers server discovery and negotiation, transport-neutral subscriptions, long-running tasks, response caching, multi-round-trip requests, and standard HTTP routing headers. Client serve() still sends initialize followed by notifications/initialized; in Discover mode, server/discover replaces that handshake and subsequent requests carry the protocol version, client information, and capabilities in _meta.
The #[tool], #[tool_router], and #[tool_handler] macros connect Rust methods to tool discovery and invocation. Generated schemas use field names, types, and field documentation, not docs on the enclosing type. Tool responses can carry mixed text, image, audio, and embedded resource blocks; structured results can be any JSON value under 2026-07-28. Resources are read by URI, with templates for parameterized URIs and notifications for list changes or individual updates.
Trade-offs & Limitations
Compared with hand-writing a narrow JSON-RPC adapter, RMCP takes on message typing, lifecycle handling, and tool schema generation, at the cost of adopting Tokio and the SDK's handler model. The tools-only macro shortcut minimizes wiring, but custom metadata or additional capabilities call for an explicit handler. Tool failures that callers should see belong in CallToolResult::error; Err(McpError) is for requests the server cannot route or process.
For mixed peer versions, choose the lifecycle deliberately: Auto can fall back when server/discover is unsupported, but a silent peer can add a 10-second wait before fallback. For stdio deployments, a server started without a client can wait at startup; serve_with_ct() supports startup cancellation, but Tokio's blocking stdin read can still delay runtime shutdown until input or EOF. Test both startup and shutdown with the actual client or process supervisor.
Hardware & Deployment Guide
The workspace uses Rust edition 2024 and declares Rust 1.88 as its minimum. Add the published crate with cargo add rmcp --features server for a server integration. For a local smoke test, build the counter with cargo build -p mcp-server-examples --example servers_counter_stdio, then run npx @modelcontextprotocol/inspector --cli ./target/debug/examples/servers_counter_stdio --method tools/list so Inspector launches the process and sends protocol messages.
The stdio path does not require a network listener or a GPU for protocol handling; size the process and any child services around representative handler workloads, payloads, and concurrency. Use the migration guide when moving to 3.x. In rmcp-v3.12.0, chrono became optional behind a default-enabled feature, typed results were preserved for numeric cache TTLs, and list_all_* pagination gained a cap. The matching macro release fixed description extraction when other attributes follow doc comments.
rmcp implements the protocol and services; rmcp-macros generates tool routing and handler wiring.serve() uses legacy initialization; serve_with_lifecycle adds explicit Discover and Auto modes.schemars derives JSON Schema 2020-12 from Rust fields; MCP 2026-07-28 allows non-object output schemas and arbitrary JSON structured content.TokioChildProcess supports this pattern on the client side.rmcp-v3.12.0 bounds list_all_* pagination and gates chrono behind a default-enabled feature.Rust teams exposing existing business logic as MCP tools or URI-addressable resources, or embedding a client that must handle both legacy initialization and newer discovery.
You need a ready-to-run server rather than a library, or your application already uses another runtime and has no reason to add a Rust component.
Quick Start & Installation
cargo add rmcp --features server
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| rust-sdk ★ | 4.2k | +38 | Rust | — | Tokio-based Rust SDK for building typed MCP clients and servers |
| headroom | 81.5k | +455 | Python | Apache-2.0 | Local context compression for LLMs via a Python library, proxy, and MCP server |
| chrome-devtools-mcp | 60.4k | +760 | TypeScript | Apache-2.0 | Chrome DevTools via MCP and CLI for live browser debugging and performance analy |
| gemini-cli | 109.6k | +376 | TypeScript | Apache-2.0 | A Node.js terminal agent for enterprise Gemini coding workflows and MCP tools |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/modelcontextprotocol/rust-sdk.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about rust-sdk
How do I expose an existing Rust service over MCP?
#[tool] and #[tool_router(server_handler)] for a tools-only service. Use an explicit ServerHandler with #[tool_handler] when you need custom server metadata or additional capabilities. For resources, advertise the capability in get_info() and implement list_resources() and read_resource().What hardware does an RMCP service need?
Can we use it commercially and self-host it?
When should we choose RMCP over a handwritten adapter or another language's SDK?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy