#[non_exhaustive]pub struct HttpConfig {
pub bind: SocketAddr,
pub path: String,
pub max_request_body_bytes: usize,
pub max_concurrent_sessions: usize,
}transport-http only.Expand description
Configuration for the HTTP transport.
Passed inside Transport::Http to control the TCP bind address and the
URL path the MCP service is mounted at.
§Note on DNS rebinding
rmcp’s StreamableHttpService validates the Host header against an
allow-list that defaults to loopback addresses only (localhost,
127.0.0.1, ::1). If you bind to 0.0.0.0 or a non-loopback address,
clients must send requests with a Host that matches the allow-list, or
use a reverse proxy that rewrites the Host header.
§Examples
use std::net::SocketAddr;
use mcpls_core::{HttpConfig, Transport};
let cfg = HttpConfig::new("127.0.0.1:3000".parse().unwrap(), "/mcp");
let transport = Transport::Http(cfg);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.bind: SocketAddrTCP address to bind (e.g. 127.0.0.1:3000).
path: StringURL path prefix the MCP service is mounted at (e.g. "/mcp").
max_request_body_bytes: usizeMaximum size, in bytes, of a single POST request body.
Enforced by rmcp’s StreamableHttpService while streaming the body,
independent of Content-Length or chunked transfer encoding. Requests
exceeding this limit receive 413 Payload Too Large. Defaults to
HttpConfig::DEFAULT_MAX_REQUEST_BODY_BYTES (4 MiB), which
comfortably covers MCP tool-call request bodies (large results, e.g.
from workspace/symbol or bulk edits, are returned in the response,
which this limit does not constrain). A value of 0 rejects every
POST body.
max_concurrent_sessions: usizeMaximum number of concurrent HTTP sessions.
This is a hard bound, enforced atomically at session creation via a
semaphore — never more than this many sessions can be active at once,
regardless of request concurrency.
Requests that would start a new session beyond this limit receive
429 Too Many Requests. Defaults to
HttpConfig::DEFAULT_MAX_CONCURRENT_SESSIONS. A value of 0
rejects every session.
Implementations§
Source§impl HttpConfig
impl HttpConfig
Sourcepub const DEFAULT_MAX_REQUEST_BODY_BYTES: usize
pub const DEFAULT_MAX_REQUEST_BODY_BYTES: usize
Default request body size cap (4 MiB), matching rmcp’s own default.
Sourcepub const DEFAULT_MAX_CONCURRENT_SESSIONS: usize = 100
pub const DEFAULT_MAX_CONCURRENT_SESSIONS: usize = 100
Default concurrent HTTP session cap.
Sourcepub fn new(bind: SocketAddr, path: impl Into<String>) -> Self
pub fn new(bind: SocketAddr, path: impl Into<String>) -> Self
Create an HttpConfig with default body-size and session caps.
§Examples
use mcpls_core::HttpConfig;
let cfg = HttpConfig::new("127.0.0.1:3000".parse().unwrap(), "/mcp");Sourcepub const fn with_max_request_body_bytes(self, bytes: usize) -> Self
pub const fn with_max_request_body_bytes(self, bytes: usize) -> Self
Override the maximum POST request body size in bytes.
Sourcepub const fn with_max_concurrent_sessions(self, max: usize) -> Self
pub const fn with_max_concurrent_sessions(self, max: usize) -> Self
Override the maximum number of concurrent HTTP sessions.