Skip to main content

McpServerConfigBuilder

Struct McpServerConfigBuilder 

Source
pub struct McpServerConfigBuilder { /* private fields */ }
Expand description

Builder for creating MCP server configurations.

Implementations§

Source§

impl McpServerConfigBuilder

Source

pub fn new() -> Self

Creates a new configuration builder with defaults.

Source

pub fn name(self, name: impl Into<String>) -> Self

Sets the server name.

Source

pub fn version(self, version: impl Into<String>) -> Self

Sets the server version.

Source

pub fn with_stdio_transport(self) -> Self

Configures the server to use stdio transport.

Source

pub fn with_http_transport(self, host: impl Into<String>, port: u16) -> Self

Available on crate feature http-server only.

Configures the server to use HTTP transport.

Source

pub fn with_tool<T: McpTool + 'static>(self, tool: T) -> Self

Adds a single tool to the server.

Source

pub fn with_dyn_tool(self, tool: DynTool) -> Self

Adds a dynamic tool reference to the server.

Source

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])
Source

pub fn with_tools_from<P: ToolProvider>(self, provider: P) -> Self

Adds all tools from a provider.

Source

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();
Source

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();
Source

pub fn with_capabilities(self, capabilities: McpCapabilities) -> Self

Adds capabilities to the server.

Source

pub fn with_resources(self) -> Self

Enables resource capabilities.

Source

pub fn with_prompts(self) -> Self

Enables prompt capabilities.

Source

pub fn build(self) -> McpServerConfig

Builds the server configuration.

Trait Implementations§

Source§

impl Default for McpServerConfigBuilder

Source§

fn default() -> McpServerConfigBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more