pub trait Transport<R, S>:
Send
+ Sync
+ 'staticwhere
R: McpMessage + Clone + Send + Sync + DeserializeOwned + 'static,
S: Clone + Send + Sync + Serialize + 'static,{
// Required methods
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(Pin<Box<dyn Stream<Item = R> + Send>>, MessageDispatcher<R>, IoStream), TransportError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
MessageDispatcher<R>: McpDispatch<R, S>,
Self: 'async_trait;
fn shut_down<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn is_shut_down<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
A trait representing the transport layer for MCP.
This trait is designed for handling the transport of messages within an MCP protocol system. It provides a method to start the transport process, which involves setting up a stream, a message sender, and handling I/O operations.
The Transport
trait requires three associated types:
R
: The message type to send, which must implement theMcpMessage
trait.S
: The message type to send.M
: The type of message that we expect to receive as a response to the sent message.