Minimal reproduction for the MCP Python SDK 2026-07-28 subscription lifecycle issue reported in modelcontextprotocol/python-sdk#3493.
Tested on 2026-09-20 on macOS arm64 with Python 3.12.
| SDK | server/discover | subscriptions/listen | Result |
|---|---|---|---|
| mcp 2.1.1 | completes; advertises listChanged/subscribe=true | remains open beyond 1.0 s with no disconnect | reproduced |
| mcp 2.2.0 | completes; advertises listChanged/subscribe=true | remains open beyond 1.0 s with no disconnect | reproduced |
| mcp 2.2.0 + private handler removal | completes; advertises listChanged/subscribe=false | immediately returns JSON-RPC -32601 | containment works |
The reproduction models a serverless adapter that does not propagate http.disconnect back into the ASGI app. It does not emulate AWS Lambda billing or claim every serverless platform behaves identically.
uv run --python 3.12 --with "mcp==2.2.0" python repro/repro.py
uv run --python 3.12 --with "mcp==2.1.1" python repro/repro.py
uv run --python 3.12 --with "mcp==2.2.0" python fixed/private-handler-removal.pyMCP 2026-07-28 uses a long-lived subscriptions/listen response stream for change notifications. A server that advertises those capabilities can cause a compatible client to open that stream even when the application never publishes changes. On a serverless platform that bills until the response closes and does not propagate disconnects, that lifecycle can pin an invocation until platform timeout.
The file in fixed/ reproduces the upstream private-attribute workaround:
mcp._lowlevel_server._request_handlers.pop("subscriptions/listen", None)This is not a supported public API and is not presented as the permanent fix. It is included only to demonstrate that removing the handler changes advertised capabilities and terminates the listen request immediately.
- modelcontextprotocol/python-sdk#3493
- modelcontextprotocol/python-sdk#3357
- modelcontextprotocol/typescript-sdk#2650
- https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http
- MCP Streamable HTTP production deployment and serverless lifecycle: https://www.xbstack.com/ai/mcp-streamable-http-deployment/?utm_source=github&utm_medium=referral&utm_campaign=mcp_subscriptions_listen_serverless&utm_content=repository_readme&ref=github
MIT