Skip to main content

a3s_code_core/mcp/transport/
mod.rs

1//! MCP Transport Layer
2//!
3//! Provides transport abstraction for MCP communication.
4//! - `stdio`: Local process communication via stdin/stdout
5//! - `http_sse`: Remote server communication via HTTP + Server-Sent Events
6
7pub mod http_sse;
8pub mod stdio;
9
10use crate::mcp::protocol::{JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, McpNotification};
11use anyhow::Result;
12use async_trait::async_trait;
13use tokio::sync::mpsc;
14
15/// MCP transport trait
16#[async_trait]
17pub trait McpTransport: Send + Sync {
18    /// Send request and wait for response
19    async fn request(&self, request: JsonRpcRequest) -> Result<JsonRpcResponse>;
20
21    /// Send notification (no response expected)
22    async fn notify(&self, notification: JsonRpcNotification) -> Result<()>;
23
24    /// Get notification receiver
25    fn notifications(&self) -> mpsc::Receiver<McpNotification>;
26
27    /// Close the transport
28    async fn close(&self) -> Result<()>;
29
30    /// Check if transport is connected
31    fn is_connected(&self) -> bool;
32}