rust-sdk/crates/rmcp-macros
Dale Seo dd30a70f84
feat!: add MRTR behavior support (SEP-2322) (#929)
* feat!: add MRTR behavior support

* feat: harden SEP-2322 MRTR support

* ci: diff public API only on features common to base and head

cargo public-api builds both revisions with the same feature set, so a
feature introduced (or removed) by a PR broke the build of the other
revision. Restrict the all-features diff to features present in both the
base and head revisions.
2026-07-10 12:02:26 -04:00
..
src feat!: add MRTR behavior support (SEP-2322) (#929) 2026-07-10 12:02:26 -04:00
Cargo.toml feat: add local feature for !Send tool handler support (#740) 2026-03-11 17:22:56 -04:00
CHANGELOG.md chore: release v2.0.0 (#920) 2026-06-29 08:24:11 -04:00
README.md feat(macros): auto-generate get_info and default router (#785) 2026-04-08 15:06:26 -04:00

rmcp-macros

Crates.io Documentation

Procedural macros for the RMCP SDK. Most users should depend on rmcp with the macros feature (enabled by default) rather than using this crate directly.

For getting started and full MCP feature documentation, see the main README.

Available Macros

Macro Description
#[tool] Mark a function as an MCP tool handler
#[tool_router] Generate a tool router from an impl block (optional server_handler flag elides a separate #[tool_handler] block for tools-only servers)
#[tool_handler] Generate call_tool and list_tools handler methods
#[prompt] Mark a function as an MCP prompt handler
#[prompt_router] Generate a prompt router from an impl block
#[prompt_handler] Generate get_prompt and list_prompts handler methods
#[task_handler] Wire up the task lifecycle on top of an OperationProcessor

Quick Example

Tools-only server with a single impl block (server_handler expands #[tool_handler] in a second macro pass):

use rmcp::{tool, tool_router};

#[derive(Clone)]
struct MyServer;

#[tool_router(server_handler)]
impl MyServer {
    #[tool(description = "Say hello")]
    async fn hello(&self) -> String {
        "Hello, world!".into()
    }
}

If you need custom #[tool_handler(...)] arguments (e.g. instructions, name, or stacked #[prompt_handler] on the same impl ServerHandler), use two blocks instead:

use rmcp::{tool, tool_router, tool_handler, ServerHandler};

#[derive(Clone)]
struct MyServer;

#[tool_router]
impl MyServer {
    #[tool(description = "Say hello")]
    async fn hello(&self) -> String {
        "Hello, world!".into()
    }
}

#[tool_handler]
impl ServerHandler for MyServer {}

See the full documentation for detailed usage of each macro.

License

This project is licensed under the terms specified in the repository's LICENSE file.