Skip to main content

ToolHandler

Trait ToolHandler 

Source
pub trait ToolHandler: Send + Sync {
    // Required methods
    fn call(&self, args: Value) -> BoxFuture<'_, Result<CallToolResult>>;
    fn input_schema(&self) -> Value;

    // Provided methods
    fn call_with_context(
        &self,
        _ctx: RequestContext,
        args: Value,
    ) -> BoxFuture<'_, Result<CallToolResult>> { ... }
    fn uses_context(&self) -> bool { ... }
}
Expand description

Tool handler trait - the core abstraction for tool execution

Required Methods§

Source

fn call(&self, args: Value) -> BoxFuture<'_, Result<CallToolResult>>

Execute the tool with the given arguments

Source

fn input_schema(&self) -> Value

Get the tool’s input schema

Provided Methods§

Source

fn call_with_context( &self, _ctx: RequestContext, args: Value, ) -> BoxFuture<'_, Result<CallToolResult>>

Execute the tool with request context for progress/cancellation support

The default implementation ignores the context and calls call. Override this to receive progress/cancellation context.

Source

fn uses_context(&self) -> bool

Returns true if this handler uses context (for optimization)

Implementors§