claude-code - 💡(How to fix) Fix [Bug] Claude in Chrome: CLI MCP client never connects to bridge socket when Desktop is also installed [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45318Fetched 2026-04-09 08:08:07
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Root Cause

Root Cause Analysis

Fix Action

Fix / Workaround

Workaround: Renaming Desktop's native messaging host config to .bak forces the extension to fall through to the CLI host. After this, Chrome correctly spawns the CLI's native host (~/.local/share/claude/versions/2.1.96 --chrome-native-host).

  1. Have both Claude Desktop and Claude Code CLI installed on macOS
  2. Install Claude in Chrome extension (1.0.66)
  3. From CLI: run /chrome — shows Status: Enabled, Extension: Installed
  4. Call any mcp__claude-in-chrome__* tool → "Browser extension is not connected"
  5. Workaround Issue 1 by renaming Desktop's host config:
    mv ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json{,.bak}
  6. Restart Chrome, click extension icon to trigger connectNative()
  7. Verify CLI native host is running and bridge socket exists with correct permissions
  8. Call mcp__claude-in-chrome__* again → still "Browser extension is not connected"
  9. lsof confirms CLI process never connects to the bridge socket

Code Example

const s = [
  {name: "com.anthropic.claude_browser_extension", label: "Desktop"},
  {name: "com.anthropic.claude_code_browser_extension", label: "Claude Code"}
];
for (const a of s) {
  const t = chrome.runtime.connectNative(a.name);
  if (await pingSucceeds(t)) {
    return true;  // stops here, never tries CLI host
  }
}

---

PID 38302: /Users/.../.local/share/claude/versions/2.1.96 --chrome-native-host

---

/tmp/claude-mcp-browser-bridge-eugene/38302.sock
   Directory: 0o700 (correct), Socket: 0o600 (correct), Owner: matches current user

---

sock.connect('/tmp/claude-mcp-browser-bridge-eugene/38302.sock')
   # Sends: {"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}
   # Receives: {"result":{"content":"Unknown method: tools/list"}}

---

$ lsof /tmp/claude-mcp-browser-bridge-eugene/38302.sock
   COMMAND   PID   USER   FD   TYPE
   2.1.96  38302 eugene    4u  unix  ...  # only the native host itself
   # CLI process is absent — never connected

---

mv ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json{,.bak}
RAW_BUFFERClick to expand / collapse

Environment

  • Claude Code: 2.1.96
  • Chrome extension: 1.0.66
  • macOS: 15.7.2 (Darwin 24.6.0, Apple Silicon)
  • Chrome: 146.0.7680.178
  • Claude Desktop: also installed

Problem

Claude in Chrome tools (mcp__claude-in-chrome__*) always return "Browser extension is not connected" from Claude Code CLI, even though the bridge socket is fully functional.

Root Cause Analysis

Issue 1: Desktop always wins the native messaging connection

The Chrome extension's service worker iterates hosts in a fixed order and returns on first success:

const s = [
  {name: "com.anthropic.claude_browser_extension", label: "Desktop"},
  {name: "com.anthropic.claude_code_browser_extension", label: "Claude Code"}
];
for (const a of s) {
  const t = chrome.runtime.connectNative(a.name);
  if (await pingSucceeds(t)) {
    return true;  // stops here, never tries CLI host
  }
}

Desktop's binary at /Applications/Claude.app/Contents/Helpers/chrome-native-host always exists and responds to ping — even when the Desktop app is not running — because Chrome spawns it as its own child process. CLI host is never tried.

Workaround: Renaming Desktop's native messaging host config to .bak forces the extension to fall through to the CLI host. After this, Chrome correctly spawns the CLI's native host (~/.local/share/claude/versions/2.1.96 --chrome-native-host).

Issue 2: CLI MCP client doesn't connect to bridge socket (the real bug)

Even after fixing Issue 1 so that the CLI's native host is running and the bridge socket exists, the CLI process never connects to it.

Diagnostic evidence:

  1. Native host running correctly (CLI binary):

    PID 38302: /Users/.../.local/share/claude/versions/2.1.96 --chrome-native-host
  2. Bridge socket exists with correct permissions:

    /tmp/claude-mcp-browser-bridge-eugene/38302.sock
    Directory: 0o700 (correct), Socket: 0o600 (correct), Owner: matches current user
  3. Socket is functional — Python test connects and gets response:

    sock.connect('/tmp/claude-mcp-browser-bridge-eugene/38302.sock')
    # Sends: {"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}
    # Receives: {"result":{"content":"Unknown method: tools/list"}}
  4. CLI process has NO connection to the socket:

    $ lsof /tmp/claude-mcp-browser-bridge-eugene/38302.sock
    COMMAND   PID   USER   FD   TYPE
    2.1.96  38302 eugene    4u  unix  ...  # only the native host itself
    # CLI process is absent — never connected
  5. /chrome → Reconnect Extension does not establish CLI-to-bridge connection. It appears to only signal the Chrome extension side, not the CLI's MCP client.

  6. Fresh sessions also fail — tested with a brand new claude session (not resume). Same result.

  7. CLI binary contains correct discovery logic — decompiled code shows it scans both os.tmpdir() and /tmp/ for .sock files in claude-mcp-browser-bridge-{username} directory. Security validation logic matches the actual file permissions. But connect() is never called on the discovered sockets.

Steps to Reproduce

  1. Have both Claude Desktop and Claude Code CLI installed on macOS
  2. Install Claude in Chrome extension (1.0.66)
  3. From CLI: run /chrome — shows Status: Enabled, Extension: Installed
  4. Call any mcp__claude-in-chrome__* tool → "Browser extension is not connected"
  5. Workaround Issue 1 by renaming Desktop's host config:
    mv ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json{,.bak}
  6. Restart Chrome, click extension icon to trigger connectNative()
  7. Verify CLI native host is running and bridge socket exists with correct permissions
  8. Call mcp__claude-in-chrome__* again → still "Browser extension is not connected"
  9. lsof confirms CLI process never connects to the bridge socket

Expected Behavior

  1. Extension should support connecting to both Desktop and CLI hosts simultaneously (or provide a user-facing toggle)
  2. CLI's MCP client should connect to the bridge socket when it exists and passes security validation

Related Issues

#20316, #33483, #29057, #20298, #20341, #20943

extent analysis

TL;DR

The most likely fix involves modifying the CLI's MCP client to connect to the bridge socket after the Chrome extension's service worker is configured to try the CLI host.

Guidance

  1. Verify the workaround for Issue 1: Rename Desktop's native messaging host config to force the extension to fall through to the CLI host, ensuring the CLI's native host is running.
  2. Investigate the CLI's MCP client connection logic: Review the decompiled code to understand why connect() is never called on the discovered bridge sockets, despite correct discovery logic.
  3. Check for potential security validation issues: Ensure the CLI's MCP client security validation matches the actual file permissions of the bridge socket.
  4. Test with a fresh session: Verify the issue persists with a brand new claude session to rule out any session-specific issues.

Example

No code snippet is provided due to the complexity of the issue and the need for further investigation into the CLI's MCP client connection logic.

Notes

The provided information suggests a potential issue with the CLI's MCP client connection logic. However, without access to the decompiled code or further diagnostic evidence, it is challenging to provide a definitive solution.

Recommendation

Apply a workaround by modifying the Chrome extension's service worker to prioritize the CLI host or provide a user-facing toggle to switch between Desktop and CLI hosts. This may involve updating the s array in the service worker to prioritize the CLI host or adding a toggle to allow users to switch between hosts.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING