Implements outputSchema validation (#566)

* feat: implement output schema validation

* fix: calculator example comply MCP spec

* refactor: merge cached_schema_for_output into schema_for_output
This commit is contained in:
Dale Seo 2025-12-08 16:13:19 -05:00 • committed by GitHub
commit df84555065
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,10 +2,7 @@
use rmcp::{
ServerHandler,
handler::server::{
router::tool::ToolRouter,
wrapper::{Json, Parameters},
},
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
model::{ServerCapabilities, ServerInfo},
schemars, tool, tool_handler, tool_router,
};
@ -44,8 +41,8 @@ impl Calculator {
}
#[tool(description = "Calculate the difference of two numbers")]
fn sub(&self, Parameters(SubRequest { a, b }): Parameters<SubRequest>) -> Json<i32> {
Json(a - b)
fn sub(&self, Parameters(SubRequest { a, b }): Parameters<SubRequest>) -> String {
(a - b).to_string()
}
}