pub trait Transport: Send + Sync {
// Required methods
fn send_request<'life0, 'async_trait>(
&'life0 mut self,
request: JsonRpcRequest,
) -> Pin<Box<dyn Future<Output = McpResult<JsonRpcResponse>> + 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;
fn receive_notification<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<Option<JsonRpcNotification>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn close<'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_connected(&self) -> bool { ... }
fn connection_info(&self) -> String { ... }
}
Expand description
Transport trait for MCP clients
This trait defines the interface for sending requests and receiving responses in a client-side MCP connection.
Required Methods§
Sourcefn send_request<'life0, 'async_trait>(
&'life0 mut self,
request: JsonRpcRequest,
) -> Pin<Box<dyn Future<Output = McpResult<JsonRpcResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_request<'life0, 'async_trait>(
&'life0 mut self,
request: JsonRpcRequest,
) -> Pin<Box<dyn Future<Output = McpResult<JsonRpcResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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,
Sourcefn receive_notification<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<Option<JsonRpcNotification>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn receive_notification<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<Option<JsonRpcNotification>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive a notification from the server (non-blocking)
§Returns
Result containing an optional notification or an error
Provided Methods§
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Check if the transport is connected
§Returns
True if the transport is connected and ready for communication