CLI loses SSE/WebSocket MCP connection after session switch in sidebar
Description
When Claude Code CLI is launched from an IDE integration that uses CLAUDE_CODE_SSE_PORT (e.g., Emacs claude-code-ide.el), the CLI connects to the WebSocket MCP server on startup and registers tools like openDiff. However, after navigating to the session list (← arrow in sidebar), selecting another session, and returning — the CLI re-initializes MCP connections but only reconnects to the HTTP MCP server configured via --mcp-config. The SSE/WebSocket connection (from CLAUDE_CODE_SSE_PORT) is not re-established.
As a result, tools registered on the WebSocket server (openDiff, closeAllDiffTabs, close_tab) disappear, and features like ediff stop working.
Steps to Reproduce
- Launch Claude Code CLI from an IDE integration that uses
CLAUDE_CODE_SSE_PORTfor a WebSocket MCP server and--mcp-configfor an HTTP MCP server - Verify
openDifftool works (e.g., ediff appears on file edit) - Press ← to open the session list in the sidebar
- Select any other session
- Return to the original session
- Request a file edit — ediff no longer appears
Observed Behavior
After session switch, the CLI sends server/discover → initialize → tools/list to the HTTP MCP server only, which returns its tools (without openDiff). No reconnection attempt is made to the WebSocket server at CLAUDE_CODE_SSE_PORT. The environment variable is still present in the process — the CLI simply does not re-establish the connection.
Expected Behavior
After session switch, the CLI should reconnect to the SSE/WebSocket endpoint at CLAUDE_CODE_SSE_PORT in addition to the HTTP MCP server from --mcp-config, preserving all registered tools.
Environment
- Claude Code CLI (latest as of 2025-09-15)
- Emacs 30+ with
claude-code-idepackage - Linux
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗