fastmcp/tests/server/http
Jeremiah Lowin 6330655809
Apply Host/Origin protection settings to the SSE transport (#5427)
`host_origin_protection`, `allowed_hosts`, and `allowed_origins` (and their `FASTMCP_HTTP_*` settings) now configure the legacy SSE transport the same way they configure Streamable HTTP. `create_sse_app()` accepts the three options, `http_app(transport="sse")` and `run(transport="sse")` forward them, and the request guard covers both the SSE connection endpoint and the message endpoint. `True`, `False`, and `"auto"` mean the same thing on both transports, so a server's Host/Origin policy is the same on either one.

Both app factories now build the guard through one shared helper, and the SSE transport passes explicit SDK security settings that leave Host/Origin validation to FastMCP, matching Streamable HTTP. The default stays `False`, so servers that don't opt in see no change. The deployment and settings docs now say the options apply to both transports.

```python
from fastmcp import FastMCP

mcp = FastMCP("My Server")

app = mcp.http_app(
    transport="sse",
    host_origin_protection=True,
    allowed_hosts=["mcp.example.com"],
)
```

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-04 10:14:50 -04:00
..
__init__.py clean up test inits 2025-05-31 19:32:08 -04:00
test_bearer_auth_backend.py Speed up the unit test suite, and fix the task-notification race it surfaced (#4550) 2026-07-19 18:52:04 -04:00
test_custom_routes.py Internal refactor of MCP handlers (#2005) 2025-10-05 08:45:10 -04:00
test_http_auth_middleware.py Speed up the unit test suite, and fix the task-notification race it surfaced (#4550) 2026-07-19 18:52:04 -04:00
test_http_dependencies.py Remove obsolete Docket memory fixtures (#4912) 2026-08-27 11:08:04 -05:00
test_http_middleware.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_lifespan_once_per_process.py Test lifespan fires once per process over HTTP (#4480) 2026-07-17 17:02:26 -04:00
test_routable_headers.py Support routable transport headers for gateways (SEP-2243) (#4622) 2026-07-26 13:40:09 -04:00
test_session_idle_timeout.py Make the unit suite fast: in-process HTTP tests, no real sleeps, parallel Windows CI (#4554) 2026-07-20 10:51:14 -04:00
test_session_owner_enforcement.py Drive the FastMCP lifespan through the SDK session manager (#4446) 2026-07-07 07:49:16 -04:00
test_sse_host_origin_protection.py Apply Host/Origin protection settings to the SSE transport (#5427) 2026-10-04 10:14:50 -04:00
test_stale_access_token.py Add subject field to AccessToken initialization (#4267) 2026-07-18 21:15:13 -04:00
test_startup_imports.py Avoid loading MCP and CLI stacks during lightweight imports (#4763) 2026-08-05 10:56:13 -04:00
test_streamable_http_shutdown.py fix(http): terminate active streamable-HTTP transports before lifespan shutdown (#4118) 2026-05-10 10:58:13 -04:00