mcp_transport_rs/server/traits.rs
1use async_trait::async_trait;
2use mcp_core_rs::protocol::message::JsonRpcMessage;
3use mcp_error_rs::Result;
4
5#[async_trait]
6pub trait ServerTransport: Send + Sync {
7 /// Reads a JSON-RPC message (could be a Request or Notification)
8 async fn read_message(&mut self) -> Option<Result<JsonRpcMessage>>;
9
10 /// Sends a JSON-RPC message (usually a Response)
11 async fn write_message(&mut self, msg: JsonRpcMessage) -> Result<()>;
12
13 /// Closes the transport connection
14 async fn close(&mut self) -> Result<()> {
15 Ok(())
16 }
17}