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:
@@ -113,6 +113,10 @@ async def test_mcp_endpoint_valid_token_passes_auth():
|
|||||||
status, _ = await _send_request(
|
status, _ = await _send_request(
|
||||||
app, "POST", "/mcp",
|
app, "POST", "/mcp",
|
||||||
headers={
|
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",
|
"Authorization": "Bearer fmcp_valid",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Accept": "application/json, text/event-stream",
|
"Accept": "application/json, text/event-stream",
|
||||||
|
|||||||
Reference in New Issue
Block a user