Skip to main content

a3s_code_core/mcp/transport/
mod.rs

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