pub trait ToolHandler: Send + Sync {
// Required methods
fn list_tools(
&self,
ctx: &Context<'_>,
) -> impl Future<Output = Result<Vec<Tool>, McpError>> + Send;
fn call_tool(
&self,
name: &str,
args: Value,
ctx: &Context<'_>,
) -> impl Future<Output = Result<ToolOutput, McpError>> + Send;
// Provided method
fn on_tools_changed(&self) -> impl Future<Output = ()> + Send { ... }
}Expand description
Handler for tool-related operations.
Implement this trait to expose tools that AI assistants can call.
Required Methods§
Provided Methods§
Sourcefn on_tools_changed(&self) -> impl Future<Output = ()> + Send
fn on_tools_changed(&self) -> impl Future<Output = ()> + Send
Called when a tool’s definition has changed.
Override this to dynamically add/remove/update tools.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.