pub struct SseClientConnection { /* private fields */ }Expand description
Opaque wrapper for SSE client connection
This type encapsulates an active connection to an MCP server via SSE 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_sse_proxy::{SseClientConnection, McpClientConfig};
let config = McpClientConfig::new("http://localhost:8080/sse")
.with_header("Authorization", "Bearer token");
let conn = SseClientConnection::connect(config).await?;
let tools = conn.list_tools().await?;
println!("Available tools: {:?}", tools);Implementations§
Source§impl SseClientConnection
impl SseClientConnection
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) -> SseHandler
pub fn into_handler(self, mcp_id: String, tool_filter: ToolFilter) -> SseHandler
Convert this connection into an SseHandler for serving
This consumes the connection and creates an SseHandler 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.
Auto Trait Implementations§
impl Freeze for SseClientConnection
impl !RefUnwindSafe for SseClientConnection
impl Send for SseClientConnection
impl Sync for SseClientConnection
impl Unpin for SseClientConnection
impl !UnwindSafe for SseClientConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more