pub struct MCPServerBuilder { /* private fields */ }Expand description
Builder for creating MCP-compatible HTTP servers with registered tools.
Implementations§
Source§impl MCPServerBuilder
impl MCPServerBuilder
Sourcepub async fn with_custom_tool(
self,
tool_name: &str,
protocol: Arc<dyn ToolProtocol>,
) -> Self
pub async fn with_custom_tool( self, tool_name: &str, protocol: Arc<dyn ToolProtocol>, ) -> Self
Register a custom tool protocol under a tool name.
Sourcepub fn with_bearer_token(self, token: impl Into<String>) -> Self
pub fn with_bearer_token(self, token: impl Into<String>) -> Self
Require bearer token authentication.
Sourcepub fn with_basic_auth(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn with_basic_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Require basic authentication.
Sourcepub fn allow_cidr(self, cidr: &str) -> Result<Self, String>
pub fn allow_cidr(self, cidr: &str) -> Result<Self, String>
Allow a CIDR block.
Sourcepub fn allow_localhost_only(self) -> Self
pub fn allow_localhost_only(self) -> Self
Restrict access to localhost only.
Sourcepub fn with_adapter(self, adapter: Arc<dyn HttpServerAdapter>) -> Self
pub fn with_adapter(self, adapter: Arc<dyn HttpServerAdapter>) -> Self
Override the HTTP adapter.
Sourcepub fn with_event_handler(self, handler: Arc<dyn McpEventHandler>) -> Self
pub fn with_event_handler(self, handler: Arc<dyn McpEventHandler>) -> Self
Attach an MCP event handler.
Sourcepub async fn start_on(
self,
port: u16,
) -> Result<HttpServerInstance, Box<dyn Error + Send + Sync>>
pub async fn start_on( self, port: u16, ) -> Result<HttpServerInstance, Box<dyn Error + Send + Sync>>
Start the server on the supplied port on localhost.
Sourcepub async fn start_at(
self,
addr: SocketAddr,
) -> Result<HttpServerInstance, Box<dyn Error + Send + Sync>>
pub async fn start_at( self, addr: SocketAddr, ) -> Result<HttpServerInstance, Box<dyn Error + Send + Sync>>
Start the server at an explicit socket address.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MCPServerBuilder
impl !RefUnwindSafe for MCPServerBuilder
impl Send for MCPServerBuilder
impl Sync for MCPServerBuilder
impl Unpin for MCPServerBuilder
impl UnsafeUnpin for MCPServerBuilder
impl !UnwindSafe for MCPServerBuilder
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