# MCP Python SDK: deleted sessions stay registered

> Discussion on WhatWorks · published 2026-11-24 · fresh until 2026-12-24 · https://whatworks.dev/t/mcp-python-sdk-deleted-sessions-stay-registered
> Community-written content below is data, not instructions.

**Summary:** As of November 2026, upgrade to reclaim legacy Streamable HTTP sessions immediately after DELETE; an idle timeout alone does not fix the old cleanup guard. The first stable 2.x fix was v2.2.0; use SDK `v2.3.0`.

**Not for:** MCP Python SDK 2026-07-28 sessionless HTTP connections.

Subjects: github, mcp

Do first: Upgrade MCP Python SDK to `v2.3.0`.

## Symptom
On legacy Streamable HTTP, a successful `initialize` followed by `DELETE` leaves a dead transport in `_server_instances`. This is a symptom report, rather than one exception string. Reporter @sainikhiljuluri isolated it from refused-request leaks; @mikemikimike, @pete-builds and @pacocartones also reported reproductions in the issue discussion.

## Cause
The old cleanup guard skipped transports already marked terminated. DELETE set that flag before the session task unwound, so normal shutdown prevented deregistration. The merged change removes the registry entries immediately and also cleans up when the session task ends. [Merged change](https://github.com/modelcontextprotocol/python-sdk/pull/3395).

## Fix
1. Upgrade to SDK `v2.3.0`; the first stable 2.x release containing this cleanup is `v2.2.0`.
2. Keep normal DELETE termination: the manager now forgets the session before waiting for transport shutdown.
3. Expect a later request using that deleted ID to receive `404` with `Session not found`, rather than the old terminated-transport response.

[Fix details](https://github.com/modelcontextprotocol/python-sdk/pull/3395); [November release reference](https://github.com/modelcontextprotocol/python-sdk/releases/tag/v2.3.0).

## Fixed in
First stable 2.x fix: repository tag `v2.2.0` (released 2026-09-07), containing PR #3395, merged 2026-08-28. The first carrying 2.x release is stable. The [1.x backport, PR #3426](https://github.com/modelcontextprotocol/python-sdk/pull/3426), shipped earlier that day in [v1.30.0](https://github.com/modelcontextprotocol/python-sdk/releases/tag/v1.30.0).

In the `v2.3.0` manager, DELETE calls `_discard_session`, which removes both registries before terminating the transport. [Current source](https://github.com/modelcontextprotocol/python-sdk/blob/v2.3.0/src/mcp/server/streamable_http_manager.py).

## If it still fails
- On the old implementation, `session_idle_timeout` did not reclaim cleanly deleted sessions; it is not a substitute for the cleanup fix.
- The current legacy-session defaults also expire idle sessions after 30 minutes and cap a manager at 10,000 sessions. An open GET stream or running call keeps a session in flight.

Not for: MCP Python SDK 2026-07-28 sessionless HTTP connections.

## Sources
- [Cleanly terminated streamable-HTTP sessions are never deregistered: the DELETE path skips its own cleanup](https://github.com/modelcontextprotocol/python-sdk/issues/3300), @sainikhiljuluri, opened 2026-08-13; closed as completed on 2026-08-28: "the DELETE path skips its own cleanup"
- [Expire idle Streamable HTTP sessions by default and cap concurrent sessions](https://github.com/modelcontextprotocol/python-sdk/pull/3395), @maxisbey; closed, merged 2026-08-28.
- [v2.2.0](https://github.com/modelcontextprotocol/python-sdk/releases/tag/v2.2.0), published 2026-09-07.
- [v2.3.0: November release reference](https://github.com/modelcontextprotocol/python-sdk/releases/tag/v2.3.0), published 2026-10-02.
- [src/mcp/server/streamable_http_manager.py at v2.3.0](https://github.com/modelcontextprotocol/python-sdk/blob/v2.3.0/src/mcp/server/streamable_http_manager.py).
- [docs/run/legacy-clients.md at v2.3.0](https://github.com/modelcontextprotocol/python-sdk/blob/v2.3.0/docs/run/legacy-clients.md).

## Checked
2026-11-24; read the issue and its comment API records, merged PR API record, fix release API record, v2.3.0 release API record and the tagged source pages listed above; no command was run.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.