pub struct McpServerConfigBuilder { /* private fields */ }Expand description
Builder for creating MCP server configurations.
Implementations§
Source§impl McpServerConfigBuilder
impl McpServerConfigBuilder
Sourcepub fn with_stdio_transport(self) -> Self
pub fn with_stdio_transport(self) -> Self
Configures the server to use stdio transport.
Sourcepub fn with_http_transport(self, host: impl Into<String>, port: u16) -> Self
Available on crate feature http-server only.
pub fn with_http_transport(self, host: impl Into<String>, port: u16) -> Self
http-server only.Configures the server to use HTTP transport.
Sourcepub fn with_tool<T: McpTool + 'static>(self, tool: T) -> Self
pub fn with_tool<T: McpTool + 'static>(self, tool: T) -> Self
Adds a single tool to the server.
Sourcepub fn with_dyn_tool(self, tool: DynTool) -> Self
pub fn with_dyn_tool(self, tool: DynTool) -> Self
Adds a dynamic tool reference to the server.
Sourcepub fn with_tools(self, tools: Vec<DynTool>) -> Self
pub fn with_tools(self, tools: Vec<DynTool>) -> Self
Adds multiple tools from a vector.
Use the tools![] macro to create the vector:
ⓘ
.with_tools(tools![AddTool, SubtractTool])Sourcepub fn with_tools_from<P: ToolProvider>(self, provider: P) -> Self
pub fn with_tools_from<P: ToolProvider>(self, provider: P) -> Self
Adds all tools from a provider.
Sourcepub fn register_tools(self) -> Self
pub fn register_tools(self) -> Self
Registers all auto-discovered tools.
This collects all tools defined with #[mcp_tool] in the crate
and registers them with the server.
§Example
ⓘ
use mcp::macros::mcp_tool;
use mcp::{McpServerConfig, McpServer};
#[mcp_tool(description = "Add numbers", group = "math")]
fn add(a: f64, b: f64) -> f64 { a + b }
let config = McpServerConfig::builder()
.name("my-server")
.register_tools() // Registers all #[mcp_tool] functions
.build();Sourcepub fn register_tools_in_group(self, group: &str) -> Self
pub fn register_tools_in_group(self, group: &str) -> Self
Registers auto-discovered tools filtered by group.
Only registers tools that have the specified group.
§Example
ⓘ
use mcp::macros::mcp_tool;
use mcp::{McpServerConfig, McpServer};
#[mcp_tool(description = "Add numbers", group = "math")]
fn add(a: f64, b: f64) -> f64 { a + b }
#[mcp_tool(description = "Echo text", group = "text")]
fn echo(msg: String) -> String { msg }
let config = McpServerConfig::builder()
.name("math-server")
.register_tools_in_group("math") // Only registers "add"
.build();Sourcepub fn with_capabilities(self, capabilities: McpCapabilities) -> Self
pub fn with_capabilities(self, capabilities: McpCapabilities) -> Self
Adds capabilities to the server.
Sourcepub fn with_resources(self) -> Self
pub fn with_resources(self) -> Self
Enables resource capabilities.
Sourcepub fn with_prompts(self) -> Self
pub fn with_prompts(self) -> Self
Enables prompt capabilities.
Sourcepub fn build(self) -> McpServerConfig
pub fn build(self) -> McpServerConfig
Builds the server configuration.
Trait Implementations§
Source§impl Default for McpServerConfigBuilder
impl Default for McpServerConfigBuilder
Source§fn default() -> McpServerConfigBuilder
fn default() -> McpServerConfigBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for McpServerConfigBuilder
impl !RefUnwindSafe for McpServerConfigBuilder
impl Send for McpServerConfigBuilder
impl Sync for McpServerConfigBuilder
impl Unpin for McpServerConfigBuilder
impl !UnwindSafe for McpServerConfigBuilder
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