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§
Sourcefn 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 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
Sourcefn supported_methods(&self) -> Vec<String>
fn supported_methods(&self) -> Vec<String>
Get the methods this handler supports
Provided Methods§
Sourcefn 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,
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)