rust-mcp-stack/rust-mcp-schema

View on GitHub ↗

A type-safe implementation of the official Model Context Protocol (MCP) schema in Rust.

76 ★6 forksRustUpdated 18d ago

What you need to know

Type-safe Rust crate implementing the official Model Context Protocol schema for all official protocol versions, auto-generated from the spec.

Install

Add rust-mcp-schema = { version = "0.10.3" } to Cargo.toml
Enable a specific version feature: rust-mcp-schema = { version = "0.10.3", default-features = false, features = ["2025_06_18"] }

Usage

  • Deserialize incoming MCP messages with ClientMessage::from_str on a server
  • Create InitializeResult responses with ServerJsonrpcResponse::new and serialize with serde_json
  • Detect InitializeRequest/InitializeResult variants via pattern matching
  • Optionally skip schema_utils and work directly with JsonrpcMessage types

Key features

  • Type-safe implementation of the MCP protocol schema with serde_json serialization/deserialization
  • All official protocol versions included: 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 and draft
  • Auto-generated schemas synchronized with the official Model Context Protocol specification
  • schema_utils module splitting JsonrpcMessage into ClientMessage and ServerMessage for stronger typing

Best for

Rust developers building MCP servers or clients with compile-time protocol type safety.

Caveats

  • Provides the schema implementation only; for server/client tooling use the companion rust-mcp-sdk crate
  • The code used to generate schemas is not included in the repository
Platforms: macOS · Linux · Windows
Documentation ↗

Reviewed 2026-08-11

Topics

crates-iomcp-clientmcp-hostmcp-servermodel-context-protocolrustrust-lang
Stars
76★
Forks
6
Language
Rust
License
MIT
Created
2025-02-08
Last push
2026-08-17