Skip to main content

Tool

Trait Tool 

Source
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<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn mutating(&self) -> bool { ... }
    fn thulp_definition(&self) -> ToolDefinition { ... }
    fn validate_args(&self, args: &Value) -> Result<(), String> { ... }
}
Expand description

Trait for implementing tools

Required Methods§

Source

fn name(&self) -> &str

Returns the unique name of this tool

Source

fn description(&self) -> &str

Returns a description of what this tool does

Source

fn parameters_schema(&self) -> Value

Returns the JSON schema for this tool’s parameters

Source

fn execute<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Executes the tool with the given arguments

Provided Methods§

Source

fn mutating(&self) -> bool

Returns whether this tool mutates state (writes files, runs commands, etc.)

Read-only tools (mutating = false) are auto-approved. Mutating tools (mutating = true) require user confirmation.

Source

fn thulp_definition(&self) -> ToolDefinition

Override in tools that use Parameter::builder() for rich validation. Default: parses JSON schema back into thulp Parameters (best-effort).

Source

fn validate_args(&self, args: &Value) -> Result<(), String>

Validate arguments using thulp-core typed parameters. Returns Ok(()) or an error describing which params are wrong/missing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§