Get the FREE Ultimate OpenClaw Setup Guide →

rust-sdk

The official Rust SDK for the Model Context Protocol

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio modelcontextprotocol-rust-sdk cargo run \
  --env RUST_LOG="info"

How to use

The Rust RMCP SDK provides a native Rust implementation of the Model Context Protocol (RMCP) with asynchronous Tokio runtime. It exposes a core protocol crate and a macros crate to help you generate RMCP tool implementations. This server-side SDK is intended for building RMCP servers in Rust and interfacing with RMCP clients. To try it locally, you typically build and run the server binary from the repository or your project that uses the rmcp crate, and then connect clients that are built with the same RMCP protocol. The README demonstrates how a client can be started via a transport (e.g., standard I/O) and how to construct a service (ServerHandler) or ClientHandler to interact with the server. You can also leverage the generated prompts and resources capabilities to expose data and dynamic endpoints to clients. In practice, you would implement ServerHandler for your domain logic, start the RMCP service, and then send requests or notifications to manage resources, roots, and other MCP features supported by the SDK.

How to install

Prerequisites:

  • Rust toolchain (installed via rustup) with stable toolchain available
  • Git to clone the repository or access to the crate via crates.io

Steps:

  1. Install Rust:
  2. Clone the repository or create a Rust project and add the rmcp dependency:
  3. Build and run the server:
    • cargo build --release
    • cargo run
  4. If integrating into your own project, add rmcp as a dependency and implement your ServerHandler accordingly, then run your binary with Tokio runtime.

Notes:

  • The README examples show using the rmcp crate to create a client and server interactions, so you’ll typically either run the server from a binary or embed the library in your application and drive it from your main function.

Additional notes

Tips and considerations:

  • If you enable logging, set RUST_LOG to capture info/debug output (e.g., RUST_LOG=info).
  • Ensure that your ServerHandler implements the required MCP capabilities (e.g., resources, prompts) via get_info.
  • The SDK uses Tokio for async runtime; ensure your environment supports asynchronous execution models.
  • When testing, you can spin up a client transport (e.g., using stdio or a TCP transport) to interact with your server.
  • If migrating from older versions, refer to the migration guide linked in the README for breaking changes and upgrade steps.

Related MCP Servers

Sponsor this space

Reach thousands of developers