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
Apply the request body limit to the SSE message endpoint
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 POST 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.
MCPServer.sse_app(), run_sse_async() and run(transport="sse") expose the
keyword, mirroring streamable_http_app().
Copy file name to clipboardExpand all lines: docs/migration.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -755,7 +755,7 @@ Transport-specific parameters have been moved off the `MCPServer` constructor an
755
755
-`sse_path`, `message_path` - SSE transport paths, on `run(transport="sse", ...)` and `sse_app()`
756
756
-`streamable_http_path` - StreamableHTTP endpoint path, on `run(transport="streamable-http", ...)` and `streamable_http_app()`
757
757
-`json_response`, `stateless_http` - StreamableHTTP behavior, same two places; each also removes a server-to-client channel, see [Server-initiated sampling, elicitation, and roots raise `NoBackChannelError`](#server-initiated-sampling-elicitation-and-roots-raise-nobackchannelerror)
758
-
-`max_request_body_size` - StreamableHTTP request-body limit, same two places
758
+
-`max_request_body_size` - HTTP request-body limit, on `run()` for both HTTP transports and on both app methods
759
759
-`event_store`, `retry_interval` - StreamableHTTP event handling, same two places
760
760
-`transport_security` - DNS rebinding protection, on `run()` for both HTTP transports and on both app methods
The limit must be positive and applies to both legacy session-based requests and V2's modern
861
861
single-exchange requests. Keep the smallest value your application actually needs.
862
862
863
+
The SSE transport's message endpoint applies the same limit, configured the same way
864
+
(`run(transport="sse", max_request_body_size=...)`, `sse_app(...)`, or
865
+
`SseServerTransport(..., max_request_body_size=...)` when you mount the transport yourself), and
866
+
answers HTTP 405 to anything other than POST.
867
+
863
868
### Streamable HTTP: lifespan now entered once at manager startup
864
869
865
870
When serving streamable HTTP (stateful or `stateless_http=True`), the server's `lifespan` context manager is now entered once when `StreamableHTTPSessionManager.run()` starts, and the resulting state is shared across all sessions and requests. Previously each session (stateful) or each request (stateless) entered and exited `lifespan` independently.
Copy file name to clipboardExpand all lines: docs/run/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ Each transport has its own keyword arguments, all on `run()`:
69
69
*`stateless_http=True`: a fresh transport per request, no session tracking.
70
70
*`max_request_body_size`: largest accepted POST body in bytes. Defaults to 4 MiB; larger requests
71
71
receive HTTP 413 before parsing or session creation. Raise it only when legitimate MCP messages
72
-
exceed that size.
72
+
exceed that size.`transport="sse"` takes the same keyword for its message endpoint.
73
73
*`event_store`, `retry_interval`, `transport_security`: resumability and DNS-rebinding protection. They can wait, until you deploy somewhere other than localhost; **[Deploy & scale](deploy.md)** covers `transport_security`.
0 commit comments