rust-sdk/crates/rmcp-macros
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Teddy Tennant 3075dc9152
fix(model): deprecate ServerInfo and ClientInfo aliases (#1156)
* fix(model): deprecate ServerInfo and ClientInfo aliases

Those names collide with the protocol's serverInfo/clientInfo fields,
which are only Implementation identity. Prefer InitializeResult and
InitializeRequestParams. Handler trait signatures, the tool_handler
macro output, tests, examples and docs now use the canonical types; the
aliases remain as deprecated shims for the rest of 3.x.

Fixes #1082

* fix(model): keep public signatures on the deprecated aliases

The public API check compares rendered signatures, and rustdoc records a
type alias by the name it was written with. Respelling
`ServerHandler::get_info`, `ClientHandler::get_info`,
`DiscoverResult::from_server_info` and `impl ClientHandler for ClientInfo`
onto `InitializeResult`/`InitializeRequestParams` therefore reads as
changed public items even though the aliases resolve to those exact types
and nothing downstream breaks.

Put those four signatures back on the aliases so the published API is
byte-identical, and note why at the alias definitions. The deprecation
still steers new code, and the macro output, tests, examples and docs
keep using the canonical names.

* fix(model): migrate leftover ClientInfo test sites

Two tests landed on main after the alias deprecation and still named
ClientInfo. Clippy -D warnings and the no-local feature test job both
failed on them.
2026-09-12 12:11:30 -04:00
..
src fix(model): deprecate ServerInfo and ClientInfo aliases (#1156) 2026-09-12 12:11:30 -04:00
Cargo.toml chore: upgrade darling and syn (#1138) 2026-08-05 10:20:22 -04:00
CHANGELOG.md chore: release v3.3.0 (#1252) 2026-09-10 11:23:32 -04:00
README.md feat: Implement SEP-2663 Tasks Extension (#1020) 2026-07-22 14:16:52 -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

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.