TurboMCP
Rust SDK for the Model Context Protocol with SIMD acceleration, robust transport layer, and ergonomic APIs. Build MCP servers with comprehensive reliability features.
Key Features
Built with performance, reliability, and developer experience in mind.
SIMD Acceleration
Fast JSON processing with sonic-rs and simd-json for 2-3x performance improvements over standard libraries.
Multi-Transport Support
Five transport protocols with runtime selection and feature-gated compilation.
OAuth 2.0 Authentication
World-class authentication with Google, GitHub, Microsoft providers and always-on PKCE security.
Zero-Overhead Macros
Ergonomic procedural macros that generate optimal code without runtime overhead.
Type Safety
Compile-time validation and automatic schema generation for robust API contracts.
MCP 2025 Compliance
Full compliance with the latest Model Context Protocol specification for maximum compatibility.
Modular Architecture
Clean, layered architecture with 8 specialized crates for maximum flexibility and maintainability.
Main SDK with ergonomic APIs
Foundation with SIMD acceleration
MCP specification implementation
Multi-protocol transport layer
Server framework and middleware
MCP client implementation
Procedural macro definitions
Command-line development tools
Simple, Powerful APIs
Build MCP servers with minimal boilerplate using our ergonomic macros and type-safe APIs.
use turbomcp::prelude::*;
use std::sync::{atomic::AtomicU64, Arc};
#[derive(Clone)]
struct Calculator {
operations: Arc<AtomicU64>,
}
#[server]
impl Calculator {
#[tool("Add two numbers")]
async fn add(&self, a: i32, b: i32) -> McpResult<i32> {
self.operations
.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
Ok(a + b)
}
#[tool("Get server statistics")]
async fn stats(&self) -> McpResult<String> {
let ops = self.operations.load(std::sync::atomic::Ordering::Relaxed);
Ok(format!("Operations performed: {}", ops))
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = Calculator {
operations: Arc::new(AtomicU64::new(0)),
};
server.run_stdio().await?;
Ok(())
}
Get started with TurboMCP in your Cargo.toml
Powerful Macro System
Zero-overhead procedural macros that generate optimal code for all MCP operations.
Attribute Macros #[...]
Procedural attribute macros for server definitions and method handlers.
Server Definition
Define MCP servers with automatic trait implementations
Tool Handlers
Create tool endpoints with parameter validation
Resource Providers
Handle resource requests with URI templating
Prompt Generators
Generate dynamic prompts for AI interactions
Macro Invocations name!()
Helper macros for creating formatted content, errors, and responses.
Text Content Blocks
Create ContentBlock structures (often used with tool_result!)
Tool Results (Advanced)
Create CallToolResult manually (usually auto-handled by #[tool])
Error Creation
Create MCP errors (use with Err(mcp_error!(...)))
Ready-to-Use Examples
Get started quickly with our comprehensive examples covering everything from basic servers to advanced use cases.
use turbomcp::prelude::*;
#[derive(Clone)]
struct Calculator {
operations: std::sync::Arc<std::sync::atomic::AtomicU64>,
}
#[server]
impl Calculator {
#[tool("Add two numbers")]
async fn add(&self, a: i32, b: i32) -> McpResult<i32> {
self.operations.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
Ok(a + b)
}
#[tool("Get server statistics")]
async fn stats(&self) -> McpResult<String> {
let ops = self.operations.load(std::sync::atomic::Ordering::Relaxed);
Ok(format!("Operations performed: {}", ops))
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = Calculator {
operations: std::sync::Arc::new(std::sync::atomic::AtomicU64::new(0)),
};
server.run_stdio().await?;
Ok(())
}
Run any example with cargo:
Performance Benchmarks
Optimized for fast processing with measurable performance improvements. Benchmarks conducted on consumer hardware (MacBook Pro M3, 32GB RAM).
2-3x Faster
JSON processing performance vs serde_json
Zero Copy
Memory-efficient message handling
SIMD
Hardware-accelerated processing
Low Latency
Optimized for real-time applications
Ready to Build with TurboMCP?
Start building fast MCP servers today with our comprehensive Rust SDK.