rust -sdk
A high-performance, asynchronous toolkit for building MCP servers and clients in Rust.
claude mcp add --transport stdio rust-mcp-stack-rust-mcp-sdk cargo run --bin rust-mcp-sdk-demo-server \ --env RUST_LOG="info" \ --env MCP_TRANSPORTS="stdio,streamable_http,sse" \ --env MCP_SERVER_BIND="0.0.0.0:8080"
How to use
Rust MCP SDK is a high-performance toolkit for building both MCP servers and clients in Rust. It handles the MCP protocol, transports, and common infrastructure, allowing you to focus on implementing your application logic with tools and user input elicitation baked in. The SDK provides a set of macros for defining MCP tools, a flexible server runtime, and support for multiple transports (stdio, streamable HTTP, and SSE), along with optional OAuth-based authentication. To use it, create a Rust project that depends on rust-mcp-sdk, implement a ServerHandler to expose your tools, and wire up a transport (for example, stdio for local testing or an HTTP transport for remote clients). The included hello-world example demonstrates a minimal server exposing a single SayHello tool that returns a static message.
How to install
Prerequisites:
- Rust toolchain (rustup and cargo)
- Git
Installation steps:
- Install Rust:
- On Unix-like systems: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Follow prompts to install cargo and rustc
- Clone the repository or set up your project with the SDK as a dependency:
- git clone https://github.com/rust-mcp-stack/rust-mcp-sdk.git
- cd rust-mcp-sdk
- In your Rust project, add the SDK as a dependency in Cargo.toml, for example: [dependencies] rust-mcp-sdk = "0.9.0" # or the latest version from crates.io
- Build and run an example server (adjust as needed for your bin name): cargo run --bin rust-mcp-sdk-demo-server
- If you prefer to run a pre-built example, you can explore the examples/ directory (e.g., hello-world-mcp-server-stdio) and adapt it to your project.
Tip: Ensure you have a compatible Rust toolchain and that you enable the desired features in Cargo.toml if you depend on optional components like OAuth providers or extra transports.
Additional notes
Notes and tips:
- The SDK supports multiple transports, including Stdio, Streamable HTTP, and backward-compatible SSE. Configure HyperServerOptions appropriately if you need HTTP-based transport.
- OAuth authentication is supported for MCP servers. You can wire up remote providers (Keycloak, WorkOS, Scalekit) through the provided authentication modules.
- The Rust MCP SDK targets MCP protocol version 2025-11-25 with backward compatibility. When upgrading from older v0.7.x, review breaking changes in the release notes before migrating.
- If you need to expose multiple tools, implement handle_list_tools_request and handle_call_tool_request in your ServerHandler to enumerate and execute tools dynamically.
- For testing locally, the Minimal MCP Server (Stdio) example is a good starting point; you can adapt the same logic to an HTTP or SSE transport as needed.
- Ensure environment variables such as MCP server bind address (MCP_SERVER_BIND) and transport enablement (MCP_TRANSPORTS) are set according to your deployment environment.
- The project is under active development; consider pinning versions and thoroughly testing in a staging environment before production use.
Related MCP Servers
MCP-Defender
Desktop app that automatically scans and blocks malicious MCP traffic in AI apps like Cursor, Claude, VS Code and Windsurf.
mcp-probe
A Model Context Protocol (MCP) client library and debugging toolkit in Rust. This foundation provides both a production-ready SDK for building MCP integrations and the core architecture for an interactive debugger.
mcp
🤖 Taskade MCP · Official MCP server and OpenAPI to MCP codegen. Build AI agent tools from any OpenAPI API and connect to Claude, Cursor, and more.
rust -schema
A type-safe implementation of the official Model Context Protocol (MCP) schema in Rust.
dynamic-shell
Dynamic Shell Command MCP Server
mcp-framework
Rust MCP framework for building AI agents