macro_rules! tool {
($name:expr, $description:expr, $args_type:ty, $handler:expr) => { ... };
}Expand description
Macro to create a tool with automatic schema generation
§Example
ⓘ
use qwencode_rs::tool;
use serde::Deserialize;
#[derive(Deserialize, JsonSchema)]
struct AddArgs {
a: i32,
b: i32,
}
let tool = tool!(
"add",
"Add two numbers",
AddArgs,
|args: AddArgs| async move {
Ok(McpToolResult {
content: vec![ToolContent::Text {
text: format!("{}", args.a + args.b),
}],
is_error: false,
})
}
);