Skip to main content

Tool

Trait Tool 

Source
pub trait Tool:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn descriptor(&self) -> ToolDescriptor;
    fn call<'life0, 'async_trait>(
        &'life0 self,
        arguments: Value,
    ) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

One operation an external AI may invoke.

A tool wraps an application service, never a Tauri command: an operation that exists only as a command is not reachable from MCP, from a CLI or from a headless run. If writing a tool means duplicating logic, the logic is in the wrong place.

Required Methods§

Source

fn descriptor(&self) -> ToolDescriptor

Source

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

Arguments arrive as JSON, validated by the caller against nothing in particular — check them.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§