Stale deferred tool in session causes permanent 400 error after MCP server disconnect

Status Open
Reported on v2.1.220
Maintainer reply None cached
Activity 0 comments · opened Jul 28, 2026

Description

When an MCP server disconnects mid-session, its tools are removed from the active deferred-tools list — but some tools (specifically DesignSync in my case) are not cleaned up. The tool name remains in the deferred-tools system prompt injection for all subsequent turns, and the API rejects every request with a 400 because the tool is referenced but not in the actual tools array. The session becomes permanently broken with no way to recover it.

Steps to Reproduce

  1. Start a long-running session with MCP servers that provide deferred tools (e.g. a claude.ai MCP server providing DesignSync)
  2. During the session, run /mcp or otherwise cause some MCP servers to disconnect
  3. Observe that most of the disconnected server's tools are removed from the deferred-tools list via a deferred_tools_delta with removedNames
  4. Note that DesignSync (and possibly others) are not added to removedNames despite the server being gone
  5. Submit any prompt — every subsequent turn errors immediately

Error

API Error: 400 Tool reference 'DesignSync' not found in available tools

Expected Behavior

When an MCP server disconnects, all of its tools should be removed from the deferred-tools list. If any tool can't be cleanly removed, the session should degrade gracefully rather than becoming permanently broken.

Actual Behavior

The stale tool name persists in the deferred-tools injection for the lifetime of the session. Every API call fails with a 400. The session cannot be recovered — a new session must be started.

Environment

  • Claude Code version: 2.1.220
  • Platform: Windows 11 Enterprise
  • Session had been running for an extended period (~27 hours based on timestamps)
  • The DesignSync tool was initially added via a deferred_tools_delta attachment, then not removed when its MCP server disconnected

Suggested Fix

When processing MCP server disconnects, ensure all tools from that server are included in removedNames in the deferred_tools_delta. Additionally, consider making the deferred-tools validation in the API request more resilient so a single missing tool doesn't hard-break the entire session.

View original on GitHub ↗