CLI loses SSE/WebSocket MCP connection after session switch in sidebar

Status Open
Maintainer reply None cached
Activity 1 comment · opened Sep 15, 2026

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

  1. Launch Claude Code CLI from an IDE integration that uses CLAUDE_CODE_SSE_PORT for a WebSocket MCP server and --mcp-config for an HTTP MCP server
  2. Verify openDiff tool works (e.g., ediff appears on file edit)
  3. Press ← to open the session list in the sidebar
  4. Select any other session
  5. Return to the original session
  6. 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-ide package
  • Linux

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗