Skip to main content

AsyncToolHandler

Trait AsyncToolHandler 

Source
pub trait AsyncToolHandler: Send + Sync {
    // Required method
    fn call<'life0, 'async_trait>(
        &'life0 self,
        params: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Async tool-handler trait — the async counterpart to the synchronous Handler.

Object-safe via async_trait, so an McpServer can store Arc<dyn AsyncToolHandler> and await it from an async transport (e.g. the HTTP/SSE transport).

Required Methods§

Source

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

Invoke the handler with the tool call parameters.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§