test(mcp): include Host header in raw-ASGI test scope

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.
This commit is contained in:
2026-05-27 13:11:39 -04:00
parent 65d3711a11
commit 06a532b0e6
+4
View File
@@ -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",