Fast MCP SDK

TurboMCP

Rust SDK for the Model Context Protocol with SIMD acceleration, robust transport layer, and ergonomic APIs. Build MCP servers with comprehensive reliability features.

2-3x
Faster JSON
5
Transport Options
Zero
Overhead Macros
Robust
Design
MIT
License

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.

SIMD JSON parsing
Zero-copy processing
Streaming support
Memory optimization

Multi-Transport Support

Five transport protocols with runtime selection and feature-gated compilation.

STDIO (default)
HTTP/SSE for web apps
WebSocket bidirectional
TCP for network deployment
Unix sockets for servers
Runtime configuration

OAuth 2.0 Authentication

World-class authentication with Google, GitHub, Microsoft providers and always-on PKCE security.

Google/GitHub/Microsoft
PKCE security
All OAuth flows
Token management
Session handling
Custom providers

Zero-Overhead Macros

Ergonomic procedural macros that generate optimal code without runtime overhead.

#[server] macro
#[tool] attributes
#[resource] handlers
#[prompt] definitions
mcp_text! helper
mcp_error! creation
tool_result! formatting

Type Safety

Compile-time validation and automatic schema generation for robust API contracts.

Compile-time validation
Schema generation
Type-safe APIs
Runtime verification

MCP 2025 Compliance

Full compliance with the latest Model Context Protocol specification for maximum compatibility.

Latest MCP spec
JSON-RPC protocol
Versioning support
Standards compliance

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

Simple, Powerful APIs

Build MCP servers with minimal boilerplate using our ergonomic macros and type-safe APIs.

main.rs
Elegant high-level API with macros
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

[dependencies]
turbomcp = "1.0"

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]

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>

Macro Invocations name!()

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

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.

examples/basic_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_macro_showcase

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.