ToolHandler

Trait ToolHandler 

Source
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§

Source

const NAME: &'static str

The name of the tool as it will appear to MCP clients.

Source

const DESCRIPTION: &'static str

A human-readable description of what the tool does.

Required Methods§

Source

fn input_schema() -> Value

Returns the JSON schema describing the tool’s input parameters.

Source

fn execute(args: Value) -> Result<String, String>

Executes the tool with the given arguments.

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)

Source§

const NAME: &'static str = T::NAME

Source§

const DESCRIPTION: &'static str = T::DESCRIPTION