Trait Transport

Source
pub trait Transport<R, S>:
    Send
    + Sync
    + 'static
where 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 the McpMessage trait.
  • S: The message type to send.
  • M: The type of message that we expect to receive as a response to the sent message.

Required Methods§

Source

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,

Source

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,

Source

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,

Implementors§

Source§

impl<R, S> Transport<R, S> for ClientSseTransport
where R: RpcMessage + Clone + Send + Sync + DeserializeOwned + 'static, S: McpMessage + Clone + Send + Sync + Serialize + 'static,

Source§

impl<R, S> Transport<R, S> for SseTransport
where R: RpcMessage + Clone + Send + Sync + DeserializeOwned + 'static, S: McpMessage + Clone + Send + Sync + Serialize + 'static,

Source§

impl<R, S> Transport<R, S> for StdioTransport
where R: RpcMessage + Clone + Send + Sync + DeserializeOwned + 'static, S: McpMessage + Clone + Send + Sync + Serialize + 'static,