pub struct McpConfig {
pub host: String,
pub port: u16,
pub server_name: String,
pub no_auth: bool,
pub trusted_gateway: bool,
pub conformance_fixtures: bool,
pub api_token: Option<String>,
pub static_token_write: bool,
pub allowed_hosts: Vec<String>,
pub allowed_origins: Vec<String>,
pub trace_headers: TraceHeaderMode,
pub auth: AuthConfig,
}Expand description
MCP HTTP server configuration.
Fields§
§host: StringBind host (SOMA_MCP_HOST). Default: 127.0.0.1 (loopback).
Set to 0.0.0.0 to listen on all interfaces — requires auth configured.
port: u16Bind port (SOMA_MCP_PORT). Default: 40060.
server_name: StringMCP server name advertised to clients (SOMA_MCP_SERVER_NAME).
no_auth: boolDisable auth entirely — only safe when bound to loopback (SOMA_MCP_NO_AUTH).
trusted_gateway: boolAllow unauthenticated access on non-loopback when behind a trusted reverse proxy that enforces its own auth (SOMA_NOAUTH). Loaded here so it participates in typed config rather than being a raw env read at call sites.
conformance_fixtures: boolAdvertise official MCP conformance reference fixtures.
This is a test harness switch, not part of Soma’s production surface. Keep it false for real derived servers.
api_token: Option<String>Static bearer token for simple auth (SOMA_MCP_TOKEN).
static_token_write: boolGrant the static bearer token soma:write in addition to the
default soma:read (SOMA_MCP_STATIC_TOKEN_WRITE). Off by default so
a leaked static token cannot perform write actions unless the
operator explicitly opted in (pattern ported from cortex’s
static_token_is_admin).
allowed_hosts: Vec<String>Additional allowed Host header values (comma-separated in env).
allowed_origins: Vec<String>Additional allowed CORS origins (comma-separated in env).
trace_headers: TraceHeaderModeTrusted HTTP trace-header extraction mode (SOMA_MCP_TRACE_HEADERS).
Only meaningful when the resolved auth policy is a real trust boundary
(loopback bind or a trusted gateway) — see
soma_runtime::server::resolve_auth_policy_kind.
auth: AuthConfigOAuth sub-config (nested under [mcp.auth] in config.toml).
Implementations§
Source§impl McpConfig
impl McpConfig
pub fn bind_addr(&self) -> String
Sourcepub fn is_loopback(&self) -> bool
pub fn is_loopback(&self) -> bool
Return true if the configured bind host resolves to a loopback address.
Uses IpAddr::is_loopback() for numeric addresses. Accepts “localhost”
as a canonical loopback hostname. Any other hostname or parse failure is
treated as non-loopback — callers must not assume safety in that case.