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§
Sourcefn call(&self, args: Value) -> BoxFuture<'_, Result<CallToolResult>>
fn call(&self, args: Value) -> BoxFuture<'_, Result<CallToolResult>>
Execute the tool with the given arguments
Sourcefn input_schema(&self) -> Value
fn input_schema(&self) -> Value
Get the tool’s input schema
Provided Methods§
Sourcefn call_with_context(
&self,
_ctx: RequestContext,
args: Value,
) -> BoxFuture<'_, Result<CallToolResult>>
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.
Sourcefn uses_context(&self) -> bool
fn uses_context(&self) -> bool
Returns true if this handler uses context (for optimization)