No description
Find a file
dependabot[bot] c8ea0f6051
chore(deps): update base64 requirement from 0.21 to 0.22 (#209)
Updates the requirements on [base64](https://github.com/marshallpierce/rust-base64) to permit the latest version.
- [Changelog](https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md)
- [Commits](https://github.com/marshallpierce/rust-base64/compare/v0.21.0...v0.22.1)

---
updated-dependencies:
- dependency-name: base64
  dependency-version: 0.22.1
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-21 11:17:56 +08:00
.devcontainer Adopt Devcontainer for Development Environment (#81) 2025-04-02 12:16:49 +08:00
.github chore(deps): bump actions/checkout from 3 to 4 (#207) 2025-05-21 11:16:06 +08:00
crates chore(deps): update base64 requirement from 0.21 to 0.22 (#209) 2025-05-21 11:17:56 +08:00
docs ci: revert badge (#202) 2025-05-21 09:19:25 +08:00
examples chore(deps): update thiserror requirement from 1.0 to 2.0 (#208) 2025-05-21 11:17:16 +08:00
.gitignore Initial commit 2025-02-18 10:55:26 +00:00
Cargo.toml fix(test): fix tool deserialization error (#68) 2025-03-31 13:05:35 +08:00
clippy.toml feat: add clippy config (#162) 2025-05-08 10:15:17 +08:00
LICENSE Initial commit 2025-02-18 10:55:26 +00:00
README.md ci: revert badge (#202) 2025-05-21 09:19:25 +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

Wait for the first release.

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.1", 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.

Development with Dev Container

See docs/DEVCONTAINER.md for instructions on using Dev Container for development.