Skip to content

MCP health pill not refreshed after disabling an MCP server via /mcp command #3895

@BZ-D

Description

@BZ-D

Bug Description

When a user manually disables an MCP server through the /mcp command, the Footer's MCP health pill continues to display "1 MCP offline" and does not refresh to reflect that the server was intentionally disabled.

However, performing mcp tool authenticate or clear authenticate on any MCP server causes the health pill to correctly re-render (showing the updated state).

Steps to Reproduce

  1. Have at least one MCP server configured and connected
  2. Disconnect/stop the MCP server externally so the health pill shows "1 MCP offline"
  3. Open /mcp dialog and disable that MCP server
  4. Observe: the health pill still shows "1 MCP offline" even though the server is now intentionally disabled

Expected Behavior

After disabling an MCP server via /mcp, the health pill should no longer count it as "offline" — it should either disappear (if no other servers are offline) or decrement the offline count.

Actual Behavior

The health pill persists showing "N MCP(s) offline" because the disabled server's entry remains in the global serverStatuses Map with status DISCONNECTED.

Root Cause Analysis

The global serverStatuses Map in packages/core/src/tools/mcp-client.ts only ever has entries added or updated (serverStatuses.set(...)) — entries are never removed (serverStatuses.delete(...) does not exist).

When disableMcpServer() is called:

  1. Tools and prompts are removed ✓
  2. MCPClientManager.disconnectServer() removes the client from this.clients
  3. McpClient.disconnect() sets status to DISCONNECTED in the global Map
  4. But the entry is never deleted from serverStatuses

As a result, useMCPHealth continues to count this server as disconnected, and the health pill keeps displaying.

The reason authenticate/clear-authenticate triggers a correct re-render is likely because those operations call updateMCPServerStatus with a new status that either reconnects or properly transitions the state.

Suggested Fix

Either:

  • Add a removeMCPServerStatus(serverName) function and call it in disconnectServer() when the server is being disabled (not just temporarily disconnected)
  • Or have useMCPHealth filter out servers that are in the config's exclusion/disabled list when computing disconnectedCount

Environment

  • OS: macOS
  • Qwen Code: latest main branch

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions