You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[v1.x] Apply the request body limit to the SSE and OAuth endpoints
SseServerTransport now takes max_request_body_size (default 4 MiB, the
same default and validation as StreamableHTTPSessionManager) and answers
413 before session lookup or parsing when a request declares or streams a
larger body. The message endpoint only ever handled POST bodies, so it
now answers 405 (Allow: POST) to other methods instead of treating them
like a POST. FastMCP forwards its existing max_request_body_size setting
to the SSE transport, so one setting governs both HTTP transports.
The create_auth_routes endpoints (/token, /revoke, /register and
/authorize) are wrapped in RequestBodyLimitMiddleware at the route
declarations and answer 413 to bodies over the 4 MiB default before any
form or JSON parsing. On the CORS-enabled routes the limit sits inside the
CORS wrapper so a 413 still carries CORS headers; cors_middleware itself is
unchanged. The middleware no longer special-cases POST, since some of these
routes also accept OPTIONS or HEAD and their handlers read the body either
way.
Differences from the main change:
- FastMCP reuses its existing max_request_body_size setting for the SSE
app instead of adding keywords to sse_app()/run(); no new FastMCP
parameter.
- /register reads its body via request.json() on this line; the same
wrapper applies unchanged.
- Tests use httpx and this line's dict-based SSE scope helper.
Copy file name to clipboardExpand all lines: docs/server.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1253,7 +1253,7 @@ The FastMCP server instance accessible via `ctx.fastmcp` provides access to serv
1253
1253
-`host` and `port` - Server network configuration
1254
1254
-`mount_path`, `sse_path`, `streamable_http_path` - Transport paths
1255
1255
-`stateless_http` - Whether the server operates in stateless mode
1256
-
-`max_request_body_size` - Maximum Streamable HTTP POST body size in bytes
1256
+
-`max_request_body_size` - Maximum HTTP request body size in bytes (Streamable HTTP and SSE)
1257
1257
- And other configuration options
1258
1258
1259
1259
```python
@@ -1418,9 +1418,9 @@ Note that `uv run mcp run` or `uv run mcp dev` only supports server using FastMC
1418
1418
1419
1419
> **Note**: Streamable HTTP transport is the recommended transport for production deployments. Use `stateless_http=True` and `json_response=True` for optimal scalability.
1420
1420
1421
-
Streamable HTTP POST bodies are limited to 4 MiB by default. Larger requests receive HTTP 413
1422
-
before parsing or session creation. If your server intentionally accepts larger MCP messages,
1423
-
configure the smallest suitable byte limit:
1421
+
HTTP request bodies (Streamable HTTP and SSE) are limited to 4 MiB by default. Larger requests
1422
+
receive HTTP 413 before parsing or session creation. If your server intentionally accepts larger MCP
1423
+
messages, configure the smallest suitable byte limit:
0 commit comments