rust-sdk  by modelcontextprotocol

Rust SDK for Model Context Protocol

created 5 months ago
1,872 stars

Top 23.7% on sourcepulse

GitHubView on GitHub
Project Summary

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

  • Install: Add rmcp to your Cargo.toml with features like server.
  • Prerequisites: Tokio async runtime.
  • Example Client:
    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(())
    }
    
  • Documentation: examples

Highlighted Details

  • Supports multiple transport mechanisms including stdio, TCP, and Server-Sent Events (SSE).
  • Macro-driven tool definition simplifies the creation and registration of callable functions for AI agents.
  • Enables management of multiple services and provides OAuth support.
  • Includes a ServerInfo struct for describing service capabilities and instructions.

Maintenance & Community

  • The project is maintained by modelcontextprotocol.
  • Development can be facilitated using Dev Containers, with instructions provided in docs/DEVCONTAINER.md.

Licensing & Compatibility

  • The SDK is likely licensed under a permissive license, common for Rust projects, but the specific license is not explicitly stated in the README. Compatibility for commercial use would depend on the exact license.

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.

Health Check
Last commit

2 days ago

Responsiveness

1 day

Pull Requests (30d)
30
Issues (30d)
16
Star History
945 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Travis Fischer Travis Fischer(Founder of Agentic), and
1 more.

fastmcp by punkpeye

3.7%
2k
TypeScript framework for building MCP servers handling client sessions
created 7 months ago
updated 2 days ago
Feedback? Help us improve.