macro_rules! dispatch_handler {
(
$(
$(#[$meta:meta])*
$variant:ident => $handler:ident
),* $(,)?
) => {
#[derive(Clone)]
pub enum ToolHandler {
$(
$(#[$meta])*
$variant($handler),
)*
}
pub fn all_tool_handlers() -> Vec<ToolHandler> {
vec![
$(
ToolHandler::$variant($handler),
)*
]
}
impl ToolHandler {
pub fn name(&self) -> &str {
match self {
$(
ToolHandler::$variant(h) => h.name(),
)*
}
}
pub fn description(&self) -> &str {
match self {
$(
ToolHandler::$variant(h) => h.description(),
)*
}
}
pub fn argument_schema(&self) -> serde_json::Value {
match self {
$(
ToolHandler::$variant(h) => h.argument_schema(),
)*
}
}
pub async fn execute(
&self,
registry: &std::sync::Arc<crate::cli::registry::ProjectRegistry>,
args: serde_json::Value,
) -> Result<serde_json::Value, $crate::cli::mcp::protocol::JsonRpcError> {
match self {
$(
ToolHandler::$variant(h) => h.execute(registry, args).await,
)*
}
}
}
};
}