pub struct SseServerBuilder { /* private fields */ }Expand description
Builder for creating SSE MCP servers
Provides a fluent API for configuring and building MCP proxy servers.
§Example
use mcp_sse_proxy::server_builder::{SseServerBuilder, BackendConfig};
// Create a server with stdio backend
let (router, ct) = SseServerBuilder::new(BackendConfig::Stdio {
command: "npx".into(),
args: Some(vec!["-y".into(), "@modelcontextprotocol/server-filesystem".into()]),
env: None,
})
.mcp_id("my-server")
.sse_path("/custom/sse")
.post_path("/custom/message")
.stateful(false) // Disable stateful mode for OneShot services (faster responses)
.build()
.await?;Implementations§
Source§impl SseServerBuilder
impl SseServerBuilder
Sourcepub fn new(backend: BackendConfig) -> Self
pub fn new(backend: BackendConfig) -> Self
Create a new builder with the given backend configuration
Sourcepub fn mcp_id(self, id: impl Into<String>) -> Self
pub fn mcp_id(self, id: impl Into<String>) -> Self
Set the MCP service identifier
Used for logging and service identification.
Sourcepub fn tool_filter(self, filter: ToolFilter) -> Self
pub fn tool_filter(self, filter: ToolFilter) -> Self
Set the tool filter configuration
Sourcepub fn keep_alive(self, secs: u64) -> Self
pub fn keep_alive(self, secs: u64) -> Self
Set the keep-alive interval in seconds
Sourcepub fn stateful(self, stateful: bool) -> Self
pub fn stateful(self, stateful: bool) -> Self
Set stateful mode (default: true)
When false, uses with_service_directly which skips MCP initialization
for faster responses. This is recommended for OneShot services.
Sourcepub async fn build(self) -> Result<(Router, CancellationToken, SseHandler)>
pub async fn build(self) -> Result<(Router, CancellationToken, SseHandler)>
Build the server and return an axum Router, CancellationToken, and SseHandler
The router can be merged with other axum routers or served directly. The CancellationToken can be used to gracefully shut down the service. The SseHandler can be used for status checks and management.