Model Context Protocol (MCP) Schema for Rust
About
A type-safe implementation of the official Model Context Protocol (MCP) schema in Rust.
Details
- License
- MIT
Explore
- 🧩 Type-safe implementation of the MCP protocol specification.
- 💎 Auto-generated schemas are always synchronized with the official schema specifications.
- 📜 Includes all official released versions : 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 and draft version for early adoption.
- 🛠 Complimentary schema utility module (schema_utils) to boost productivity and ensure development integrity.
:point_right: The following examples focus solely on the serialization and deserialization of schema messages, assuming the JSON-RPC message has already been received in the application as a string.
If you prefer not to use schema_utils, you can directly work with the generated types in your application or build custom utilities around them.
A type-safe Rust implementation of the official Model Context Protocol (MCP) schema, supporting all official MCP Protocol versions:
- 2025-11-25
- 2025-06-18
- 2025-03-26
- 2024-11-05
- draft
The MCP schemas in this repository are automatically generated from the official Model Context Protocol, ensuring they are always up-to-date and aligned with the latest official specifications.
---
Note: This crate only provides an implementation of the MCP schema.
If you are looking for a high-performance, asynchronous toolkit for building MCP servers and clients, checkout rust-mcp-sdk.
Focus on your app's logic while rust-mcp-sdk takes care of the rest!
---
Contents:
- Features
- How can this crate be used?
- Schema Versions
- How to switch between different schema versions?
- How are Schemas generated?
- What is schema_utils?
- What does the schema_utils do?
- Usage Examples
- Detecting an InitializeRequest Message on an MCP Server
- Creating an InitializeResult Response on an MCP Server
- Detecting an InitializeResult Response Message in an MCP Client
- Usage Examples (Without Utilizing schema_utils)
- Detecting an InitializeRequest Message on an MCP Server (without schema_utils)
Features
- 🧩 Type-safe implementation of the MCP protocol specification.
- 💎 Auto-generated schemas are always synchronized with the official schema specifications.
- 📜 Includes all official released versions : 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 and draft version for early adoption.
- 🛠 Complimentary schema utility module (schema_utils) to boost productivity and ensure development integrity.
How can this crate be used?
This Crate provides Rust implementation of the official Model Context Protocol (MCP) schema.
Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you’re building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.
This crate includes the schema with serialization / deserialization support via serde_json, along with a minimal implementation of the necessary traits for structs and enums. This helps in creating and using various MCP messages such as requests, responses, notifications, and errors.
This crate could be used for developing an MCP Server or MCP Client in Rust.
For more information on the MCP architecture, refer to the official documentation.
---
Check out rust-mcp-sdk , a high-performance, asynchronous toolkit for building MCP servers and clients which is based on rust-mcp-schema. Focus on your app's logic while rust-mcp-sdk takes care of the rest!
---
Schema Versions
This repository provides all official released versions the schema , including draft version, enabling you to prepare and adapt your applications ahead of upcoming official schema releases.
- 2025-11-25
- 2025-06-18
- 2025-03-26
- 2024-11-05
- draft
How to switch between different schema versions?
By default, the latest version of the MCP Protocol schema is enabled.
Each schema version has a corresponding Cargo feature that can be enabled in your project's Cargo.toml.
Multiple schema versions may be enabled concurrently if needed. Non-default versions are available under explicitly named modules, for example:
- rust_mcp_schema::mcp_2025_06_18
- rust_mcp_schema::mcp_draft"
Example: enable 2025-06-18 version of the schema:
<!-- x-release-please-start-version -->
```toml
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



