pub struct StreamServerBuilder { /* private fields */ }Expand description
Builder for creating Streamable HTTP MCP servers
Provides a fluent API for configuring and building MCP proxy servers.
§Example
ⓘ
use mcp_streamable_proxy::server_builder::{StreamServerBuilder, BackendConfig};
// Create a server with stdio backend
let (router, ct) = StreamServerBuilder::new(BackendConfig::Stdio {
command: "npx".into(),
args: Some(vec!["-y".into(), "@modelcontextprotocol/server-filesystem".into()]),
env: None,
})
.mcp_id("my-server")
.stateful(false)
.build()
.await?;Implementations§
Source§impl StreamServerBuilder
impl StreamServerBuilder
Sourcepub fn new(backend: BackendConfig) -> Self
pub fn new(backend: BackendConfig) -> Self
Create a new builder with the given backend configuration
Sourcepub fn stateful(self, enabled: bool) -> Self
pub fn stateful(self, enabled: bool) -> Self
Set whether to enable stateful mode
Stateful mode enables session management and server-side push.
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 async fn build(self) -> Result<(Router, CancellationToken, ProxyHandler)>
pub async fn build(self) -> Result<(Router, CancellationToken, ProxyHandler)>
Build the server and return an axum Router, CancellationToken, and ProxyHandler
The router can be merged with other axum routers or served directly. The CancellationToken can be used to gracefully shut down the service. The ProxyHandler can be used for status checks and management.
Auto Trait Implementations§
impl Freeze for StreamServerBuilder
impl RefUnwindSafe for StreamServerBuilder
impl Send for StreamServerBuilder
impl Sync for StreamServerBuilder
impl Unpin for StreamServerBuilder
impl UnsafeUnpin for StreamServerBuilder
impl UnwindSafe for StreamServerBuilder
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