pub struct McpConfig {
pub name: String,
pub version: String,
pub description: Option<String>,
pub tools_enabled: bool,
pub allowed_tags: HashSet<String>,
pub allowed_path_prefixes: Vec<String>,
pub admin_token: Option<String>,
pub expose_detailed_errors: bool,
pub max_tools: usize,
pub invocation_mode: InvocationMode,
}Expand description
Configuration for the native MCP server.
This is the primary way users control what gets exposed as tools, authentication for MCP clients, transport behavior, etc.
Fields§
§name: StringHuman-friendly name of this MCP server (shown to agents).
version: StringVersion string.
description: Option<String>Optional description.
tools_enabled: boolWhether tool discovery and calling is enabled.
Explicitly allowed tags. Only routes that have at least one of these tags
(via OpenAPI tags or future route metadata) will be exposed as tools.
Empty set + no other allow rules = nothing is exposed (safe default).
allowed_path_prefixes: Vec<String>Explicit path prefixes that are allowed to become tools.
Example: ["/api/public", "/agent"]
admin_token: Option<String>Admin / MCP client token.
When set, MCP clients must present this (via header or query param, transport dependent) to use discovery or invocation.
expose_detailed_errors: boolWhether to include detailed error information in tool responses.
In production you usually want this false (similar to RUSTAPI_ENV=production).
max_tools: usizeMaximum number of tools to advertise in one tools/list response.
Helps protect against very large route sets.
invocation_mode: InvocationModeHow tools/call should be executed.
Proxy (default) always goes over HTTP (correct and works for external targets).
InProcess / Auto are for when an in-process RustApi instance is available.
Implementations§
Source§impl McpConfig
impl McpConfig
Sourcepub fn version(self, version: impl Into<String>) -> Self
pub fn version(self, version: impl Into<String>) -> Self
Set the version advertised to MCP clients.
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Set a human description.
Sourcepub fn enable_tools(self, enabled: bool) -> Self
pub fn enable_tools(self, enabled: bool) -> Self
Enable or disable the tools capability entirely.
Allow tools only for routes that carry at least one of the given tags.
This is the recommended way to safely expose a curated surface to agents.
Sourcepub fn allow_path_prefix(self, prefix: impl Into<String>) -> Self
pub fn allow_path_prefix(self, prefix: impl Into<String>) -> Self
Add a path prefix that is allowed to be exposed as tools.
Sourcepub fn admin_token(self, token: impl Into<String>) -> Self
pub fn admin_token(self, token: impl Into<String>) -> Self
Require this token for MCP clients (discovery + calls).
Sourcepub fn expose_detailed_errors(self, expose: bool) -> Self
pub fn expose_detailed_errors(self, expose: bool) -> Self
Control whether tool responses include full internal error details.
Sourcepub fn invocation_mode(self, mode: InvocationMode) -> Self
pub fn invocation_mode(self, mode: InvocationMode) -> Self
Choose invocation strategy for tool calls.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for McpConfig
impl RefUnwindSafe for McpConfig
impl Send for McpConfig
impl Sync for McpConfig
impl Unpin for McpConfig
impl UnsafeUnpin for McpConfig
impl UnwindSafe for McpConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more