* docs: add prose documentation for core features to meet conformance * docs: remove static coverage badge and svg * docs: rewrite Chinese README to match current English README
6.1 KiB
6.1 KiB
RMCP
An official Rust Model Context Protocol SDK implementation with tokio async runtime.
This repository contains the following crates:
- rmcp: The core crate providing the RMCP protocol implementation - see rmcp
- rmcp-macros: A procedural macro crate for generating RMCP tool implementations - see rmcp-macros
Usage
Import the crate
rmcp = { version = "0.16.0", features = ["server"] }
## or dev channel
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "main" }
Third Dependencies
Basic dependencies:
Build a Client
Start a client
use rmcp::{ServiceExt, transport::{TokioChildProcess, ConfigureCommandExt}};
use tokio::process::Command;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ().serve(TokioChildProcess::new(Command::new("npx").configure(|cmd| {
cmd.arg("-y").arg("@modelcontextprotocol/server-everything");
}))?).await?;
Ok(())
}
Build a Server
Build a transport
use tokio::io::{stdin, stdout};
let transport = (stdin(), stdout());
Build a service
You can easily build a service by using ServerHandler or ClientHandler.
let service = common::counter::Counter::new();
Start the server
// this call will finish the initialization process
let server = service.serve(transport).await?;
Interact with the server
Once the server is initialized, you can send requests or notifications:
// request
let roots = server.list_roots().await?;
// or send notification
server.notify_cancelled(...).await?;
Waiting for service shutdown
let quit_reason = server.waiting().await?;
// or cancel it
let quit_reason = server.cancel().await?;
Examples
See examples.
Feature Documentation
See docs/FEATURES.md for detailed documentation on core MCP features: resources, prompts, sampling, roots, logging, completions, notifications, and subscriptions.
OAuth Support
See Oauth_support for details.
Related Resources
Related Projects
Extending rmcp
- rmcp-actix-web - An
actix_webbackend forrmcp - rmcp-openapi - Transform OpenAPI definition endpoints into MCP tools
Built with rmcp
- goose - An open-source, extensible AI agent that goes beyond code suggestions
- apollo-mcp-server - MCP server that connects AI agents to GraphQL APIs via Apollo GraphOS
- rustfs-mcp - High-performance MCP server providing S3-compatible object storage operations for AI/LLM integration
- containerd-mcp-server - A containerd-based MCP server implementation
- rmcp-openapi-server - High-performance MCP server that exposes OpenAPI definition endpoints as MCP tools
- nvim-mcp - A MCP server to interact with Neovim
- terminator - AI-powered desktop automation MCP server with cross-platform support and >95% success rate
- stakpak-agent - Security-hardened terminal agent for DevOps with MCP over mTLS, streaming, secret tokenization, and async task management
- video-transcriber-mcp-rs - High-performance MCP server for transcribing videos from 1000+ platforms using whisper.cpp
- NexusCore MCP - Advanced malware analysis & dynamic instrumentation MCP server with Frida integration and stealth unpacking capabilities
- spreadsheet-mcp - Token-efficient MCP server for spreadsheet analysis with automatic region detection, recalculation, screenshot, and editing support for LLM agents
- hyper-mcp - A fast, secure MCP server that extends its capabilities through WebAssembly (WASM) plugins
- rudof-mcp - RDF validation and data processing MCP server with ShEx/SHACL validation, SPARQL queries, and format conversion. Supports stdio and streamable HTTP transports with full MCP capabilities (tools, prompts, resources, logging, completions, tasks)
Development
Tips for Contributors
See docs/CONTRIBUTE.MD to get some tips for contributing.
Using Dev Container
If you want to use dev container, see docs/DEVCONTAINER.md for instructions on using Dev Container for development.