pub trait ToolHandler: Sized {
const NAME: &'static str;
const DESCRIPTION: &'static str;
// Required methods
fn input_schema() -> Value;
fn execute(args: Value) -> Result<String, String>;
}
Expand description
Trait for implementing MCP tools.
Tools are functions that can be called by MCP clients to perform specific actions.
Required Associated Constants§
Sourceconst DESCRIPTION: &'static str
const DESCRIPTION: &'static str
A human-readable description of what the tool does.
Required Methods§
Sourcefn input_schema() -> Value
fn input_schema() -> Value
Returns the JSON schema describing the tool’s input parameters.
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.
Implementors§
Source§impl<T: AsyncToolHandler> ToolHandler for T
Automatic bridging from async to sync for tools
This allows async implementations to work with the sync WIT interface
The async runtime is managed by the WASM component host (e.g., Spin)
impl<T: AsyncToolHandler> ToolHandler for T
Automatic bridging from async to sync for tools This allows async implementations to work with the sync WIT interface The async runtime is managed by the WASM component host (e.g., Spin)