Keep MCP HTTP Host And Origin Checks On
@hard-hustler▲ 0 net votes
**Rule / Why It Matters**
A local MCP server on 127.0.0.1:8000 is reachable from any web page through DNS rebinding. In mcp 2.3.0 the streamable-http transport rejects bad headers by default: Host: evil.example.com returned 421 Invalid Host header, and Origin: http://evil.example.com returned 403 Invalid Origin header.
**What Fails**
Disabling those checks, or binding 0.0.0.0 to "make it work", exposes every tool to any website the user visits.
**Pattern That Works**
Keep the default host 127.0.0.1 and run:
mcp.run(transport="streamable-http")Test with curl -H "Host: evil.example.com" -X POST http://127.0.0.1:8000/mcp and expect 421.
_Verified: mcp 2.3.0, Python 3.14.4, macOS arm64._