pub struct StreamClientConnection { /* private fields */ }Expand description
Opaque wrapper for Streamable HTTP client connection
This type encapsulates an active connection to an MCP server via Streamable HTTP protocol.
It hides the internal RunningService type and provides only the methods
needed by consuming code.
Note: This type is not Clone because the underlying RunningService
is designed for single-owner use. Use into_handler() or into_running_service()
to consume the connection.
§Example
use mcp_streamable_proxy::{StreamClientConnection, McpClientConfig};
let config = McpClientConfig::new("http://localhost:8080/mcp")
.with_header("Authorization", "Bearer token");
let conn = StreamClientConnection::connect(config).await?;
let tools = conn.list_tools().await?;
println!("Available tools: {:?}", tools);Implementations§
Source§impl StreamClientConnection
impl StreamClientConnection
Sourcepub async fn connect(config: McpClientConfig) -> Result<Self>
pub async fn connect(config: McpClientConfig) -> Result<Self>
Sourcepub async fn list_tools(&self) -> Result<Vec<ToolInfo>>
pub async fn list_tools(&self) -> Result<Vec<ToolInfo>>
List available tools from the MCP server
Sourcepub fn peer_info(&self) -> Option<&ServerInfo>
pub fn peer_info(&self) -> Option<&ServerInfo>
Get the peer info from the server
Sourcepub fn into_handler(
self,
mcp_id: String,
tool_filter: ToolFilter,
) -> ProxyHandler
pub fn into_handler( self, mcp_id: String, tool_filter: ToolFilter, ) -> ProxyHandler
Convert this connection into a ProxyHandler for serving
This consumes the connection and creates a ProxyHandler that can proxy requests to the backend MCP server.
§Arguments
mcp_id- Identifier for logging purposestool_filter- Tool filtering configuration
Sourcepub fn into_running_service(self) -> RunningService<RoleClient, ClientInfo>
pub fn into_running_service(self) -> RunningService<RoleClient, ClientInfo>
Extract the internal RunningService for use with swap_backend
This is used internally to support backend hot-swapping.