Skip to main content

ToolHandler

Trait ToolHandler 

Source
pub trait ToolHandler: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn gate_set(&self) -> &'static [GateId];
    fn call(&self, params: Value) -> Result<Value, ToolError>;
}
Expand description

A single MCP tool that can be dispatched by the ToolRegistry.

Implementors must be Send + Sync because the registry may be held across thread boundaries in future async-capable transports.

Required Methods§

Source

fn name(&self) -> &'static str

The JSON-RPC method name this handler responds to.

Must be unique across all handlers registered in the same [ToolRegistry]. The convention is cortex_<verb>.

Source

fn gate_set(&self) -> &'static [GateId]

Gate IDs this tool activates.

Must be non-empty. ToolRegistry::register asserts this at registration time (DA-3).

Source

fn call(&self, params: Value) -> Result<Value, ToolError>

Execute the tool with the given JSON params, returning a JSON result.

The params value is the raw "params" field from the JSON-RPC request. If the request omitted "params", the serve loop passes serde_json::Value::Null.

Implementors§