Share error_response and default host allowlist; drop AppResult

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YShymaPrXmc3KYRUg2HMSs
This commit is contained in:
ariandClaude Sonnet 5.5 committed 2026-10-16 08:57:21 -04:00
1 parent 66eb91bf01
commit d022ebeae5
5 files changed
+38 -60

No files matched your search

+4 -11
View File
@@ -1,7 +1,7 @@
//! MCP server (WS-F). Tools, prompts and resources are thin projections over
//! MCP server. Tools, prompts and resources are thin projections over
//! the `sources` traits; nothing here talks to D-Bus, journald or Docker.
//!
//! Pinned `rmcp` 3.5.1 validates `Host` and `Origin` itself (DEC-8); `service`
//! Pinned `rmcp` 3.5.1 validates `Host` and `Origin` itself; `service`
//! feeds it loopback names, `server.bind` and the configured extras.
pub mod prompts;
@@ -400,13 +400,7 @@ fn authority(ip: IpAddr) -> String {
/// Allowed `Host` values: loopback names, `server.bind`, plus configured extras.
fn allowed_hosts(state: &AppState) -> Vec<String> {
let s = &state.config.server;
let mut v: Vec<String> = ["localhost", "127.0.0.1", "::1"]
.into_iter()
.map(String::from)
.collect();
if !s.bind.is_unspecified() {
v.push(s.bind.to_string());
}
let mut v = s.default_hosts();
v.extend(s.allowed_hosts.iter().cloned());
v
}
@@ -433,7 +427,7 @@ fn allowed_origins(state: &AppState) -> Vec<String> {
v
}
/// Streamable HTTP config with Host/Origin validation (DEC-8).
/// Streamable HTTP config with Host/Origin validation.
fn http_config(state: &AppState) -> StreamableHttpServerConfig {
StreamableHttpServerConfig::default()
.with_allowed_hosts(allowed_hosts(state))
@@ -541,7 +535,6 @@ mod tests {
assert!(info.capabilities.tools.is_some());
assert!(info.capabilities.prompts.is_some());
let res = info.capabilities.resources.as_ref().unwrap();
// DEC-5: no subscriptions.
assert!(!res.subscribe.unwrap_or(false));
assert!(info.instructions.unwrap().contains("failed"));
}