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) -> SseServerBuilder
pub fn new(backend: BackendConfig) -> SseServerBuilder
Create a new builder with the given backend configuration
Sourcepub fn sse_path(self, path: impl Into<String>) -> SseServerBuilder
pub fn sse_path(self, path: impl Into<String>) -> SseServerBuilder
Set the SSE endpoint path
Sourcepub fn post_path(self, path: impl Into<String>) -> SseServerBuilder
pub fn post_path(self, path: impl Into<String>) -> SseServerBuilder
Set the message endpoint path
Sourcepub fn mcp_id(self, id: impl Into<String>) -> SseServerBuilder
pub fn mcp_id(self, id: impl Into<String>) -> SseServerBuilder
Set the MCP service identifier
Used for logging and service identification.
Sourcepub fn tool_filter(self, filter: ToolFilter) -> SseServerBuilder
pub fn tool_filter(self, filter: ToolFilter) -> SseServerBuilder
Set the tool filter configuration
Sourcepub fn keep_alive(self, secs: u64) -> SseServerBuilder
pub fn keep_alive(self, secs: u64) -> SseServerBuilder
Set the keep-alive interval in seconds
Sourcepub fn stateful(self, stateful: bool) -> SseServerBuilder
pub fn stateful(self, stateful: bool) -> SseServerBuilder
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), Error>
pub async fn build( self, ) -> Result<(Router, CancellationToken, SseHandler), Error>
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.
Auto Trait Implementations§
impl Freeze for SseServerBuilder
impl RefUnwindSafe for SseServerBuilder
impl Send for SseServerBuilder
impl Sync for SseServerBuilder
impl Unpin for SseServerBuilder
impl UnsafeUnpin for SseServerBuilder
impl UnwindSafe for SseServerBuilder
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request