modelcontextprotocol_client/transport/mod.rs
1// mcp-client/src/transport/mod.rs
2pub mod stdio;
3
4use async_trait::async_trait;
5use anyhow::Result;
6use mcp_protocol::messages::JsonRpcMessage;
7
8/// Transport trait for sending and receiving MCP messages
9#[async_trait]
10pub trait Transport: Send + Sync + 'static {
11 /// Start the transport (listening for incoming messages)
12 async fn start(&self) -> Result<()>;
13
14 /// Send a message to the server
15 async fn send(&self, message: JsonRpcMessage) -> Result<()>;
16
17 /// Close the transport
18 async fn close(&self) -> Result<()>;
19
20 /// Clone the transport
21 fn box_clone(&self) -> Box<dyn Transport>;
22}
23
24pub use stdio::StdioTransport;