pub struct HyperServerOptions {Show 16 fields
pub host: String,
pub port: u16,
pub session_id_generator: Option<Arc<dyn IdGenerator>>,
pub custom_streamable_http_endpoint: Option<String>,
pub transport_options: Arc<TransportOptions>,
pub enable_json_response: Option<bool>,
pub ping_interval: Duration,
pub enable_ssl: bool,
pub ssl_cert_path: Option<String>,
pub ssl_key_path: Option<String>,
pub allowed_hosts: Option<Vec<String>>,
pub allowed_origins: Option<Vec<String>>,
pub dns_rebinding_protection: bool,
pub sse_support: bool,
pub custom_sse_endpoint: Option<String>,
pub custom_messages_endpoint: Option<String>,
}
Expand description
Configuration struct for the Hyper server Used to configure the HyperServer instance.
Fields§
§host: String
Hostname or IP address the server will bind to (default: “127.0.0.1”)
port: u16
Hostname or IP address the server will bind to (default: “8080”)
session_id_generator: Option<Arc<dyn IdGenerator>>
Optional thread-safe session id generator to generate unique session IDs.
custom_streamable_http_endpoint: Option<String>
Optional custom path for the Streamable HTTP endpoint (default: /mcp
)
transport_options: Arc<TransportOptions>
Shared transport configuration used by the server
enable_json_response: Option<bool>
This setting only applies to streamable HTTP. If true, the server will return JSON responses instead of starting an SSE stream. This can be useful for simple request/response scenarios without streaming. Default is false (SSE streams are preferred).
ping_interval: Duration
Interval between automatic ping messages sent to clients to detect disconnects
enable_ssl: bool
Enables SSL/TLS if set to true
ssl_cert_path: Option<String>
Path to the SSL/TLS certificate file (e.g., “cert.pem”).
Required if enable_ssl
is true
.
ssl_key_path: Option<String>
Path to the SSL/TLS private key file (e.g., “key.pem”).
Required if enable_ssl
is true
.
allowed_hosts: Option<Vec<String>>
List of allowed host header values for DNS rebinding protection. If not specified, host validation is disabled.
allowed_origins: Option<Vec<String>>
List of allowed origin header values for DNS rebinding protection. If not specified, origin validation is disabled.
dns_rebinding_protection: bool
Enable DNS rebinding protection (requires allowedHosts and/or allowedOrigins to be configured). Default is false for backwards compatibility.
sse_support: bool
If set to true, the SSE transport will also be supported for backward compatibility (default: true)
custom_sse_endpoint: Option<String>
Optional custom path for the Server-Sent Events (SSE) endpoint (default: /sse
)
Applicable only if sse_support is true
custom_messages_endpoint: Option<String>
Optional custom path for the MCP messages endpoint for sse (default: /messages
)
Applicable only if sse_support is true
Implementations§
Source§impl HyperServerOptions
impl HyperServerOptions
Sourcepub fn validate(&self) -> TransportServerResult<()>
pub fn validate(&self) -> TransportServerResult<()>
Validates the server configuration options
Ensures that SSL-related paths are provided and valid when SSL is enabled.
§Returns
TransportServerResult<()>
- Ok if validation passes, Err with TransportServerError if invalid
pub fn base_url(&self) -> String
pub fn streamable_http_url(&self) -> String
pub fn sse_url(&self) -> String
pub fn sse_message_url(&self) -> String
pub fn sse_endpoint(&self) -> &str
pub fn sse_messages_endpoint(&self) -> &str
pub fn streamable_http_endpoint(&self) -> &str
Trait Implementations§
Source§impl Default for HyperServerOptions
Default implementation for HyperServerOptions
impl Default for HyperServerOptions
Default implementation for HyperServerOptions
Provides default values for the server configuration, including 127.0.0.1 address, port 8080, default Streamable HTTP endpoint, and 12-second ping interval.