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 set_tool_schemas(
&mut self,
_schemas: HashMap<String, Value>,
) -> McpResult<()> { ... }
fn set_server_capabilities(
&mut self,
_capabilities: ServerCapabilities,
) -> McpResult<()> { ... }
fn set_task_notifications(
&mut self,
_receiver: Receiver<JsonRpcNotification>,
) -> McpResult<()> { ... }
fn is_running(&self) -> bool { ... }
fn server_info(&self) -> String { ... }
}Expand description
Transport trait for MCP servers
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
Sourcefn 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 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,
Provided Methods§
Sourcefn set_tool_schemas(
&mut self,
_schemas: HashMap<String, Value>,
) -> McpResult<()>
fn set_tool_schemas( &mut self, _schemas: HashMap<String, Value>, ) -> McpResult<()>
Provide registered tool input schemas to transports that mirror and validate MCP routing headers. Other transports may ignore them.
Sourcefn set_server_capabilities(
&mut self,
_capabilities: ServerCapabilities,
) -> McpResult<()>
fn set_server_capabilities( &mut self, _capabilities: ServerCapabilities, ) -> McpResult<()>
Provide the capabilities used to acknowledge subscription filters.
Sourcefn set_task_notifications(
&mut self,
_receiver: Receiver<JsonRpcNotification>,
) -> McpResult<()>
fn set_task_notifications( &mut self, _receiver: Receiver<JsonRpcNotification>, ) -> McpResult<()>
Attach task-status notifications to the transport’s subscription hub.
Sourcefn is_running(&self) -> bool
fn is_running(&self) -> bool
Sourcefn server_info(&self) -> String
fn server_info(&self) -> String
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".