No description
Find a file
Michael Bolin 2e3cc4a973
feat: add support for custom server notifications (#580)
https://github.com/modelcontextprotocol/rust-sdk/pull/556 introduced support for
custom client notifications, so this PR makes the complementary change, adding
support for custom server notifications.

MCP clients, particularly ones that offer "experimental" capabilities,
may wish to handle custom server notifications that are not part of the
standard MCP specification. This change introduces a new
`CustomServerNotification` type that allows a client to process
such custom notifications.

- introduces `CustomServerNotification` to carry arbitrary methods/params while
  still preserving meta/extensions; wires it into the `ServerNotification` union
  and `serde` so `params` can be decoded with `params_as`
- allows client handlers to receive custom notifications via a new
  `on_custom_notification` hook
- adds integration coverage that sends a custom server notification end-to-end
  and asserts the client sees the method and payload

Test:

```shell
cargo test -p rmcp --features client test_custom_server_notification_reaches_client
```
2025-12-16 12:48:03 -05:00
.devcontainer Adopt Devcontainer for Development Environment (#81) 2025-04-02 12:16:49 +08:00
.github chore(deps): bump actions/checkout from 5 to 6 (#554) 2025-11-21 09:25:40 +08:00
crates feat: add support for custom server notifications (#580) 2025-12-16 12:48:03 -05:00
docs fix(docs): update CONTRIBUTE.MD (#579) 2025-12-10 09:33:22 +08:00
examples Add SEP-991 (CIMD) support for URL-based client IDs (#570) 2025-12-10 08:55:38 -05:00
.gitignore fix:crates/rmcp/src/handler/client/progress.rs dispacher-> dispatcher (#429) 2025-09-10 17:03:35 -04:00
Cargo.toml chore: release v0.11.0 (#568) 2025-12-08 16:42:02 -05:00
client-metadata.json fix: correct redirect URI in client-metadata.json (#585) 2025-12-15 13:17:39 -05: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 Add NexusCore MCP to project list (#573) 2025-12-09 09:16:18 +08:00
rust-toolchain.toml chore: bump to rust 1.90.0 (#453) 2025-09-24 12:58:54 -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.8.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.

Extending rmcp

Built with rmcp

  • 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
  • rmcp-openapi-server - High-performance MCP server that exposes OpenAPI definition endpoints as MCP tools
  • nvim-mcp - A MCP server to interact with Neovim
  • terminator - AI-powered desktop automation MCP server with cross-platform support and >95% success rate
  • stakpak-agent - Security-hardened terminal agent for DevOps with MCP over mTLS, streaming, secret tokenization, and async task management
  • video-transcriber-mcp-rs - High-performance MCP server for transcribing videos from 1000+ platforms using whisper.cpp
  • NexusCore MCP - Advanced malware analysis & dynamic instrumentation MCP server with Frida integration and stealth unpacking capabilities

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.