mcpkit
A Rust SDK for the Model Context Protocol (MCP) that simplifies server development through a unified #[mcp_server] macro.
Features
- Unified
#[mcp_server]macro for defining tools, resources, and prompts - Runtime-agnostic async support (Tokio, async-std, smol)
- Typestate builders for compile-time validation of server configuration
- Context-based error handling with
McpErrorand.context()chains - MCP 2025-11-25 protocol including Tasks, Elicitation, and OAuth 2.1
- Tower-compatible middleware via built-in Layer pattern
Why mcpkit?
mcpkit implements MCP 2025-11-25 — the latest protocol specification. As of December 2025, the official rmcp SDK documentation references protocol version 2024-11-05 (always verify current status). mcpkit supports the newest MCP features:
| Feature | Added In | Description |
|---|---|---|
| Tasks | 2025-11-25 | Long-running operations with progress tracking and cancellation |
| Elicitation | 2025-06-18 | Server-initiated requests for user input |
| OAuth 2.1 | 2025-03-26 | Modern authentication with mandatory PKCE |
| Tool Annotations | 2025-03-26 | readOnly, destructive, idempotent hints for tools |
| Structured Output | 2025-06-18 | Type-safe JSON responses with schema validation |
See the detailed comparison for a full overview of Rust MCP SDK options.
Quick Start
Add the dependency to your Cargo.toml:
[]
= "0.2"
= { = "1", = ["full"] }
= "1"
Create a simple MCP server:
use *;
use StdioTransport;
;
async
Note: This SDK is runtime-agnostic. You provide the transport, which lets you use Tokio, async-std, smol, or any other async runtime. The examples use Tokio, but the SDK itself doesn't depend on any specific runtime.
mcpkit Highlights
| Feature | Description |
|---|---|
| Protocol | MCP 2025-11-25 (supports all 4 protocol versions) |
| Macro | Single #[mcp_server] with #[tool], #[resource], #[prompt] |
| Parameters | Extracted directly from function signatures |
| Errors | Unified McpError with .context() chains |
| Transports | stdio, WebSocket, HTTP/SSE, Unix sockets |
| Middleware | Built-in Tower-compatible Layer system |
| Runtime | Agnostic (Tokio, async-std, smol) |
For comparisons with other Rust MCP SDKs (rmcp, rust-mcp-sdk, mcp-protocol-sdk), see the detailed comparison.
Crate Structure
mcpkit/
├── mcpkit/ # Facade crate (use this)
├── crates/
│ ├── mcpkit-core/ # Protocol types, traits
│ ├── mcpkit-transport/ # Transport abstractions
│ │ ├── stdio # Standard I/O transport
│ │ ├── http # Streamable HTTP transport
│ │ ├── websocket # WebSocket transport
│ │ └── unix # Unix domain sockets
│ ├── mcpkit-server/ # Server implementation
│ ├── mcpkit-client/ # Client implementation
│ ├── mcpkit-macros/ # Procedural macros
│ ├── mcpkit-testing/ # Test utilities
│ ├── mcpkit-axum/ # Axum web framework integration
│ └── mcpkit-actix/ # Actix-web framework integration
└── examples/ # Example servers
Examples
Minimal Server
use *;
;
With Resources
use *;
;
With Prompts
use *;
;
Transports
The SDK is runtime-agnostic. You choose the transport and the async runtime.
Standard I/O
use StdioTransport;
let transport = new;
HTTP (Streamable)
use HttpTransport;
let transport = new;
WebSocket
use WebSocketTransport;
let transport = new;
Unix Domain Socket (Unix only)
use UnixTransport;
let transport = new;
Middleware
use StdioTransport;
use ;
use Duration;
use Level;
let transport = new;
let stack = new
.with
.with;
Error Handling
use *;
Protocol Version
This SDK implements MCP protocol version 2025-11-25.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Documentation
- Getting Started
- Working with Tools
- Working with Resources
- Working with Prompts
- Error Handling
- Using Middleware
- Transport Options
- Architecture Decision Records
Contributing
Contributions are welcome! Please read our Contributing Guide before submitting a Pull Request.
Security
For security issues, please see our Security Policy.