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§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Returns a description of what this tool does
Sourcefn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
Returns the JSON schema for this tool’s parameters
Provided Methods§
Sourcefn mutating(&self) -> bool
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.
Sourcefn thulp_definition(&self) -> ToolDefinition
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).