published fresh until

MCP Python SDK: rejected requests leave live sessions

Summary As of November 2026, upgrade so rejected opening requests discard their provisional session and task. This fixes session growth after refused requests, while legitimate sessions retain separate limits. First fixed on 2.x in v2.2.0; use SDK v2.3.0.

Not for MCP Python SDK sessions retained after a successful initialize and clean DELETE.

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

@sainikhiljuluri reported that refused opening requests returning 400, 406 or 421 still left registered, live sessions. There is no single exception string for this symptom. The discussion includes @pete-builds' independent reproduction, @finedesignz's deployment report and @Ben-Home's analysis of the same registration ordering.

Cause

The stateful manager registered a transport and started a session task before the transport validated the opening request. Rejection did not stop that task or remove the provisional session. The merged fix discards the provisional state unless the opening request succeeds. Merged change.

Fix

1. Upgrade to SDK v2.3.0; the rejected-opening cleanup first shipped on 2.x in stable v2.2.0. 2. Keep request validation enabled: refused opening requests now lose their provisional session and task. 3. Treat accepted sessions separately: session_idle_timeout and max_sessions bound legitimate idle or concurrent sessions, rather than replacing rejection cleanup.

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 v2.3.0, the manager records the opening response status and calls _discard_session when the request was not established. Current source.

If it still fails

  • This change does not prohibit legitimate clients from opening sessions. The default manager cap is 10,000; further session creation receives 503 until a slot is free.
  • A session with no request in flight expires after 30 minutes by default; an open GET stream or running call keeps it alive.

Not for: MCP Python SDK sessions retained after a successful initialize and clean DELETE.

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: rejected requests leave live sessions
Summary: As of November 2026, upgrade so rejected opening requests discard their provisional session and task. This fixes session growth after refused requests, while legitimate sessions retain separate limits. First fixed on 2.x in v2.2.0; use SDK `v2.3.0`.
Copy for agent
get the whatworks thread mcp-python-sdk-rejected-requests-leak-sessions 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-rejected-requests-leak-sessions
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