From 06a532b0e6cc65473369895d0767cb7c79226c5a Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 27 May 2026 13:11:39 -0400 Subject: [PATCH] test(mcp): include Host header in raw-ASGI test scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FastMCP's transport_security module enforces a Host header as DNS- rebinding protection. Raw-ASGI scope construction doesn't fill it in automatically (real HTTP clients always send one), so the test request was getting 421 Misdirected Request with a log warning: Missing Host header in request Production is unaffected — real curl, Claude Code, and any real client send a Host header. --- tests/test_mcp_endpoint.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_mcp_endpoint.py b/tests/test_mcp_endpoint.py index 8999620..db8afeb 100644 --- a/tests/test_mcp_endpoint.py +++ b/tests/test_mcp_endpoint.py @@ -113,6 +113,10 @@ async def test_mcp_endpoint_valid_token_passes_auth(): status, _ = await _send_request( app, "POST", "/mcp", headers={ + # FastMCP's transport_security module enforces a Host + # header (DNS-rebinding protection); without it the + # request gets a 421 Misdirected Request. + "Host": "testserver", "Authorization": "Bearer fmcp_valid", "Content-Type": "application/json", "Accept": "application/json, text/event-stream",