Production-grade Rust implementation of the Model Context Protocol (MCP) - 16x faster than TypeScript, built with Toyota Way quality principles
PMCP is a complete MCP ecosystem for Rust, providing everything you need to build, test, and deploy production-grade MCP servers:
- π¦ pmcp SDK - High-performance Rust crate with full MCP protocol support
- β‘ cargo-pmcp - CLI toolkit for scaffolding, testing, and development
- π pmcp-book - Comprehensive guide with 27 chapters
- π€ AI Agents - Kiro and Claude Code configurations for AI-assisted development
Why PMCP?
- Performance: 16x faster than TypeScript SDK, 50x lower memory
- Safety: Rust's type system + zero
unwrap()in production code - Quality: Toyota Way principles - zero technical debt tolerance
- Complete: SDK, tooling, documentation, and AI assistance in one ecosystem
Choose your path based on experience and preference:
Build production-ready MCP servers with AI assistance in minutes:
Prerequisites:
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup update
# Install cargo-pmcp
cargo install cargo-pmcpInstall Claude Code AI Agent:
# Install the mcp-developer subagent (user-level - works across all projects)
curl -fsSL https://raw.githubusercontent.com/paiml/rust-mcp-sdk/main/ai-agents/claude-code/mcp-developer.md \
-o ~/.claude/agents/mcp-developer.md
# Restart Claude CodeBuild your server:
You: "Create a weather forecast MCP server with tools for getting current conditions and 5-day forecasts"
Claude Code: [Invokes mcp-developer subagent]
I'll create a production-ready weather MCP server using cargo-pmcp.
$ cargo pmcp new weather-mcp-workspace
$ cd weather-mcp-workspace
$ cargo pmcp add server weather --template minimal
[Implements type-safe tools with validation]
[Adds comprehensive tests and observability]
[Validates quality gates]
β
Production-ready server complete with 85% test coverage!
What you get: Production-ready code following Toyota Way principles, with comprehensive tests, structured logging, metrics collection, and zero clippy warnings.
Learn more: AI-Assisted Development Guide | AI Agents README
Scaffold and build servers using the cargo-pmcp CLI:
Installation:
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup update
# Install cargo-pmcp
cargo install cargo-pmcpCreate a server:
# Create workspace
cargo pmcp new my-mcp-workspace
cd my-mcp-workspace
# Add a server using a template
cargo pmcp add server myserver --template minimal
# Start development server with hot-reload
cargo pmcp dev --server myserver
# Generate and run tests
cargo pmcp test --server myserver --generate-scenarios
cargo pmcp test --server myserver
# Build for production
cargo build --releaseAvailable templates:
minimal- Empty structure for custom serverscalculator- Arithmetic operations (learning)complete_calculator- Full-featured reference implementationsqlite_explorer- Database browser pattern
Learn more: cargo-pmcp Guide
Use the pmcp crate directly for maximum control:
Installation:
[dependencies]
pmcp = "1.8"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
schemars = "0.8" # For type-safe toolsType-safe server example:
use pmcp::{ServerBuilder, TypedTool, RequestHandlerExtra, Error};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[schemars(deny_unknown_fields)]
struct WeatherArgs {
#[schemars(description = "City name")]
city: String,
#[schemars(description = "Number of days (1-5)")]
days: Option<u8>,
}
#[derive(Debug, Serialize, JsonSchema)]
struct WeatherOutput {
temperature: f64,
conditions: String,
}
async fn get_weather(args: WeatherArgs, _extra: RequestHandlerExtra) -> pmcp::Result<WeatherOutput> {
// Validate
if args.city.is_empty() {
return Err(Error::validation("City cannot be empty"));
}
let days = args.days.unwrap_or(1);
if !(1..=5).contains(&days) {
return Err(Error::validation("Days must be 1-5"));
}
// Call weather API...
Ok(WeatherOutput {
temperature: 72.0,
conditions: "Sunny".to_string(),
})
}
#[tokio::main]
async fn main() -> pmcp::Result<()> {
let server = ServerBuilder::new()
.name("weather-server")
.version("1.0.0")
.tool("get-weather", TypedTool::new("get-weather", |args, extra| {
Box::pin(get_weather(args, extra))
}).with_description("Get weather forecast for a city"))
.build()?;
server.run_stdio().await?;
Ok(())
}Learn more: pmcp-book | API Documentation
High-performance Rust implementation of the MCP protocol.
Key Features:
- Type-Safe Tools: Automatic JSON schema generation from Rust types
- Multiple Transports: stdio, HTTP/SSE, WebSocket, WASM
- OAuth Support: Full auth context pass-through (v1.8.0+)
- Workflows: Multi-step orchestration with array indexing support
- Performance: 16x faster than TypeScript, SIMD-accelerated parsing
- Quality: Zero
unwrap(), comprehensive error handling
Latest Version: pmcp = "1.8.3"
Documentation:
Scaffolding and development toolkit for MCP servers.
What it does:
- Scaffold servers in seconds with proven patterns
- Hot-reload dev server for rapid iteration
- Generate test scenarios automatically
- Validate quality gates (fmt, clippy, tests)
- Deploy to production - AWS Lambda or Cloudflare Workers
- Manage deployments - logs, metrics, secrets, rollback
Commands:
cargo pmcp new <workspace> # Create workspace
cargo pmcp add server <name> # Add server
cargo pmcp dev --server <name> # Start dev server
cargo pmcp test --server <name> # Run tests
cargo pmcp deploy --target <target> # Deploy to production
cargo pmcp deploy logs --tail # Stream logs
cargo pmcp deploy destroy --clean # Remove deploymentWhy use it?
- Encodes best practices from 6 production servers
- Saves 30-60 minutes vs manual setup
- Ensures consistent structure across servers
- Integrated testing and quality validation
Learn more: cargo-pmcp Guide
27-chapter comprehensive guide to building MCP servers with pmcp.
π Read Online
Coverage:
- Getting Started: Installation, first server, quick start tutorial
- Core Concepts: Tools, resources, prompts, error handling
- Advanced Features: Auth, transports, middleware, progress tracking
- Real-World: Production servers, testing, deployment, performance
- Examples & Patterns: Complete examples and design patterns
- TypeScript Migration: Complete compatibility guide
- Advanced Topics: Custom transports, AI-assisted development
Local development:
make book-serve # Serve at http://localhost:3000
make book-open # Build and open in browserAI agent configurations that teach Kiro and Claude Code how to build MCP servers.
Supported AI Assistants:
Kiro (Steering Files) - 10,876 lines of persistent MCP expertise
- Always-active knowledge in every conversation
- Comprehensive testing and observability guidance
- Installation Guide
Claude Code (Subagent) - ~750 lines of focused MCP knowledge
- On-demand invocation for MCP tasks
- Quick scaffolding and implementation
- Installation Guide
What AI agents know:
- MCP protocol concepts and patterns
- cargo-pmcp workflow (never creates files manually)
- Type-safe tool implementation
- Testing strategies (unit, integration, property, fuzz)
- Production observability (logging, metrics)
- Toyota Way quality standards
Community implementations welcome:
- GitHub Copilot, Cursor, Cline, and others
- Contribution Guide
Learn more: AI-Assisted Development | ai-agents/
Highlights:
- π OAuth Auth Context: Full token pass-through from transport β middleware β tools
- π Workflow Array Indexing: Access array elements in workflow templates
- π‘οΈ Spec Compliance: Fixed ClientCapabilities schema for Cursor IDE compatibility
- π§ Type-Safe Tools: Production-ready typed tools with schema generation
- β‘ Performance: SIMD-accelerated parsing (10.3x speedup)
Full changelog: CHANGELOG.md
Migration guides:
- stdio: Standard input/output for CLI integration
- HTTP/SSE: Streamable HTTP with Server-Sent Events
- WebSocket: Full-duplex with auto-reconnection
- WASM: Browser and Cloudflare Workers support
- Automatic Schema Generation: From Rust types using
schemars - Compile-Time Validation: Type-checked tool arguments
- Runtime Validation: Against generated JSON schemas
- Zero Unwraps: Explicit error handling throughout
- OAuth 2.0: Full auth context pass-through
- OIDC Discovery: Automatic provider configuration
- Bearer Tokens: Standard authentication
- Path Validation: Secure file system access
- mcp-tester: Comprehensive server testing tool
- Scenario Generation: Auto-generate test cases
- Property Testing: Invariant validation
- Quality Gates: fmt, clippy, coverage enforcement
- 16x faster than TypeScript SDK
- 50x lower memory usage
- SIMD Parsing: 10.3x SSE speedup with AVX2/SSE4.2
- Connection Pooling: Smart load balancing
- Zero Technical Debt: TDG score 0.76
- Jidoka: Stop the line on defects
- Genchi Genbutsu: Go and see (evidence-based)
- Kaizen: Continuous improvement
- No Unwraps: Explicit error handling only
- pmcp-book - Comprehensive guide (27 chapters)
- API Reference - Complete API documentation
- cargo-pmcp Guide - CLI toolkit documentation
- AI-Assisted Development - Building with AI
- Examples - 200+ working examples
- CHANGELOG - Version history
- Migration Guides - Upgrade instructions
- Contributing - How to contribute
The SDK includes 60+ comprehensive examples covering all features:
# Basic examples
cargo run --example 01_client_initialize # Client setup
cargo run --example 02_server_basic # Basic server
cargo run --example 03_client_tools # Tool usage
# Type-safe tools (v1.6.0+)
cargo run --example 32_typed_tools --features schema-generation
cargo run --example 33_advanced_typed_tools --features schema-generation
# Advanced features
cargo run --example 09_authentication # OAuth/Bearer
cargo run --example 13_websocket_transport # WebSocket
cargo run --example 15_middleware # Middleware chain
# Testing
cargo run --example 26-server-tester -- test http://localhost:8080
# AI-assisted development
# See ai-agents/README.md for Kiro and Claude Code setupSee examples/README.md for complete list.
Comprehensive testing tool for validating MCP server implementations.
Features:
- Protocol compliance validation (JSON-RPC 2.0, MCP spec)
- Multi-transport support (HTTP, HTTPS, WebSocket, stdio)
- Tool discovery and testing
- CI/CD ready with JSON output
Installation:
cargo install mcp-server-tester
# Or download pre-built binaries from releasesUsage:
# Test a server
mcp-tester test http://localhost:8080
# Protocol compliance check
mcp-tester compliance http://localhost:8080 --strict
# Connection diagnostics
mcp-tester diagnose http://localhost:8080Learn more: examples/26-server-tester/README.md
PMCP is built following Toyota Production System principles:
-
Jidoka (θͺεε): Automation with human touch
- Quality gates stop builds on defects
- Zero tolerance for
unwrap()in production - Comprehensive error handling with context
-
Genchi Genbutsu (ηΎε°ηΎη©): Go and see
- Evidence-based decisions with metrics
- PMAT quality analysis (TDG score 0.76)
- Comprehensive testing (unit, property, fuzz)
-
Kaizen (ζΉε): Continuous improvement
- Regular benchmarking and optimization
- Performance regression prevention
- Community-driven enhancements
- TDG Score: 0.76 (production-ready)
- Technical Debt: Minimal (436h across entire codebase)
- Complexity: All functions β€25 complexity
- Coverage: 52% line coverage, 100% function coverage
- Linting: Zero clippy warnings in production code
Metric PMCP (Rust) TypeScript SDK Improvement
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Overall Speed 16x 1x 16x faster
Memory Usage <10 MB ~500 MB 50x lower
SSE Parsing 336,921 ev/s 32,691 ev/s 10.3x faster
JSON-RPC Parsing 195,181 docs/s N/A SIMD-optimized
Round-trip Latency <100 ΞΌs ~1-2 ms 10-20x faster
Base64 Operations 252+ MB/s N/A Optimized
Run benchmarks:
make bench # General benchmarks
cargo run --example 32_simd_parsing # SIMD-specificFull WASM support for browser and edge deployment:
Targets:
- Cloudflare Workers (wasm32-unknown-unknown)
- WASI Runtimes (wasm32-wasi)
- Browser (wasm-bindgen)
Quick start:
# Build for Cloudflare Workers
cargo build --target wasm32-unknown-unknown --no-default-features --features wasm
# Deploy
make cloudflare-sdk-deployLearn more: WASM Guide | WASM Example
- Rust 1.82.0 or later
- Git
git clone https://github.com/paiml/rust-mcp-sdk
cd rust-mcp-sdk
# Install development tools
make setup
# Run quality checks
make quality-gatemake test-all # All tests
make test-property # Property tests
make coverage # Coverage report
make mutants # Mutation testsWe welcome contributions! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Ensure quality gates pass (
make quality-gate) - Commit with conventional commits
- Push and open a Pull Request
See: CONTRIBUTING.md
| Feature | TypeScript SDK | PMCP (Rust) |
|---|---|---|
| Protocol Version | 2024-10-07+ | 2024-10-07+ |
| Transports | stdio, SSE, WebSocket | stdio, SSE, WebSocket, WASM |
| Authentication | OAuth 2.0, Bearer | OAuth 2.0, Bearer, OIDC |
| Tools | β | β (Type-safe) |
| Prompts | β | β (Workflows) |
| Resources | β | β (Subscriptions) |
| Sampling | β | β |
| Performance | 1x | 16x faster |
| Memory | Baseline | 50x lower |
This project is licensed under the MIT License - see the LICENSE file for details.
- Model Context Protocol specification
- TypeScript SDK for reference implementation
- PAIML MCP Agent Toolkit for quality standards
- Community contributors and early adopters
- Documentation: https://paiml.github.io/rust-mcp-sdk/
- Crates.io: https://crates.io/crates/pmcp
- API Docs: https://docs.rs/pmcp
- Issues: https://github.com/paiml/rust-mcp-sdk/issues
- Discussions: https://github.com/paiml/rust-mcp-sdk/discussions
Built with π¦ Rust and β€οΈ following Toyota Way principles