Rust SDK for Model Context Protocol
Top 23.7% on sourcepulse
This Rust SDK provides an implementation of the Model Context Protocol (MCP) for building AI agent services. It enables developers to create clients and servers that communicate using JSON-RPC over various transports, facilitating the integration of AI models and tools into applications.
How It Works
The SDK leverages Tokio for asynchronous operations and defines traits for building communication transports (e.g., stdio, TCP, SSE) and service handlers. It supports defining tools with custom logic using macros, which automatically generate necessary metadata for RPC calls. Services can be managed collectively and interact with clients via requests and notifications.
Quick Start & Requirements
rmcp
to your Cargo.toml
with features like server
.use rmcp::{ServiceExt, transport::TokioChildProcess};
use tokio::process::Command;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ().serve(
TokioChildProcess::new(Command::new("npx").arg("-y").arg("@modelcontextprotocol/server-everything"))?
).await?;
let roots = client.list_roots().await?;
Ok(())
}
Highlighted Details
ServerInfo
struct for describing service capabilities and instructions.Maintenance & Community
modelcontextprotocol
.docs/DEVCONTAINER.md
.Licensing & Compatibility
Limitations & Caveats
The README does not explicitly state the license, which is crucial for determining commercial usability. Some advanced features like SSE transports or specific tool integrations might require deeper dives into the examples or source code.
2 days ago
1 day