Skip to content

Python: MCPStreamableHTTPTool cannot set mcp 2's max_sse_event_size, so tool results over 1 MiB fail #10222

Open

Description

Problem

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).

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 10, 2026
  2. gian-alloy commented on Nov 10, 2026

    @gian-alloy
    Author

    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.

  3. gian-alloy commented on Nov 10, 2026

    @gian-alloy
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: PythontriageUsage: [Issues], Target: All issues that still need to be triaged

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions