Skip to content

About

Reproduction of MCP subscriptions/listen holding a serverless invocation open when disconnect propagation is missing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP subscriptions/listen serverless timeout reproduction

Minimal reproduction for the MCP Python SDK 2026-07-28 subscription lifecycle issue reported in modelcontextprotocol/python-sdk#3493.

What XBSTACK reproduced

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.

Run

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

Why it matters

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

Workaround boundary

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.

References

Related XBSTACK guide

License

MIT

About

Reproduction of MCP subscriptions/listen holding a serverless invocation open when disconnect propagation is missing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages