pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Value,
ctx: &'life1 dyn ToolContext,
) -> Pin<Box<dyn Future<Output = Result<Value, PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
A tool that can be invoked by an agent or exposed via MCP.
Tools are the primary extension point for adding new capabilities.
Each tool declares its name, description, and a JSON Schema for
its parameters. The host routes execute() calls based on the
tool name.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description of what the tool does.
Sourcefn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON Schema describing the tool’s parameters.
Returns a serde_json::Value representing a JSON Schema object.
The host uses this schema for validation and for MCP tools/list.
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Value,
ctx: &'life1 dyn ToolContext,
) -> Pin<Box<dyn Future<Output = Result<Value, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Value,
ctx: &'life1 dyn ToolContext,
) -> Pin<Box<dyn Future<Output = Result<Value, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute the tool with the given parameters and context.
params is a JSON object matching parameters_schema().
Returns a JSON value with the tool’s result, or a PluginError.