mcpkit
A production-grade Rust SDK for the Model Context Protocol (MCP) that dramatically reduces boilerplate through a unified #[mcp_server] macro.
Features
- 66% less boilerplate via unified
#[mcp_server]macro - Runtime-agnostic async support (Tokio, async-std, smol)
- Type-safe state machines via typestate pattern for connection lifecycle
- Rich error handling with context chains
- Full MCP 2025-11-25 protocol coverage including Tasks (which rmcp lacks)
- First-class middleware via Tower-compatible Layer pattern
Quick Start
Add the dependency to your Cargo.toml:
[]
= "0.1"
= { = "1.0", = ["full"] }
= "1"
Create a simple MCP server:
use *;
use ServerBuilder;
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.
Comparison with rmcp
| Aspect | rmcp | This SDK |
|---|---|---|
| Macros | 4 interdependent | 1 unified #[mcp_server] |
| Boilerplate | Manual router wiring | Zero initialization |
| Parameters | Parameters<T> wrapper |
Direct from signature |
| Error types | 3 nested layers | 1 unified McpError |
| Tasks | Not implemented | Full support |
| WebSocket | Custom implementation | First-class |
| Middleware | Manual/Tower separate | Built-in Layer system |
| Runtime | Tokio-only | Runtime-agnostic |
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.