MCP Python SDK: Unbounded Session Accumulation in StreamableHTTP Transport Enables Resource Exhaustion
What fixes it
- 1.30.0mcp, pipGitHub
- 2.2.0mcp, pipGitHub
- 1.30.0mcp, PyPIOSV
pip install "mcp>=1.30.0" - 2.2.0mcp, PyPIOSV
pip install "mcp>=2.2.0"
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Summary
In affected versions, a Streamable HTTP server in stateful mode (the default) never reclaimed session state:
- sessions did not expire;
- a client
DELETEended the session but left its entry registered; - a session whose first request was refused stayed registered with a running task.
Each session also kept its parsed initialize parameters, and the number of sessions was unlimited. A client that could reach the endpoint could grow server memory without bound using ordinary short requests; only a restart reclaimed it.
Am I affected?
Yes, if you serve MCP over Streamable HTTP in stateful mode and clients you do not fully trust can reach the endpoint. Stateful mode is the default for:
FastMCP(1.x)MCPServerandServer.streamable_http_app()(2.x)StreamableHTTPSessionManager
Affected versions: 1.8.0 through 1.29.1, and 2.0.0 through 2.1.1.
Not affected:
- servers on 1.12.0 or later passing
stateless_http=True(no sessions are kept) - servers using only the stdio or SSE transports
Authentication limits who can open sessions, not how many a token holder can open.
Fix
Upgrade to mcp 1.30.0 (1.x) or 2.2.0 (2.x) or later. In those versions:
- a session with no request in flight for
session_idle_timeoutseconds (default 1800) is closed and its ID then answers404; open streams and in-progress requests keep it alive; - at most
max_sessionssessions exist at once (default 10000); a request that would open another is answered503; - a session is discarded as soon as it ends, whether by
DELETE, expiry, or a refused opening request.
Both settings are keyword arguments on FastMCP(...) (1.x), MCPServer.run() / streamable_http_app() (2.x) and StreamableHTTPSessionManager; None disables them.
This bounds retention rather than eliminating it: a live session still holds its initialize parameters (up to roughly twice the 4 MiB body limit), and an initialize with invalid parameters still opens a session that expires like any other. On a small host, lower session_idle_timeout, max_sessions and max_request_body_size to fit.
If you cannot upgrade yet, pass stateless_http=True (1.12.0 or later) where you need no per-session state, or restrict who can reach the endpoint.
Text from GitHub Advisory Database
Affected versions 53
- mcp, pip>= 1.8.0, < 1.30.0GitHub
- mcp, pip>= 2.0.0, < 2.2.0GitHub
- python-sdkaffected: >= 1.8.0, < 1.30.0CVE List
- python-sdkaffected: >= 2.0.0, < 2.2.0CVE List
- mcp, PyPIfrom 1.8.0, fixed in 1.30.0OSV
- mcp, PyPI1.10.0OSV
- mcp, PyPI1.10.1OSV
- mcp, PyPI1.11.0OSV
- mcp, PyPI1.12.0OSV
- mcp, PyPI1.12.1OSV
- mcp, PyPI1.12.2OSV
- mcp, PyPI1.12.3OSV
- mcp, PyPI1.12.4OSV
- mcp, PyPI1.13.0OSV
- mcp, PyPI1.13.1OSV
- mcp, PyPI1.14.0OSV
- mcp, PyPI1.14.1OSV
- mcp, PyPI1.15.0OSV
- mcp, PyPI1.16.0OSV
- mcp, PyPI1.17.0OSV
- mcp, PyPI1.18.0OSV
- mcp, PyPI1.19.0OSV
- mcp, PyPI1.20.0OSV
- mcp, PyPI1.21.0OSV
- mcp, PyPI1.21.1OSV
- mcp, PyPI1.21.2OSV
- mcp, PyPI1.22.0OSV
- mcp, PyPI1.23.0OSV
- mcp, PyPI1.23.1OSV
- mcp, PyPI1.23.2OSV
- mcp, PyPI1.23.3OSV
- mcp, PyPI1.24.0OSV
- mcp, PyPI1.25.0OSV
- mcp, PyPI1.26.0OSV
- mcp, PyPI1.27.0OSV
- mcp, PyPI1.27.1OSV
- mcp, PyPI1.27.2OSV
- mcp, PyPI1.28.0OSV
- mcp, PyPI1.28.1OSV
- mcp, PyPI1.29.0OSV
- mcp, PyPI1.29.1OSV
- mcp, PyPI1.8.0OSV
- mcp, PyPI1.8.1OSV
- mcp, PyPI1.9.0OSV
- mcp, PyPI1.9.1OSV
- mcp, PyPI1.9.2OSV
- mcp, PyPI1.9.3OSV
- mcp, PyPI1.9.4OSV
- mcp, PyPIfrom 2.0.0, fixed in 2.2.0OSV
- mcp, PyPI2.0.0OSV
- mcp, PyPI2.0.1OSV
- mcp, PyPI2.1.0OSV
- mcp, PyPI2.1.1OSV
References 9
- github.com/modelcontextprotocol/python-sdk/commit/92120b4b0f50385af096592d7cee932fc1d994e7Fixvia CVE List
- github.com/modelcontextprotocol/python-sdk/commit/d2290ca3434731b68ea3e2270bc06a6e6575931bFixvia CVE List
- github.com/modelcontextprotocol/python-sdk/releases/tag/v1.30.0Fixvia CVE List
- github.com/modelcontextprotocol/python-sdk/releases/tag/v2.2.0Fixvia CVE List
- github.com/modelcontextprotocol/python-sdk/security/advisories/GHSA-84m7-p3x7-pcfvAdvisoryvia CVE List
- github.com/advisories/GHSA-84m7-p3x7-pcfvAdvisoryvia GitHub
- nvd.nist.gov/vuln/detail/CVE-2026-59951Referencevia GitHub
- github.com/modelcontextprotocol/python-sdk/pull/3395Referencevia CVE List
- github.com/modelcontextprotocol/python-sdk/pull/3426Referencevia CVE List