ToolProvider

Trait ToolProvider 

Source
pub trait ToolProvider: Send + Sync {
    // Required methods
    fn list_tools<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 RequestContext,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Tool>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn call_tool<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        arguments: Option<HashMap<String, Value>>,
        ctx: &'life2 RequestContext,
    ) -> Pin<Box<dyn Future<Output = Result<(Vec<ToolContent>, bool)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Trait for implementing tool providers

Implement this trait to provide tools (functions, operations) to MCP clients. All methods receive a RequestContext with access to headers and request metadata.

Required Methods§

Source

fn list_tools<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 RequestContext, ) -> Pin<Box<dyn Future<Output = Result<Vec<Tool>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List available tools

§Arguments
  • ctx - Request context with headers and metadata
§Returns

A vector of available tools

Source

fn call_tool<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, arguments: Option<HashMap<String, Value>>, ctx: &'life2 RequestContext, ) -> Pin<Box<dyn Future<Output = Result<(Vec<ToolContent>, bool)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Call a specific tool

§Arguments
  • name - The name of the tool to call
  • arguments - Tool arguments as a key-value map
  • ctx - Request context with headers and metadata
§Returns

A tuple of (content, is_error)

Implementors§