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
{{ message }}
Repository navigation
Python: MCPStreamableHTTPTool cannot set mcp 2's max_sse_event_size, so tool results over 1 MiB fail #10222
With agent-framework-core 1.24.0 and mcp 2.3.0, a streamable HTTP MCP tool result larger than 1 MiB fails. It looks like a lost connection.
mcp 2 limits one SSE event to 1 MiB by default (mcp/client/streamable_http.py:61, DEFAULT_MAX_SSE_EVENT_SIZE = 1024 * 1024). streamable_http_client accepts max_sse_event_size, and None disables the limit (streamable_http.py:718, :735). mcp 1 had no such limit.
MCPStreamableHTTPTool.get_mcp_client (agent_framework/_mcp.py:4306) calls streamable_http_client(url=..., http_client=..., terminate_on_close=...) (:4417-4421). It passes no max_sse_event_size, and the tool has no parameter for it. So a caller cannot raise or lift the limit without overriding get_mcp_client.
Workaround we use
We subclass the tool and override get_mcp_client. It reads the arguments from the unentered context manager that super().get_mcp_client() returns (args/kwds), then calls streamable_http_client(**kwds, max_sse_event_size=None). This depends on a private detail of contextlib, and it breaks if the call's shape changes.
Ask
Add a max_sse_event_size: int | None parameter to MCPStreamableHTTPTool, passed through to streamable_http_client. Its default should be mcp's own default, so today's behaviour does not change.
Versions
agent-framework-core 1.24.0
mcp 2.3.0
Python 3.13
max_sse_event_size is also absent from _mcp.py in python-1.25.0 and on main (checked 2026-11-10).
One more detail for whoever triages this: the parameter only exists from mcp 2.3.0 (modelcontextprotocol/python-sdk#3600). In mcp 2.2.0, streamable_http_client has no max_sse_event_size, and the 1 MiB limit can't be changed. Core declares mcp>=2.2.0,<3, and only in the all extra, so simply passing the new keyword would break existing installs that run mcp 2.2.0.
The design I'd propose, keeping the current mcp range:
MCPStreamableHTTPTool(..., max_sse_event_size=...), with a sentinel default (typing_extensions.Sentinel, as _skills.py already does).
Omitted: the keyword isn't passed, so behaviour stays the same on every supported mcp version.
A positive int: passed through. None: passed through, which disables the limit (mcp's own semantics).
An explicit value is checked at construction:
<= 0 raises ValueError, the same way max_host_payload_size_bytes is validated.
If the installed mcp's streamable_http_client has no max_sse_event_size parameter, ValueError asks for mcp>=2.3.0.
Any explicit value together with mcp_client= joins the existing "framework-owned HTTP options" conflict error.
Tests: forwarding, validation and the conflict path, plus an SSE-response regression through the real mcp client: the default rejects a 2 MiB event, while None and a larger limit accept it.
Docs: the MCPStreamableHTTPTool docstring, plus the core README/AGENTS notes next to the other transport limits.
Does this direction look right to you? If it does, I'm happy to open a PR.
It covers the code, tests and the README/AGENTS notes. The tests pass on mcp 2.3.0 and on the declared floor, mcp 2.2.0. I'll open a PR from it once you're happy with the direction, or change it first if you'd prefer something else.
Activity
gian-alloy commentedon Nov 10, 2026
One more detail for whoever triages this: the parameter only exists from mcp 2.3.0 (modelcontextprotocol/python-sdk#3600). In mcp 2.2.0,
streamable_http_clienthas nomax_sse_event_size, and the 1 MiB limit can't be changed. Core declaresmcp>=2.2.0,<3, and only in theallextra, so simply passing the new keyword would break existing installs that run mcp 2.2.0.The design I'd propose, keeping the current mcp range:
MCPStreamableHTTPTool(..., max_sse_event_size=...), with a sentinel default (typing_extensions.Sentinel, as_skills.pyalready does).int: passed through.None: passed through, which disables the limit (mcp's own semantics).<= 0raisesValueError, the same waymax_host_payload_size_bytesis validated.streamable_http_clienthas nomax_sse_event_sizeparameter,ValueErrorasks for mcp>=2.3.0.mcp_client=joins the existing "framework-owned HTTP options" conflict error.Noneand a larger limit accept it.MCPStreamableHTTPTooldocstring, plus the core README/AGENTS notes next to the other transport limits.Does this direction look right to you? If it does, I'm happy to open a PR.
gian-alloy commentedon Nov 10, 2026
In case it helps triage, the design above is already implemented on a branch (one commit, no PR yet):
main...gian-alloy:agent-framework:python-mcp-max-sse-event-size
It covers the code, tests and the README/AGENTS notes. The tests pass on mcp 2.3.0 and on the declared floor, mcp 2.2.0. I'll open a PR from it once you're happy with the direction, or change it first if you'd prefer something else.