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;
9pub mod streamable_http;
10
11use crate::mcp::protocol::{JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, McpNotification};
12use anyhow::Result;
13use async_trait::async_trait;
14use tokio::sync::mpsc;
15
16/// MCP transport trait
17#[async_trait]
18pub trait McpTransport: Send + Sync {
19    /// Send request and wait for response
20    async fn request(&self, request: JsonRpcRequest) -> Result<JsonRpcResponse>;
21
22    /// Send notification (no response expected)
23    async fn notify(&self, notification: JsonRpcNotification) -> Result<()>;
24
25    /// Get notification receiver
26    fn notifications(&self) -> mpsc::Receiver<McpNotification>;
27
28    /// Close the transport
29    async fn close(&self) -> Result<()>;
30
31    /// Check if transport is connected
32    fn is_connected(&self) -> bool;
33}