Get the FREE Ultimate OpenClaw Setup Guide →

rust -schema

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

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add rust-mcp-stack-rust-mcp-schema

How to use

This Rust crate provides a type-safe implementation of the MCP (Model Context Protocol) schema. It includes generated schema modules for multiple MCP versions (including draft) and a utility module (schema_utils) to help with common tasks like serializing and deserializing MCP messages. You can use this crate as the core schema layer when building an MCP Server or MCP Client in Rust; the actual server/client logic, network handling, and application-specific behavior should be implemented in your project while relying on rust-mcp-schema for the MCP message types and serialization support. If you need higher-level functionality, pair this crate with rust-mcp-sdk, which offers a high-performance toolkit for building MCP servers and clients on top of the schema.

How to install

Prerequisites:

  • Rust toolchain (rustc, cargo) installed. Preferably via rustup.
  • Basic knowledge of Cargo and adding dependencies to a Rust project.

Step 1: Create a new Rust project (if you don’t have one yet)

  • cargo new my_mcp_project --bin
  • cd my_mcp_project

Step 2: Add rust-mcp-schema as a dependency

  • Open Cargo.toml and add: [dependencies] rust-mcp-schema = "0.9" # or the latest version from crates.io

Step 3: Build your project to fetch the dependency

  • cargo build

Step 4: (Optional) Enable a specific feature set if you know you need a particular schema version.

  • In Cargo.toml, under [dependencies], you can specify features, for example: rust-mcp-schema = { version = "0.9", default-features = false, features = ["2025_11_25"] }

Step 5: Start implementing your MCP Server/Client logic using the types from rust-mcp-schema (and optionally rust-mcp-sdk for server/client scaffolding).

Additional notes

Notes and tips:

  • This crate focuses on providing the MCP schema (types, serialization/deserialization) rather than full server logic. For building servers/clients, consider using rust-mcp-sdk on top of rust-mcp-schema for high-performance, asynchronous capabilities.
  • Schema versions are available as Cargo features (e.g., 2025_11_25, 2025_06_18, draft). Enable the features you need in Cargo.toml.
  • Serialization is supported via serde_json; ensure serde and serde_json are in scope where needed.
  • If you are new to MCP, review the official MCP specification to understand message types like InitializeRequest, InitializeResult, and other protocol messages.
  • The repository contains generated_schema modules under src/generated_schema with multiple versions; you can target a non-default version by enabling its Cargo feature.
  • If you want to generate or adapt schemas manually, you can reference the schema_utils module for helper types and functions, but note that using schema_utils is optional.

Related MCP Servers

Sponsor this space

Reach thousands of developers