Skip to main content

ToolDyn

Trait ToolDyn 

Source
pub trait ToolDyn: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn input_schema(&self) -> Value;
    fn call(
        &self,
        input: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + '_>>;

    // Provided methods
    fn maybe_streaming(&self) -> Option<&dyn ToolDynStreaming> { ... }
    fn concurrency_hint(&self) -> ToolConcurrencyHint { ... }
}
Expand description

Object-safe trait for tool implementations.

Any tool source (local function, MCP server, HTTP endpoint) implements this trait. Tools are stored as Arc<dyn ToolDyn> in ToolRegistry.

Required Methods§

Source

fn name(&self) -> &str

The tool’s unique name.

Source

fn description(&self) -> &str

Human-readable description of what the tool does.

Source

fn input_schema(&self) -> Value

JSON Schema for the tool’s input parameters.

Source

fn call( &self, input: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + '_>>

Execute the tool with the given input.

Provided Methods§

Source

fn maybe_streaming(&self) -> Option<&dyn ToolDynStreaming>

If this tool also supports streaming, return a reference to its streaming interface. Default is None; streaming is opt-in and non-disruptive.

Source

fn concurrency_hint(&self) -> ToolConcurrencyHint

Optional concurrency hint used by planners/deciders.

Default is Exclusive to preserve backward-compatible behavior.

Implementors§