pub struct McpStreamableHttpServerConfig {
pub name: String,
pub url: String,
pub headers: BTreeMap<String, SecretString>,
pub allow_plaintext_credentials: bool,
pub limits: McpStreamableHttpLimits,
}Expand description
Configuration for an MCP server reachable over the Streamable HTTP transport.
This is the transport from protocol revision 2025-03-26 and later, where one
URL serves every message. It is the counterpart to
McpServerConfig for stdio and
McpSseServerConfig for the legacy
HTTP+SSE transport.
§Example
use mentra::mcp::McpStreamableHttpServerConfig;
let config = McpStreamableHttpServerConfig::new("observability", "https://mcp.example.com/mcp")
.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 MCP endpoint, which serves every request.
headers: BTreeMap<String, SecretString>Headers sent on every request to the endpoint.
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: McpStreamableHttpLimitsTimeouts and size limits, defaulted rather than deserialized.
Implementations§
Source§impl McpStreamableHttpServerConfig
impl McpStreamableHttpServerConfig
Sourcepub fn new(
name: impl Into<String>,
url: impl Into<String>,
) -> McpStreamableHttpServerConfig
pub fn new( name: impl Into<String>, url: impl Into<String>, ) -> McpStreamableHttpServerConfig
Creates a configuration with default timeouts and limits.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<SecretString>,
) -> McpStreamableHttpServerConfig
pub fn with_header( self, name: impl Into<String>, value: impl Into<SecretString>, ) -> McpStreamableHttpServerConfig
Adds a header sent on every request to the endpoint.
Sourcepub fn with_bearer_token(
self,
token: impl Into<String>,
) -> McpStreamableHttpServerConfig
pub fn with_bearer_token( self, token: impl Into<String>, ) -> McpStreamableHttpServerConfig
Adds a bearer Authorization header.
Sourcepub fn with_limits(
self,
limits: McpStreamableHttpLimits,
) -> McpStreamableHttpServerConfig
pub fn with_limits( self, limits: McpStreamableHttpLimits, ) -> McpStreamableHttpServerConfig
Replaces the timeouts and size limits.
Sourcepub fn allowing_plaintext_credentials(self) -> McpStreamableHttpServerConfig
pub fn allowing_plaintext_credentials(self) -> McpStreamableHttpServerConfig
Permits sending configured headers over plaintext http://.
Sourcepub fn validate(&self) -> Result<Url, McpStreamableHttpConfigError>
pub fn validate(&self) -> Result<Url, McpStreamableHttpConfigError>
Validates the configuration and returns the parsed endpoint URL.
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-handshake.
Trait Implementations§
Source§impl Clone for McpStreamableHttpServerConfig
impl Clone for McpStreamableHttpServerConfig
Source§fn clone(&self) -> McpStreamableHttpServerConfig
fn clone(&self) -> McpStreamableHttpServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more