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
- Have at least one MCP server configured and connected
- Disconnect/stop the MCP server externally so the health pill shows "1 MCP offline"
- Open
/mcp dialog and disable that MCP server
- 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:
- Tools and prompts are removed ✓
MCPClientManager.disconnectServer() removes the client from this.clients ✓
McpClient.disconnect() sets status to DISCONNECTED in the global Map
- 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
Bug Description
When a user manually disables an MCP server through the
/mcpcommand, 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 authenticateorclear authenticateon any MCP server causes the health pill to correctly re-render (showing the updated state).Steps to Reproduce
/mcpdialog and disable that MCP serverExpected 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
serverStatusesMap with statusDISCONNECTED.Root Cause Analysis
The global
serverStatusesMap inpackages/core/src/tools/mcp-client.tsonly ever has entries added or updated (serverStatuses.set(...)) — entries are never removed (serverStatuses.delete(...)does not exist).When
disableMcpServer()is called:MCPClientManager.disconnectServer()removes the client fromthis.clients✓McpClient.disconnect()sets status toDISCONNECTEDin the global MapserverStatusesAs a result,
useMCPHealthcontinues 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
updateMCPServerStatuswith a new status that either reconnects or properly transitions the state.Suggested Fix
Either:
removeMCPServerStatus(serverName)function and call it indisconnectServer()when the server is being disabled (not just temporarily disconnected)useMCPHealthfilter out servers that are in the config's exclusion/disabled list when computingdisconnectedCountEnvironment