From f022368a76109f4c0b35b2983bf174843e8eb1d3 Mon Sep 17 00:00:00 2001 From: claude-bot-go Date: Wed, 22 Jul 2026 21:48:59 +0800 Subject: [PATCH] fix(filter): capture x-mcp-method and x-mcp-name header variants on_http_request_headers() previously only looked up the bare 'mcp-method' / 'mcp-name' headers. The MCP protocol also uses the 'x-mcp-method' / 'x-mcp-name' prefixed form (and clients sending 'X-MCP-Method' / 'MCP-Method' as documented in the milestone). proxy-wasm normalises header names to lowercase at the host boundary, so the lookup is case-insensitive once lowercased. This change adds a fallback chain: try 'x-mcp-method' first (prefixed form), then fall back to 'mcp-method'. Same pattern for mcp_name. No struct changes required (fields already exist). Existing tests pass unchanged; cargo build + cargo test green. Closes #79 --- crates/proxy-wasm-evidence/src/filter.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/proxy-wasm-evidence/src/filter.rs b/crates/proxy-wasm-evidence/src/filter.rs index 35d674a..eb6ab2f 100644 --- a/crates/proxy-wasm-evidence/src/filter.rs +++ b/crates/proxy-wasm-evidence/src/filter.rs @@ -124,8 +124,17 @@ impl HttpContext for EvidenceFilter { self.path = self.get_http_request_header(":path").unwrap_or_default(); self.trace_id = self.get_http_request_header(&self.config.trace_id_header); self.agent_id = self.get_http_request_header(&self.config.agent_id_header); - self.mcp_method = self.get_http_request_header("mcp-method"); - self.mcp_name = self.get_http_request_header("mcp-name"); + // Capture mcp_method from "x-mcp-method" (prefixed variant) or + // "mcp-method" (bare variant). proxy-wasm normalises header names to + // lowercase, so both "X-MCP-Method" and "MCP-Method" map to the same + // lookup key. + self.mcp_method = self + .get_http_request_header("x-mcp-method") + .or_else(|| self.get_http_request_header("mcp-method")); + // Capture mcp_name from "mcp-name" or "x-mcp-name". + self.mcp_name = self + .get_http_request_header("mcp-name") + .or_else(|| self.get_http_request_header("x-mcp-name")); Action::Continue }