pub struct McpSseServerConfig {
pub name: String,
pub url: String,
pub headers: BTreeMap<String, SecretString>,
pub allow_plaintext_credentials: bool,
pub limits: McpSseLimits,
}Expand description
Configuration for an MCP server reachable over the legacy HTTP+SSE transport.
This is the SSE counterpart to McpServerConfig,
which remains the stdio configuration type.
§Example
use mentra::mcp::McpSseServerConfig;
let config = McpSseServerConfig::new("observability", "https://mcp.example.com/sse")
.with_header("authorization", "Bearer <token>");§Security
Header values are stored as SecretString and never appear in Debug
output, error messages, or logs. Configuring a header on a plaintext http://
URL is rejected unless the host is loopback, because the credential would
otherwise cross the network in the clear; see
allow_plaintext_credentials to
override that deliberately.
Fields§
§name: StringDisplay name for the server, used to namespace its bridged tools.
url: StringThe operator-configured SSE stream URL, opened with a long-lived GET.
headers: BTreeMap<String, SecretString>Headers sent on both the SSE GET and every JSON-RPC POST.
allow_plaintext_credentials: boolPermits sending configured headers over plaintext http:// to a
non-loopback host.
This exists so the refusal is overridable but never accidental.
limits: McpSseLimitsTimeouts and size limits, defaulted rather than deserialized.
Implementations§
Source§impl McpSseServerConfig
impl McpSseServerConfig
Sourcepub fn new(
name: impl Into<String>,
url: impl Into<String>,
) -> McpSseServerConfig
pub fn new( name: impl Into<String>, url: impl Into<String>, ) -> McpSseServerConfig
Creates a configuration with default timeouts and limits.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<SecretString>,
) -> McpSseServerConfig
pub fn with_header( self, name: impl Into<String>, value: impl Into<SecretString>, ) -> McpSseServerConfig
Adds a header sent on both the SSE GET and every JSON-RPC POST.
Sourcepub fn with_bearer_token(self, token: impl Into<String>) -> McpSseServerConfig
pub fn with_bearer_token(self, token: impl Into<String>) -> McpSseServerConfig
Adds a bearer Authorization header.
Sourcepub fn with_limits(self, limits: McpSseLimits) -> McpSseServerConfig
pub fn with_limits(self, limits: McpSseLimits) -> McpSseServerConfig
Replaces the timeouts and size limits.
Sourcepub fn allowing_plaintext_credentials(self) -> McpSseServerConfig
pub fn allowing_plaintext_credentials(self) -> McpSseServerConfig
Permits sending configured headers over plaintext http://.
Sourcepub fn validate(&self) -> Result<Url, McpSseConfigError>
pub fn validate(&self) -> Result<Url, McpSseConfigError>
Validates the configuration and returns the parsed stream URL.
Runs before any connection is opened so a bad configuration fails at the boundary rather than mid-handshake. Checks the URL, header names, and credential handling without connecting, so a host can reject a bad configuration at its own boundary rather than discovering it mid-build.
Trait Implementations§
Source§impl Clone for McpSseServerConfig
impl Clone for McpSseServerConfig
Source§fn clone(&self) -> McpSseServerConfig
fn clone(&self) -> McpSseServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more