feat(macros): auto-generate get_info and default router (#785)

* feat(macros): auto-generate get_info and default router

* docs: simplify examples and docs with new defaults

* feat(macros): add tool_router(server_handler) to elide separate #[tool_handler] impl

* docs: add Tools section to README and simplify calculator examples with server_handler
This commit is contained in:
Dale Seo 2026-04-08 15:06:26 -04:00 • committed by GitHub
commit be321a4abe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,8 +6,8 @@ use std::{
use futures::Stream;
use rmcp::{
ErrorData as McpError, RoleServer, ServerHandler, handler::server::tool::ToolRouter, model::*,
service::RequestContext, tool, tool_handler, tool_router,
ErrorData as McpError, RoleServer, ServerHandler, model::*, service::RequestContext, tool,
tool_handler, tool_router,
};
use serde_json::json;
use tokio_stream::StreamExt;
@ -54,7 +54,6 @@ impl Stream for StreamDataSource {
#[derive(Clone)]
pub struct ProgressDemo {
data_source: StreamDataSource,
tool_router: ToolRouter<Self>,
}
#[tool_router]
@ -62,7 +61,6 @@ impl ProgressDemo {
#[allow(dead_code)]
pub fn new() -> Self {
Self {
tool_router: Self::tool_router(),
data_source: StreamDataSource::from_text("Hello, world!"),
}
}