Skip to main content

Crate mcp_streamable_proxy

Crate mcp_streamable_proxy 

Source
Expand description

MCP Streamable HTTP Proxy Module

This module provides a proxy implementation for MCP (Model Context Protocol) using Streamable HTTP transport with stateful session management.

§Features

  • Streamable HTTP Support: Uses rmcp 0.12 with enhanced Streamable HTTP transport
  • Stateful Sessions: Custom SessionManager with backend version tracking
  • Hot Swap: Supports backend connection replacement without downtime
  • Version Control: Automatically invalidates sessions when backend reconnects
  • High-level Client API: Simple connection interface hiding transport details

§Architecture

Client → Streamable HTTP → ProxyAwareSessionManager → ProxyHandler → Backend MCP Service
                                   ↓
                           Version Tracking
                           (DashMap<SessionId, BackendVersion>)

§Example

use mcp_streamable_proxy::{StreamClientConnection, McpClientConfig};

// Connect to an MCP server
let config = McpClientConfig::new("http://localhost:8080/mcp");
let conn = StreamClientConnection::connect(config).await?;

// List available tools
let tools = conn.list_tools().await?;

Re-exports§

pub use proxy_handler::ProxyHandler;
pub use server::run_stream_server;
pub use server::run_stream_server_from_config;
pub use session_manager::ProxyAwareSessionManager;
pub use detector::is_streamable_http;
pub use server_builder::BackendConfig;
pub use server_builder::StreamServerBuilder;
pub use server_builder::StreamServerConfig;
pub use client::StreamClientConnection;
pub use client::ToolInfo;

Modules§

client
Streamable HTTP Client Connection Module
config
Configuration types for Streamable HTTP proxy
detector
proxy_handler
server
Streamable HTTP server implementation
server_builder
Streamable HTTP Server Builder
session_manager
Session Manager with backend version tracking

Structs§

ClientCapabilities
Builder
Implementation
LocalSessionManager
McpClientConfig
Configuration for MCP client connections
McpServiceConfig
MCP 服务配置
Peer
An interface to fetch the remote client or server
RoleClient
RoleServer
RunningService
StreamableHttpClientTransportConfig
StreamableHttpServerConfig
StreamableHttpService
Streamable HTTP server
TokioChildProcess
ToolFilter
工具过滤配置

Traits§

ServerHandler
ServiceExt

Functions§

stdio
StdIO Transport

Type Aliases§

ClientInfo
ServerInfo
StreamableHttpClientTransport
A client-agnostic HTTP transport for RMCP that supports streaming responses.