pub trait ServerTransport: Send + Sync {
// Required methods
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn set_request_handler(&mut self, handler: ServerRequestHandler);
fn send_notification<'life0, 'async_trait>(
&'life0 mut self,
notification: JsonRpcNotification,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn is_running(&self) -> bool { ... }
fn server_info(&self) -> String { ... }
}
Expand description
Transport trait for MCP servers
This trait defines the interface for handling incoming requests and sending responses in a server-side MCP connection.
Required Methods§
Sourcefn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start the server transport and begin listening for connections
§Returns
Result indicating success or an error
Sourcefn set_request_handler(&mut self, handler: ServerRequestHandler)
fn set_request_handler(&mut self, handler: ServerRequestHandler)
Set the request handler that will process incoming requests
§Arguments
handler
- The request handler function