Rust MCP SDK

Agent frameworks and SDKs

A high-performance, asynchronous toolkit for building MCP servers and clients in Rust.

Your AI app calls Rust MCP SDK, which does the agent frameworks and SDKs work and sends the result back to the chat.

About Rust MCP SDK

Rust MCP SDK is a community MCP server from rust-mcp-stack, filed in our directory under agent frameworks and sdks. A high-performance, asynchronous toolkit for building MCP servers and clients in Rust.

At a glance

Publisher
rust-mcp-stack (community)
Runs
See the README for setup
Written in
Rust
License
MIT
GitHub stars
204

How to set up Rust MCP SDK

  1. Follow the install steps in the Rust MCP SDK README; it is written in Rust, so have that toolchain ready.
  2. Check the Rust MCP SDK README for keys or settings; the registry lists none that Rust MCP SDK requires.
  3. Add Rust MCP SDK to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Rust MCP SDK tools to confirm the connection.
  5. Run one read-only task with Rust MCP SDK first, and keep your app asking before each tool call until the results look right.

Rust MCP SDK compared with similar servers

  • Xiaozhi Mcphub by huangjunsen0406 has fewer GitHub stars than Rust MCP SDK (204 against 204); both are community servers, and both run locally.
  • Agentgeex Core by agentgeex has more GitHub stars than Rust MCP SDK (205 against 204); both are community servers, and both run locally.
  • Adamwattis Proxy by adamwattis has fewer GitHub stars than Rust MCP SDK (201 against 204); both are community servers, and both run locally.

Before you connect Rust MCP SDK

  • Give Rust MCP SDK its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Rust MCP SDK tool call until you trust what it does with them.
  • Treat text that Rust MCP SDK fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Rust MCP SDK on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Rust MCP SDK

How marketing and sales teams put Rust MCP SDK to work, by company size. Pick the size closest to yours and start Rust MCP SDK on one use case.

Small business

  • A small business with a developer can use Rust MCP SDK to build one focused agent, such as lead follow-up, without a big platform.
  • Technical founders can prototype marketing agents with Rust MCP SDK and keep what works as a small, owned tool.
  • Rust MCP SDK runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineering teams can use Rust MCP SDK to build agents that combine CRM, analytics and content tools behind one workflow.
  • Marketing ops can standardize on Rust MCP SDK so every agent they ship has the same logging, approvals and error handling.
  • Start Rust MCP SDK on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can build on Rust MCP SDK with their own identity, policy and evaluation layers, so agents meet the same bar as other software.
  • Platform teams can use Rust MCP SDK to give business units a governed way to ship agents without each one starting from scratch.
  • Rust MCP SDK is a community server, so have security review the code and pin a version before Rust MCP SDK touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Rust MCP SDK README

From rust-mcp-stack/rust-mcp-sdk on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

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

🥇 Tier 1 SDK: passes 100% of scored conformance scenarios, and the official MCP conformance tool's tier-check reports Tier 1 under SEP-1730. Tier-check runs · release reports

✅ This SDK fully implements the MCP 2026-07-28 stateless protocol and passes 100% of official MCP conformance tests.

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-sdk 2.x, implementing the new MCP 2026-07-28 (stateless) specification. For the previous MCP 2025-11-25 specification, use rust-mcp-sdk 1.x. 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) main
1.x (LTS) MCP 2025-11-25 release-1.x

Upgrading? See the upgrade guide.

Key Features

  • ✅ Latest MCP protocol specification supported: 2026-07-28
  • 🥇 Tier 1 SDK - official MCP conformance tool's tier-check reports Tier 1 under SEP-1730. see tier-check runs·
  • ✅ 100% MCP Conformance - passes all official client (254/254) and server (40/40) conformance tests
  • ✅ Transports: Stdio, Streamable HTTP, and backward-compatible SSE support
  • ✅ Framework Agnostic: Axum, Actix, and BYO Server integrations
  • ✅ MRTR (Mid-Request Turn-Around) for server→client input requests
  • ✅ Response cache (SEP-2549) with principal-scoped privacy + auto-pagination
  • ✅ Per-request _meta with RequestContext
  • ✅ Multi-client concurrency
  • ✅ DNS Rebinding Protection
  • ✅ Message Observer (Telemetry & Monitoring)
  • ✅ HTTP Health Checks (for load balancers & container orchestration)
  • ✅ OAuth Authentication for MCP Servers
  • ✅ OAuth Authentication for MCP Clients (metadata discovery, CIMD, PKCE, token refresh, pluggable storage)
  • ✅ Issuer-bound credentials (SEP-2352), strict iss validation (SEP-2468)

Table of Contents

  • Quick Start
  • Minimal MCP Server (Stdio)
  • Minimal MCP Server (Streamable HTTP)
  • Minimal MCP Client (Stdio)
  • Usage Examples
  • Macros
    • mcp_tool
    • tool_box
    • mcp_elicit
    • mcp_resource
    • mcp_resource_template
    • mcp_prompt
    • mcp_icon
  • Authentication
  • HTTP Server Backends (Axum & Actix)
  • Cargo features
  • Handler Traits
  • Message Observer (Telemetry & Monitoring)
  • Health Check Endpoint
  • Contributing
  • Development
  • License

Quick Start

Add to your Cargo.toml:

[dependencies]
rust-mcp-sdk = "2.0.0"  # Check crates.io for the latest version

Minimal MCP Server (Stdio)

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
}

HTTP Server Backends (Axum & Actix)

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.

Axum Backend (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(())
}

Actix-web Backend (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(())
}

BYO-server: Embed MCP in your Existing App

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

Custom HTTP Framework Integrations

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.

AxumServerOptions

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?;

Security Considerations

  • DNS rebinding protection is enabled by default. If allowed_hosts is not set, it auto-derives from host:port.
  • When running locally, bind only to localhost (127.0.0.1 / localhost) rather than all network interfaces (0.0.0.0)
  • Use TLS/HTTPS for production deployments

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(())
}

Usage Examples

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:

Macros

Enable with the macros feature.

mcp_tool

Generate 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>,
}

◾ mcp_resource()

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.

◾ mcp_resource_template()

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.

◾ mcp_prompt()

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"
);

Authentication

MCP servers can verify tokens issued by other systems, integrate with external identity providers, or manage the entire authentication process.

RemoteAuthProvider

RemoteAuthProvider enables authentication with identity providers that support Dynamic Client Registration (DCR), letting MCP clients auto-register and obtain credentials.

OAuthProxy

OAuthProxy enables authentication with OAuth providers that don't support DCR.

Cargo Features

Available Features

  • server: Activates MCP server capabilities
  • client: Activates MCP client capabilities
  • macros: Procedural macros for Tool, Elicit, Resource structures
  • sse: Server-Sent Events (SSE) transport
  • streamable-http: Streamable HTTP transport
  • stdio: Standard input/output (stdio) transport
  • auth: OAuth authentication support for MCP servers
  • tls-no-provider: TLS without a crypto provider

Default Features

All features are enabled by default:

[dependencies]
rust-mcp-sdk = "2.0.0"

Using Only the Server Features

[dependencies]
rust-mcp-sdk = { version = "2.0.0", default-features = false, features = ["server", "macros", "stdio"] }

Using Only the Client Features

[dependencies]
rust-mcp-sdk = { version = "2.0.0", default-features = false, features = ["client", "stdio"] }

Handler Traits

Choosing Between ServerHandler and ServerHandlerCore

  • ServerHandler: Recommended. Default implementations for all MCP messages. Override only what you need.
  • ServerHandlerCore: Full control over request/notification/error dispatch.

Note: Use server_runtime::create_server() or server_runtime_core::create_server() depending on which handler you implement.

Choosing Between ClientHandler and ClientHandlerCore

Same principles apply on the client side: use client_runtime::create_client() with ClientHandler, or client_runtime_core::create_client() with ClientHandlerCore.

Message Observer (Telemetry & Monitoring)

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()),
});

Health Check Endpoint

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()
    },
);

Contributing

We welcome everyone who wishes to contribute! Please refer to the contributing guidelines for more details.

Check out our development guide for instructions on setting up, building, testing, formatting, and trying out example projects.

All contributions, including issues and pull requests, must follow Rust's Code of Conduct.

Unless explicitly stated otherwise, any contribution you submit for inclusion in rust-mcp-sdk is provided under the terms of the MIT License, without any additional conditions or restrictions.

Development

Check out our development guide for instructions on setting up, building, testing, formatting, and trying out example projects.

License

This project is licensed under the MIT License. see the LICENSE file for details.

Questions about Rust MCP SDK

What is the Rust MCP SDK MCP server?

A high-performance, asynchronous toolkit for building MCP servers and clients in Rust. Rust MCP SDK is maintained by rust-mcp-stack on GitHub at rust-mcp-stack/rust-mcp-sdk, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Rust MCP SDK MCP server?

Rust MCP SDK doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (rust-mcp-stack/rust-mcp-sdk). Like most servers, Rust MCP SDK ends with a command or URL you paste into your AI app's MCP config.

Does Rust MCP SDK need an API key?

The registry lists no required keys for Rust MCP SDK. Check the Rust MCP SDK README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Rust MCP SDK an official MCP server?

No. Rust MCP SDK is a community server maintained by rust-mcp-stack. Community servers can be excellent; read the code and the open issues before you give Rust MCP SDK access to company data.

What license is Rust MCP SDK under?

Rust MCP SDK is released under the MIT license, according to its GitHub repository. The license covers the code of Rust MCP SDK; the service it connects to has its own terms.