Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn description(&self) -> &'static str;
    fn schema(&self) -> Value;
    fn call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        args: &'life1 Value,
        ctx: &'life2 ToolContext,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Content>, AgentError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn metadata(&self) -> ToolMetadata { ... }
}

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn description(&self) -> &'static str

Human-readable description of what this tool does and when to use it.

Source

fn schema(&self) -> Value

JSON Schema for the tool’s input arguments (MCP inputSchema shape, without the provider envelope).

Source

fn call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, args: &'life1 Value, ctx: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = Result<Vec<Content>, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Provided Methods§

Source

fn metadata(&self) -> ToolMetadata

Machine-readable metadata for tool introspection.

The default implementation derives name and description from Tool::name and Tool::description, sets origin to "custom", and leaves requirements empty. Tool authors are encouraged to override this to provide an accurate origin and version.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Tool for EditFileTool

Source§

fn name(&self) -> &'static str

Source§

fn description(&self) -> &'static str

Source§

fn schema(&self) -> Value

Source§

fn metadata(&self) -> ToolMetadata

Source§

fn call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, args: &'life1 Value, _ctx: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = Result<Vec<Content>, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, EditFileTool: 'async_trait,

Source§

impl Tool for ListFilesTool

Source§

fn name(&self) -> &'static str

Source§

fn description(&self) -> &'static str

Source§

fn schema(&self) -> Value

Source§

fn metadata(&self) -> ToolMetadata

Source§

fn call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, args: &'life1 Value, ctx: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = Result<Vec<Content>, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, ListFilesTool: 'async_trait,

Source§

impl Tool for McpToolAdapter

Source§

fn name(&self) -> &'static str

Source§

fn description(&self) -> &'static str

Source§

fn schema(&self) -> Value

Source§

fn call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, args: &'life1 Value, _ctx: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = Result<Vec<Content>, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, McpToolAdapter: 'async_trait,

Source§

impl Tool for ReadFileTool

Source§

fn name(&self) -> &'static str

Source§

fn description(&self) -> &'static str

Source§

fn schema(&self) -> Value

Source§

fn metadata(&self) -> ToolMetadata

Source§

fn call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, args: &'life1 Value, ctx: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = Result<Vec<Content>, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, ReadFileTool: 'async_trait,

Source§

impl Tool for WriteFileTool

Source§

fn name(&self) -> &'static str

Source§

fn description(&self) -> &'static str

Source§

fn schema(&self) -> Value

Source§

fn metadata(&self) -> ToolMetadata

Source§

fn call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, args: &'life1 Value, _ctx: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = Result<Vec<Content>, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, WriteFileTool: 'async_trait,

Implementors§

Source§

impl Tool for AutoContinueTool

Source§

impl Tool for UpdatePlanTool

Source§

impl<T> Tool for T
where T: TypedTool + Send + Sync + 'static,