Enterprise-Ready MCP SDK

TurboMCP

Production-ready Rust SDK for the Model Context Protocol with RFC 9449 DPoP security, type-state capability builders, SIMD acceleration, and zero-cost abstractions. Enterprise-grade features for mission-critical AI infrastructure.

2-3x
Faster JSON
5
Transport Options
Zero
Overhead Macros
v1.1.0
Latest Release
MIT
License

Key Features

Built with performance, reliability, and developer experience in mind.

RFC 9449 DPoP Security Suite

Complete Demonstration of Proof-of-Possession implementation with enterprise-grade OAuth 2.0 enhancements.

Token theft prevention
Multi-store support (Memory/Redis/HSM)
ES256/RS256 algorithms
YubiHSM2 integration
PKCS#11 support
Auto key rotation

Type-State Capability Builders

Revolutionary const-generic builders with compile-time validation and impossible state prevention.

Compile-time validation
Zero-cost abstractions
Impossible states prevented
SIMD optimization hints
Pre-configured patterns
Enterprise security modes

SIMD Acceleration

Fast JSON processing with sonic-rs and simd-json for 2-3x performance improvements over standard libraries.

SIMD JSON parsing
Zero-copy processing
Streaming support
Memory optimization
black_box benchmarks
WebSocket Message::Text API

Advanced Transport Layer

Enterprise-ready transport with Axum integration, circuit breakers, and modern WebSocket support.

Axum web framework
Circuit breakers
Connection pooling
WebSocket v0.27.0
HTTP/SSE streaming
TCP & Unix sockets
Graceful shutdown

Revolutionary Macro System

Zero-boilerplate MCP tools with compile-time validation, automatic schema generation, and ergonomic async support.

#[tool] procedural macros
Automatic registration
Type-safe parameters
Schema generation
Send-safe contexts
ctx_info! ergonomics

Complete MCP 2025-06-18

Full protocol support with enhanced features and comprehensive security hardening.

Zero vulnerabilities
Performance benchmarks
ElicitationHandler support
Interactive clients
Conversation context
HTTP timeout config

Modular Architecture

Clean, layered architecture with 8 specialized crates for maximum flexibility and maintainability.

turbomcp

Main SDK with ergonomic APIs

Procedural macros
Prelude module
Integration layer
turbomcp-core

Foundation with SIMD acceleration

SIMD message handling
Request context
Session management
turbomcp-protocol

MCP specification implementation

JSON-RPC protocol
Schema validation
MCP 2025-06-18 spec
turbomcp-transport

Multi-protocol transport layer

5 transport protocols
Circuit breakers
Security features
turbomcp-server

Server framework and middleware

Handler registry
OAuth 2.0
Health monitoring
turbomcp-client

MCP client implementation

Connection management
Error recovery
Async operations
turbomcp-macros

Procedural macro definitions

Zero-overhead generation
Type-safe APIs
Schema generation
turbomcp-cli

Command-line development tools

Server testing
Schema export
Multi-transport support

Revolutionary Type-Safe APIs

Build enterprise-grade MCP servers with DPoP security, type-state builders, and zero-cost abstractions.

main.rs
Elegant high-level API with macros
use turbomcp::prelude::*;

#[derive(Clone)]
struct Calculator;

#[server(
    name = "calculator-server",
    version = "1.0.0",
    description = "A simple calculator"
)]
impl Calculator {
    #[tool("Add two numbers")]
    async fn add(&self, a: i32, b: i32) -> McpResult<i32> {
        Ok(a + b)
    }

    #[tool("Subtract two numbers")]
    async fn subtract(&self, a: i32, b: i32) -> McpResult<i32> {
        Ok(a - b)
    }

    #[tool("Get server status")]
    async fn status(&self, ctx: Context) -> McpResult<String> {
        ctx.info("Status requested").await?;
        Ok("Server running".to_string())
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    Calculator.run_stdio().await?;
    Ok(())
}

Get started with TurboMCP in your Cargo.toml

[dependencies]
turbomcp = "1.1"

Powerful Macro System

Revolutionary type-state builders and zero-overhead macros with compile-time safety guarantees.

Attribute Macros #[...]

Procedural attribute macros for server definitions and method handlers.

#[server]

Server Definition

Define MCP servers with automatic trait implementations

#[server] impl MyServer { // methods }
#[tool]

Tool Handlers

Create tool endpoints with parameter validation

#[tool("Add numbers")] async fn add(&self, a: i32, b: i32) -> McpResult<i32>
#[resource]

Resource Providers

Handle resource requests with URI templating

#[resource("calc://history")] async fn history(&self, _uri: String) -> McpResult<String>
#[prompt]

Prompt Generators

Generate dynamic prompts for AI interactions

#[prompt("Generate a math problem")] async fn math_problem(&self) -> McpResult<String>
v1.1.0
#[dpop_secured]

DPoP Security (NEW)

RFC 9449 token binding with cryptographic proof

#[dpop_secured] #[tool("Secure operation")] async fn secure_op(&self) -> McpResult<String>
v1.1.0
CapabilityBuilder

Type-State Builder (NEW)

Compile-time safe capability configuration

let caps = CapabilityBuilder::new() .with_simd_hints() .enterprise_security() .build_const()
#[elicitation]

User Input

Request structured input from clients

#[elicitation("Get user prefs")] async fn get_prefs(&self, schema: Value) -> McpResult<Value>
#[completion]

Autocomplete

Provide intelligent completion suggestions

#[completion("Complete paths")] async fn complete(&self, partial: String) -> McpResult<Vec<String>>

Macro Invocations name!()

Helper macros for creating formatted content, errors, and responses.

v1.1.0
dpop_token!

DPoP Tokens (NEW)

Generate RFC 9449 cryptographically bound tokens

let token = dpop_token!( ctx, "https://api.example.com/resource", "GET" ).await?;
mcp_text!

Text Content Blocks

Create ContentBlock structures (often used with tool_result!)

// Standalone content creation let content = mcp_text!("Status: {}", status); // See tool_result! card for usage →
tool_result!

Tool Results (Advanced)

Create CallToolResult manually (usually auto-handled by #[tool])

// Single content block tool_result!(mcp_text!("Success")) // Multiple content blocks tool_result!(content = [text1, text2])
mcp_error!

Error Creation

Create MCP errors (use with Err(mcp_error!(...)))

return Err(mcp_error!("Failed: {}", reason));

Ready-to-Use Examples

Get started quickly with our comprehensive examples covering everything from basic servers to advanced use cases.

crates/turbomcp/examples/06_stateful_server.rs
Simple MCP server with STDIO transport
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:

cargo run --example 06_stateful_server

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.

Learn by Example

Explore 40+ comprehensive examples covering everything from basic usage to advanced enterprise features.

View All Examples on GitHub