pub struct ServerBuilder<H: McpHandler> { /* private fields */ }Expand description
Server builder for configuring and running MCP servers.
This builder provides a fluent API for:
- Selecting transport at runtime
- Configuring rate limits and connection limits
- Setting up graceful shutdown
- Integrating with existing server infrastructure
§Example
ⓘ
use turbomcp::prelude::*;
MyServer.builder()
.transport(Transport::http("0.0.0.0:8080"))
.with_rate_limit(100, Duration::from_secs(1))
.serve()
.await?;Implementations§
Source§impl<H: McpHandler> ServerBuilder<H>
impl<H: McpHandler> ServerBuilder<H>
Sourcepub fn with_rate_limit(self, max_requests: u32, window: Duration) -> Self
pub fn with_rate_limit(self, max_requests: u32, window: Duration) -> Self
Sourcepub fn with_connection_limit(self, max: usize) -> Self
pub fn with_connection_limit(self, max: usize) -> Self
Sourcepub fn with_graceful_shutdown(self, timeout: Duration) -> Self
pub fn with_graceful_shutdown(self, timeout: Duration) -> Self
Sourcepub fn with_max_message_size(self, size: usize) -> Self
pub fn with_max_message_size(self, size: usize) -> Self
Sourcepub fn with_config(self, config: ServerConfig) -> Self
pub fn with_config(self, config: ServerConfig) -> Self
Sourcepub fn handler(&self) -> &H
pub fn handler(&self) -> &H
Get the underlying handler.
Useful for testing or custom integrations.
Sourcepub fn into_handler(self) -> H
pub fn into_handler(self) -> H
Consume the builder and return the handler.
Useful for custom integrations where you need ownership.
Trait Implementations§
Auto Trait Implementations§
impl<H> Freeze for ServerBuilder<H>where
H: Freeze,
impl<H> RefUnwindSafe for ServerBuilder<H>where
H: RefUnwindSafe,
impl<H> Send for ServerBuilder<H>
impl<H> Sync for ServerBuilder<H>
impl<H> Unpin for ServerBuilder<H>where
H: Unpin,
impl<H> UnsafeUnpin for ServerBuilder<H>where
H: UnsafeUnpin,
impl<H> UnwindSafe for ServerBuilder<H>where
H: UnwindSafe,
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