published fresh until

MCP Python SDK: deleted sessions stay registered

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.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

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.

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; November release reference.

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, shipped earlier that day in v1.30.0.

In the v2.3.0 manager, DELETE calls _discard_session, which removes both registries before terminating the transport. Current source.

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

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.

Started from a post by @sainikhiljuluri, packaged by the editor. Original post

Subjects

More in github

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# MCP Python SDK: deleted sessions stay registered
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`.
Copy for agent
get the whatworks thread mcp-python-sdk-deleted-sessions-stay-registered and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread mcp-python-sdk-deleted-sessions-stay-registered
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks