I think some parts are a bit redundant, such as having to mark each variable with #[tool(param)] or #[tool(aggr)]. I looked at the source code of rcmp-macros, and I think we can simply judge by the number of variables after excluding variables such as self. When it is greater than 1, pack them together, and use a single one in other cases. The effect is as follows:
use rmcp::{ServerHandler,
handler::server::wrapper::Json,
model::{ServerCapabilities,ServerInfo},
schemars, tool,};use serde::Serialize;#[derive(Debug,Serialize, serde::Deserialize, schemars::JsonSchema)]pubstructSumRequest{#[schemars(description = "the left hand side number")]puba:i32,pubb:i32,}#[derive(Debug,Clone)]pubstructCalculator;#[tool(tool_box)]implCalculator{#[tool(description = "Calculate the sum of two numbers")]fnsum(&self,sum:SumRequest) -> String{(sum.a+sum.b).to_string()}#[tool(description = "Calculate the difference of two numbers")]fnsub(&self,a:i32,b:i32,) -> Json<i32>{Json(a - b)}}
I think some parts are a bit redundant, such as having to mark each variable with #[tool(param)] or #[tool(aggr)]. I looked at the source code of rcmp-macros, and I think we can simply judge by the number of variables after excluding variables such as self. When it is greater than 1, pack them together, and use a single one in other cases. The effect is as follows: