McpHandler

Trait McpHandler 

Source
pub trait McpHandler: Send + Sync {
    // Required methods
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        params: Option<Value>,
    ) -> Pin<Box<dyn Future<Output = McpResult<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn supported_methods(&self) -> Vec<String>;

    // Provided method
    fn handle_with_session<'life0, 'async_trait>(
        &'life0 self,
        params: Option<Value>,
        _session: Option<SessionContext>,
    ) -> Pin<Box<dyn Future<Output = McpResult<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Generic MCP handler trait

Required Methods§

Source

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

Handle an MCP request

Source

fn supported_methods(&self) -> Vec<String>

Get the methods this handler supports

Provided Methods§

Source

fn handle_with_session<'life0, 'async_trait>( &'life0 self, params: Option<Value>, _session: Option<SessionContext>, ) -> Pin<Box<dyn Future<Output = McpResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle an MCP request with session context (default implementation calls handle)

Implementors§