pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn execute_with_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
_sink: &'life1 dyn ProgressSink,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn spec(&self) -> ToolSpec { ... }
}Expand description
Core tool trait — implement for any capability
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description
Sourcefn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON schema for parameters
Provided Methods§
Sourcefn execute_with_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
_sink: &'life1 dyn ProgressSink,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_with_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
_sink: &'life1 dyn ProgressSink,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute the tool with a progress-notification sink.
This is an additive, opt-in entry point for long-running tools
that want to emit progress updates (modeled on MCP
notifications/progress). The default implementation simply forwards
to Tool::execute and ignores sink, so every existing tool keeps
compiling and behaving identically.
Callers that do not care about progress should keep calling
Tool::execute directly; callers that do (e.g. the forthcoming
in-process MCP server) call execute_with_progress with a real sink
and forward emissions as MCP notifications.