macro_rules! tool_box {
($enum_name:ident, [$($tool:ident),*]) => { ... };
}
Expand description
Generates an enum representing a toolbox with mcp tool variants and associated functionality.
Note: The macro assumes that tool types provided are annotated with the mcp_tool() macro.
This macro creates:
- An enum with the specified name containing variants for each mcp tool
- A
tools()
function returning a vector of supported tools - A
TryFrom<CallToolRequestParams>
implementation for converting requests to tool instances
§Arguments
$enum_name
- The name to give the generated enum[$($tool:ident),*]
- A comma-separated list of tool types to include in the enum
§Example
ⓘ
tool_box!(FileSystemTools, [ReadFileTool, EditFileTool, SearchFilesTool]);
// Creates:
// pub enum FileSystemTools {
// ReadFileTool(ReadFileTool),
// EditFileTool(EditFileTool),
// SearchFilesTool(SearchFilesTool),
// }
// pub fn tools() -> Vec<Tool> {
// vec![ReadFileTool::tool(), EditFileTool::tool(), SearchFilesTool::tool()]
// }
// impl TryFrom<CallToolRequestParams> for FileSystemTools {
// //.......
// }