
Write HTML. Render video. Built for agents.
Rust MCP SDK is a Rust framework for building Model Context Protocol servers and clients. It handles protocol details, transports like stdio and HTTP, and provides macros for tools, prompts, resources, and elicitation.

Builders who want to ship MCP servers or clients in Rust without wiring the protocol by hand.
You can build MCP integrations faster while keeping protocol, transport, and auth plumbing in the SDK.
Provides `McpServer` and `McpClient` support with async handlers for MCP requests and notifications.
Supports stdio, Streamable HTTP, and backward-compatible SSE transport.
Adds Axum and Actix integration, plus BYO-server mounting for existing apps.
Generates tools, prompts, resources, resource templates, elicitation types, and icons from Rust structs.
Includes OAuth support for MCP servers and clients, plus remote auth provider patterns.
Passes official MCP conformance tests and can observe messages for logging and monitoring.
A high-performance, asynchronous Rust toolkit for building MCP servers and clients.
Documentation · Tutorials · Examples · Upgrade Guide · Changelog
Contributing · Report a bug · Request a Feature
This SDK fully implements the MCP 2026-07-28 stateless protocol and passes 100% of official MCP conformance tests (110/110 server, 440/440 client).
rust-mcp-sdk provides the necessary components for developing both servers and clients in the MCP ecosystem. It leverages the rust-mcp-schema crate for type-safe schema objects and includes powerful procedural macros.
Focus on your application logic, rust-mcp-sdk handles the protocol, transports, and the rest.
⚠️ Version notice: This is
rust-mcp-sdk2.x, implementing the new MCP 2026-07-28 (stateless) specification. For the previous MCP 2025-11-25 specification, userust-mcp-sdk1.x:rust-mcp-sdk = "1"See the upgrade guide to migrate from 1.x to 2.0.
Version matrix:
SDK version Protocol Branch 2.0 MCP 2026-07-28 (stateless) main1.x (LTS) MCP 2025-11-25 release-1.xUpgrading? See the upgrade guide.
Key Features
_meta with RequestContextiss validation (SEP-2468)Add to your Cargo.toml:
[dependencies]
rust-mcp-sdk = "2.0.0" # Check crates.io for the latest version
use async_trait::async_trait;
use rust_mcp_sdk::{
error::SdkResult, macros, mcp_icon,
mcp_server::{server_runtime, McpServerOptions, ServerHandler},
schema::*,
McpServer, RequestContext, ServerDetails, StdioTransport, ToMcpServerHandler,
TransportOptions,
};
// Define an MCP tool
#[macros::mcp_tool(name = "say_hello", description = "returns \"Hello from Rust MCP SDK!\" message")]
#[derive(Debug, ::serde::Deserialize, ::serde::Serialize, macros::JsonSchema)]
pub struct SayHelloTool {}
// Define a custom handler
#[derive(Default)]
struct HelloHandler;
#[async_trait]
impl ServerHandler for HelloHandler {
async fn handle_list_tools_request(
&self,
_request: Option<PaginatedRequestParams>,
_context: &RequestContext,
_runtime: std::sync::Arc<dyn McpServer>,
) -> std::result::Result<ListToolsResult, RpcError> {
Ok(ListToolsResult {
tools: vec![SayHelloTool::tool()],
meta: None,
next_cursor: None,
cache_scope: Default::default(),
result_type: "complete".to_string(),
ttl_ms: 0,
})
}
async fn handle_call_tool_request(
&self,
params: CallToolRequestParams,
_context: &RequestContext,
_runtime: std::sync::Arc<dyn McpServer>,
) -> std::result::Result<ServerResult, CallToolError> {
if params.name == "say_hello" {
Ok(ServerResult::CallToolResult(CallToolResult {
content: vec![ContentBlock::TextContent(TextContent::new(
"Hello from Rust MCP SDK!".to_string(),
None,
None,
))],
is_error: None,
meta: None,
result_type: "complete".to_string(),
}))
} else {
Err(CallToolError::unknown_tool(params.name))
}
}
}
#[tokio::main]
async fn main() -> SdkResult<()> {
let server_details = ServerDetails {
server_info: Implementation {
name: "hello-rust-mcp".into(),
version: "0.1.0".into(),
title: Some("Hello World MCP Server".into()),
description: Some("A minimal Rust MCP server".into()),
icons: vec![mcp_icon!(
src = "https://raw.githubusercontent.com/rust-mcp-stack/rust-mcp-sdk/main/assets/rust-mcp-icon.png",
mime_type = "image/png",
sizes = ["128x128"],
theme = "light"
)],
website_url: Some("https://github.com/rust-mcp-stack/rust-mcp-sdk".into()),
},
capabilities: ServerCapabilities {
tools: Some(ServerCapabilitiesTools { list_changed: None }),
..Default::default()
},
instructions: None,
meta: None,
};
let transport = StdioTransport::new(TransportOptions::default())?;
let handler = HelloHandler::default().to_mcp_server_handler();
let server = server_runtime::create_server(McpServerOptions {
server_details,
transport,
handler,
message_observer: None,
});
server.start().await
}
Creating a Streamable HTTP MCP server in rust-mcp-sdk allows multiple clients to connect simultaneously with no additional setup. The setup is nearly identical to the stdio example , the only difference is which HTTP backend crate you install and which function you call to create the server.
Post only - the 2026-07-28 protocol is stateless. GET and DELETE endpoints return 405 Method Not Allowed.
rust-mcp-axum)Add rust-mcp-axum to your dependencies and use create_axum_server() with AxumServerOptions.
use async_trait::async_trait;
use rust_mcp_axum::{create_axum_server, AxumServerOptions};
use rust_mcp_sdk::{
error::SdkResult, macros,
mcp_server::ServerHandler, schema::*,
};
// ... (define SayHelloTool and HelloHandler as shown above)
#[tokio::main]
async fn main() -> SdkResult<()> {
let server_details = ServerDetails { /* ... */ };
let handler = HelloHandler::default().to_mcp_server_handler();
let server = create_axum_server(
server_details,
handler,
AxumServerOptions {
host: "127.0.0.1".to_string(),
..Default::default()
},
);
server.start().await?;
Ok(())
}
rust-mcp-actix)Add rust-mcp-actix to your dependencies and use create_actix_server() with ActixServerOptions.
use rust_mcp_actix::{create_actix_server, ActixServerOptions};
use rust_mcp_sdk::{
error::SdkResult,
mcp_server::ServerHandler, schema::*,
};
// ... (define SayHelloTool and HelloHandler as shown above)
#[tokio::main]
async fn main() -> SdkResult<()> {
let server_details = ServerDetails { /* ... */ };
let handler = HelloHandler::default().to_mcp_server_handler();
let server = create_actix_server(
server_details,
handler,
ActixServerOptions {
host: "127.0.0.1".to_string(),
..Default::default()
},
);
server.start().await?;
Ok(())
}
Both backends support a BYO-server (Bring Your Own Server) mode, letting you mount MCP endpoints onto a router or app you already control - no need to hand over the server lifecycle.
| Backend | Function | Docs |
|---|---|---|
| Axum | mcp_routes(state, &mount_opts, http_handler) | rust-mcp-axum README |
| Actix-web | mcp_scope(state, http_handler, &mount_opts) | rust-mcp-actix README |
The SDK is completely framework-agnostic. If you are using a different HTTP framework (like Rocket, Salvo, or Warp), you can build a custom integration by adapting your framework's native Request/Response types to the SDK's core HTTP handling logic.
See the Custom HTTP Framework Integration Guide for architectural details.
Axum server is highly customizable through AxumServerOptions:
let server = create_axum_server(
server_details,
handler.to_mcp_server_handler(),
AxumServerOptions {
host: "127.0.0.1".to_string(),
port: 8080,
auth: Some(Arc::new(auth_provider)), // enable authentication
health_endpoint: Some("/health".into()), // health check
sse_support: true, // backward-compat SSE
..Default::default()
},
);
server.start().await?;
allowed_hosts is not set, it auto-derives from host:port.Following is implementation of an MCP client that starts the @modelcontextprotocol/server-everything server, discovers the server's capabilities, lists available tools, and calls a tool.
use async_trait::async_trait;
use rust_mcp_sdk::{
error::SdkResult,
mcp_client::{client_runtime, ClientHandler, McpClientOptions},
schema::*,
ClientDetails, McpClient, StdioTransport, ToMcpClientHandler, TransportOptions,
};
pub struct MyClientHandler;
#[async_trait]
impl ClientHandler for MyClientHandler {
// Override handler methods as needed.
// See: crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler.rs
}
#[tokio::main]
async fn main() -> SdkResult<()> {
let client_details = ClientDetails {
client_info: Implementation {
name: "simple-rust-mcp-client".into(),
version: "0.1.0".into(),
description: None,
icons: vec![],
title: None,
website_url: None,
},
capabilities: ClientCapabilities::default(),
};
let transport = StdioTransport::create_with_server_launch(
"npx",
vec!["-y".to_string(), "@modelcontextprotocol/server-everything@latest".to_string()],
None,
TransportOptions::default(),
)?;
let handler = MyClientHandler {};
let client = client_runtime::create_client(McpClientOptions::new(
client_details,
transport,
handler.to_mcp_client_handler(),
));
client.clone().start().await?;
// Discover the server
let discover = client.request_discover(Default::default()).await?;
println!("Supported protocol versions: {:?}", discover.supported_versions);
// List tools
let tools = client.request_tool_list(None).await?.tools;
tools.iter().enumerate().for_each(|(i, tool)| {
println!(" {}. {} : {}", i + 1, tool.name, tool.description.unwrap_or_default());
});
// Call a tool (supports MRTR auto-retry)
let result = client.call_tool(CallToolRequestParams {
name: "say_hello".to_string(),
arguments: None,
input_responses: None,
request_state: None,
meta: RequestMetaObject::default(),
}).await?;
client.shut_down().await?;
Ok(())
}
For more examples (stdio, Streamable HTTP, clients, auth, etc.), see the examples/ directory.
👉 For step-by-step tutorials (server, client, HTTP deployment, OAuth, and more), see the documentation site.
See the hello-world-mcp-server-stdio example running in the MCP Inspector:
Enable with the macros feature.
mcp_toolGenerate a Tool from a struct, with metadata (icons, hints, etc.).
#[mcp_tool(
name = "write_file",
title = "Write File Tool",
description = "Create or overwrite a file with new content.",
destructive_hint = false, idempotent_hint = false, open_world_hint = false, read_only_hint = false,
meta = r#"{ "key": "value" }"#,
icons = [(src = "https://website.com/write.png", mime_type = "image/png", sizes = ["128x128"], theme = "light")]
)]
#[derive(rust_mcp_macros::JsonSchema)]
pub struct WriteFileTool {
/// The target file's path for writing content.
pub path: String,
/// The string content to be written to the file
pub content: String,
}
tool_box!()Automatically generates an enum based on the provided list of tools.
tool_box!(GreetingTools, [SayHelloTool, SayGoodbyeTool]);
let tools: Vec<Tool> = GreetingTools::tools();
mcp_elicit()Generates type-safe elicitation (Form or URL mode) for user input.
#[mcp_elicit(message = "Please enter your info", mode = form)]
#[derive(JsonSchema)]
pub struct UserInfo {
#[json_schema(title = "Name", min_length = 5, max_length = 100)]
pub name: String,
#[json_schema(title = "Email", format = "email")]
pub email: Option<String>,
#[json_schema(title = "Age", minimum = 15, maximum = 125)]
pub age: i32,
#[json_schema(title = "Tags")]
pub tags: Vec<String>,
}
A procedural macro attribute that generates utility methods to create fully populated Resource instances from compile-time metadata , usually used for exposing static assets like files, images, or documents. Also generates a RESOURCE_URI associated constant, usable in match patterns, and a resource_mime_type() accessor.
📝 For complete documentation, example usage, and a list of all available attributes, please refer to https://crates.io/crates/rust-mcp-macros.
A procedural macro attribute that generates utility methods to create fully populated ResourceTemplate instances from compile-time metadata for exposing parameterized server resources. Also generates a RESOURCE_URI_TEMPLATE associated constant, usable in match patterns, and a resource_template_mime_type() accessor.
📝 For complete documentation, example usage, and a list of all available attributes, please refer to https://crates.io/crates/rust-mcp-macros.
A procedural macro attribute that generates utility methods to create fully populated Prompt instances from compile-time metadata, and , when the optional messages attribute is provided , to parse request arguments (from_arguments) and render them into a GetPromptResult (render). Struct fields become typed prompt arguments (String = required, Option<String> = optional, String + default = fallback), the prompts/get handler itself is left to the user.
📝 For complete documentation, example usage, and a list of all available attributes, please refer to https://crates.io/crates/rust-mcp-macros.
mcp_icon!()A convenient icon builder for implementations and tools, offering full attribute support including theme, size, mime, and more.
example usage:
let icon: crate::schema::Icon = mcp_icon!(
src = "http://website.com/icon.png",
mime_type = "image/png",
sizes = ["64x64"],
theme = "dark"
);
MCP servers can verify tokens issued by other systems, integrate with external identity providers, or manage the entire authentication process.
RemoteAuthProvider enables authentication with identity providers that support Dynamic Client Registration (DCR), letting MCP clients auto-register and obtain credentials.
OAuthProxy enables authentication with OAuth providers that don't support DCR.
server: Activates MCP server capabilitiesclient: Activates MCP client capabilitiesmacros: Procedural macros for Tool, Elicit, Resource structuressse: Server-Sent Events (SSE) transportstreamable-http: Streamable HTTP transportstdio: Standard input/output (stdio) transportauth: OAuth authentication support for MCP serverstls-no-provider: TLS without a crypto providerAll features are enabled by default:
[dependencies]
rust-mcp-sdk = "2.0.0"
[dependencies]
rust-mcp-sdk = { version = "2.0.0", default-features = false, features = ["server", "macros", "stdio"] }
[dependencies]
rust-mcp-sdk = { version = "2.0.0", default-features = false, features = ["client", "stdio"] }
ServerHandler and ServerHandlerCoreNote: Use server_runtime::create_server() or server_runtime_core::create_server() depending on which handler you implement.
ClientHandler and ClientHandlerCoreSame principles apply on the client side: use client_runtime::create_client() with ClientHandler, or client_runtime_core::create_client() with ClientHandlerCore.
Implement McpObserver to intercept all incoming and outgoing MCP messages for telemetry, logging, debugging, or monitoring.
let server = server_runtime::create_server(McpServerOptions {
server_details,
transport,
handler: handler.to_mcp_server_handler(),
message_observer: Some(SimpleServerObserver::new()),
});
An optional HTTP health check endpoint for load balancers and container orchestration:
let server = create_axum_server(
server_details,
handler.to_mcp_server_handler(),
AxumServerOptions {
host: "127.0.0.1".into(),
health_endpoint: Some("/health".into()),
..Default::default()
},
);
| Name | Description | Link | |
|---|---|---|---|
![]() | Rust MCP Filesystem | Fast, async MCP server enabling high-performance, modern filesystem operations with advanced features. | GitHub |
![]() | MCP Discovery | A lightweight command-line tool for discovering and documenting MCP Server capabilities. | GitHub |
| mistral.rs | Blazingly fast LLM inference. | GitHub | |
| moon | moon is a repository management, organization, orchestration, and notification tool for the web ecosystem, written in Rust. | GitHub | |
![]() | [destructive_command_guard](https://github.com/Dicklesworthstone/destr |
Sign in to join the discussion.
No comments yet. Be the first to say what this is good for.

Write HTML. Render video. Built for agents.
Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps
SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.
A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.
🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!