No description
Find a file
Julián Montes de Oca 7f20a87825
feat: include reqwest in transport-streamble-http-client feature (#376)
* fix: add reqwest dependency to transport-streamable-http-client feature

- Fix compilation error when using transport-streamable-http-client feature due to missing dependency
- Move From<reqwest::Error> implementation to reqwest module

* feat(rmcp): enhance transport features by decoupling reqwest

- Added reqwest features for reqwest-based implementations.
- Updated documentation
- Modified error handling in SSE transport to use `String` for content type.
- Updated examples to include new features

* feat(rmcp): enhance transport features by decoupling reqwest

- Added reqwest features for reqwest-based implementations
- Updated documentation
- Modified error handling in SSE transport to use `String`
- Updated examples to include new features
2025-08-20 11:43:18 +08:00
.devcontainer Adopt Devcontainer for Development Environment (#81) 2025-04-02 12:16:49 +08:00
.github chore(deps): bump actions/checkout from 4 to 5 (#371) 2025-08-13 08:53:03 +08:00
crates feat: include reqwest in transport-streamble-http-client feature (#376) 2025-08-20 11:43:18 +08:00
docs docs(README): update zh_cn README (#336) 2025-07-29 02:41:38 +08:00
examples feat: include reqwest in transport-streamble-http-client feature (#376) 2025-08-20 11:43:18 +08:00
.gitignore example: add simpling example and test (#289) 2025-06-30 18:18:23 +08:00
Cargo.toml chore: release v0.6.0 (#369) 2025-08-19 09:23:09 -04:00
clippy.toml feat: add clippy config (#162) 2025-05-08 10:15:17 +08:00
justfile chore: cov settings, and fix serveral building warnings (#281) 2025-06-25 14:30:45 +08:00
LICENSE Initial commit 2025-02-18 10:55:26 +00:00
README.md docs: add related project rustfs-mcp (#378) 2025-08-18 14:44:38 +08:00
rust-toolchain.toml Move whole rmcp crate to offcial rust sdk (#44) 2025-03-27 17:33:41 -04:00
rustfmt.toml style: fmt the project (#54) 2025-03-28 23:50:46 +08:00

RMCP

Crates.io Version

Coverage

An official Rust Model Context Protocol SDK implementation with tokio async runtime.

This repository contains the following crates:

  • rmcp: The core crate providing the RMCP protocol implementation (If you want to get more information, please visit rmcp)
  • rmcp-macros: A procedural macro crate for generating RMCP tool implementations (If you want to get more information, please visit rmcp-macros)

Usage

Import the crate

rmcp = { version = "0.2.0", features = ["server"] }
## or dev channel
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "main" }

Third Dependencies

Basic dependencies:

Build a Client

Start a client
use rmcp::{ServiceExt, transport::{TokioChildProcess, ConfigureCommandExt}};
use tokio::process::Command;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ().serve(TokioChildProcess::new(Command::new("npx").configure(|cmd| {
        cmd.arg("-y").arg("@modelcontextprotocol/server-everything");
    }))?).await?;
    Ok(())
}

Build a Server

Build a transport
use tokio::io::{stdin, stdout};
let transport = (stdin(), stdout());
Build a service

You can easily build a service by using ServerHandler or ClientHandler.

let service = common::counter::Counter::new();
Start the server
// this call will finish the initialization process
let server = service.serve(transport).await?;
Interact with the server

Once the server is initialized, you can send requests or notifications:

// request
let roots = server.list_roots().await?;

// or send notification
server.notify_cancelled(...).await?;
Waiting for service shutdown
let quit_reason = server.waiting().await?;
// or cancel it
let quit_reason = server.cancel().await?;

Examples

See examples

OAuth Support

See oauth_support for details.

  • rustfs-mcp - High-performance MCP server providing S3-compatible object storage operations for AI/LLM integration
  • containerd-mcp-server - A containerd-based MCP server implementation

Development

Tips for Contributors

See docs/CONTRIBUTE.MD to get some tips for contributing.

Using Dev Container

If you want to use dev container, see docs/DEVCONTAINER.md for instructions on using Dev Container for development.