Skip to main content

mcp_sse_proxy/
lib.rs

1//! MCP SSE Proxy Module
2//!
3//! This module provides a proxy implementation for MCP (Model Context Protocol)
4//! using SSE (Server-Sent Events) transport.
5//!
6//! # Features
7//!
8//! - **SSE Support**: Uses rmcp 0.10 with SSE transport (removed in 0.12+)
9//! - **Stable Protocol**: Production-ready SSE implementation
10//! - **Hot Swap**: Supports backend connection replacement
11//! - **Fallback Option**: Used when Streamable HTTP is not supported
12//! - **High-level Client API**: Simple connection interface hiding transport details
13//!
14//! # Architecture
15//!
16//! ```text
17//! Client → SSE → SseHandler → Backend MCP Service
18//! ```
19//!
20//! # Example
21//!
22//! ```rust,ignore
23//! use mcp_sse_proxy::{SseClientConnection, McpClientConfig};
24//!
25//! // Connect to an MCP server
26//! let config = McpClientConfig::new("http://localhost:8080/sse");
27//! let conn = SseClientConnection::connect(config).await?;
28//!
29//! // List available tools
30//! let tools = conn.list_tools().await?;
31//! ```
32
33pub mod client;
34pub mod config;
35pub mod server;
36pub mod server_builder;
37pub mod sse_handler;
38
39// Re-export main types
40pub use mcp_common::McpServiceConfig;
41pub use server::{run_sse_server, run_sse_server_from_config};
42pub use sse_handler::{SseHandler, ToolFilter};
43
44// Re-export server builder API
45pub use server_builder::{BackendConfig, SseServerBuilder, SseServerBuilderConfig};
46
47// Re-export client connection types
48pub use client::{SseClientConnection, ToolInfo};
49pub use mcp_common::McpClientConfig;
50
51// Re-export commonly used rmcp types
52pub use rmcp::{
53    RoleClient, RoleServer, ServerHandler, ServiceExt,
54    model::{CallToolRequestParam, ClientCapabilities, ClientInfo, Implementation, ServerInfo},
55    service::{Peer, RunningService},
56};
57
58// Re-export transport types for SSE protocol (rmcp 0.10)
59pub use rmcp::transport::{
60    SseClientTransport, SseServer, child_process::TokioChildProcess, sse_client::SseClientConfig,
61    sse_server::SseServerConfig, stdio,
62};