macro_rules! tool {
(
name: $name:literal,
description: $desc:literal,
schema: $schema:expr,
call: |$input:ident : $input_ty:ty| async move $body:block,
tool_type: $ty:ident $(,)?
) => { ... };
}Expand description
Declarative tool-trait impl.
§Example
ⓘ
use forge_sdk::tool;
use forge_sdk::mcp::{ToolInput, ToolOutput};
use serde_json::json;
tool! {
name: "greet",
description: "Greet by name",
schema: json!({"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]}),
call: |input: ToolInput| async move {
let name = input.value["name"].as_str().unwrap_or("stranger");
ToolOutput::text(format!("hello {name}"))
},
tool_type: GreetTool,
}