Chrome Mcp Troubleshooting

作者 trailofbits82fe82262526無授權條款7.4K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫昨天更新

Diagnose and fix Claude in Chrome MCP extension connectivity issues. Use when mcp__claude-in-chrome__* tools fail, return "Browser extension is not connected", or behave erratically.

AI 產生的概覽

診斷並修復 macOS 上 Claude in Chrome MCP 擴充功能的連線問題,主要是原生主機衝突。

功能
提供以 macOS 為主的疑難排解指南,處理 Claude in Chrome MCP 瀏覽器工具無法連線或運作不穩定的情況。內容說明 Claude.app(Cowork)與 Claude Code CLI 原生訊息主機之間的衝突,以及兩者不相容的 socket 格式,並提供 shell 指令來停用其中一個設定、執行切換函式、檢查行程與 socket,以及進行完整重設。也涵蓋多個 Chrome 設定檔、多個 Claude Code 工作階段、包裝指令碼中寫死版本,以及未設定 TMPDIR 等其他原因。
適用情境
當 mcpclaude-in-chrome* 工具回報瀏覽器擴充功能未連線、逾時或運作不穩定時使用,尤其是在更新 Claude Code 或 Claude.app 之後,或在 CLI 與桌面應用程式之間切換時。不適用於 Linux 或 Windows、一般 Chrome 自動化問題、桌面應用程式問題、網路問題或擴充功能安裝問題。
執行需求
macOS 上的 Chrome 與 Claude 擴充功能,以及 Claude Code CLI 或 Claude.app;需要 shell 存取權限來執行 ps、lsof、pkill、mv、osascript、getconf 等指令。此技能未附帶指令碼,指令以說明形式提供。

Claude in Chrome MCP Troubleshooting

Use this skill when Claude in Chrome MCP tools fail to connect or work unreliably.

When to Use

  • mcp__claude-in-chrome__* tools fail with "Browser extension is not connected"
  • Browser automation works erratically or times out
  • After updating Claude Code or Claude.app
  • When switching between Claude Code CLI and Claude.app (Cowork)
  • Native host process is running but MCP tools still fail

When NOT to Use

  • Linux or Windows users - This skill covers macOS-specific paths and tools (~/Library/Application Support/, osascript)
  • General Chrome automation issues unrelated to the Claude extension
  • Claude.app desktop issues (not browser-related)
  • Network connectivity problems
  • Chrome extension installation issues (use Chrome Web Store support)

The Claude.app vs Claude Code Conflict (Primary Issue)

Background: When Claude.app added Cowork support (browser automation from the desktop app), it introduced a competing native messaging host that conflicts with Claude Code CLI.

Two Native Hosts, Two Socket Formats

ComponentNative Host BinarySocket Location
Claude.app (Cowork)/Applications/Claude.app/Contents/Helpers/chrome-native-host/tmp/claude-mcp-browser-bridge-$USER/<PID>.sock
Claude Code CLI~/.local/share/claude/versions/<version> --chrome-native-host$TMPDIR/claude-mcp-browser-bridge-$USER (single file)

Why They Conflict

  1. Both register native messaging configs in Chrome:

    • com.anthropic.claude_browser_extension.json → Claude.app helper
    • com.anthropic.claude_code_browser_extension.json → Claude Code wrapper
  2. Chrome extension requests a native host by name

  3. If the wrong config is active, the wrong binary runs

  4. The wrong binary creates sockets in a format/location the MCP client doesn't expect

  5. Result: "Browser extension is not connected" even though everything appears to be running

The Fix: Disable Claude.app's Native Host

If you use Claude Code CLI for browser automation (not Cowork):

bash
# Disable the Claude.app native messaging configmv ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json \   ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json.disabled
# Ensure the Claude Code config exists and points to the wrappercat ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_code_browser_extension.json

If you use Cowork (Claude.app) for browser automation:

bash
# Disable the Claude Code native messaging configmv ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_code_browser_extension.json \   ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_code_browser_extension.json.disabled

You cannot use both simultaneously. Pick one and disable the other.

Toggle Script

Add this to ~/.zshrc or run directly:

bash
chrome-mcp-toggle() {    local CONFIG_DIR=~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts    local CLAUDE_APP="$CONFIG_DIR/com.anthropic.claude_browser_extension.json"    local CLAUDE_CODE="$CONFIG_DIR/com.anthropic.claude_code_browser_extension.json"
    if [[ -f "$CLAUDE_APP" && ! -f "$CLAUDE_APP.disabled" ]]; then        # Currently using Claude.app, switch to Claude Code        mv "$CLAUDE_APP" "$CLAUDE_APP.disabled"        [[ -f "$CLAUDE_CODE.disabled" ]] && mv "$CLAUDE_CODE.disabled" "$CLAUDE_CODE"        echo "Switched to Claude Code CLI"        echo "Restart Chrome and Claude Code to apply"    elif [[ -f "$CLAUDE_CODE" && ! -f "$CLAUDE_CODE.disabled" ]]; then        # Currently using Claude Code, switch to Claude.app        mv "$CLAUDE_CODE" "$CLAUDE_CODE.disabled"        [[ -f "$CLAUDE_APP.disabled" ]] && mv "$CLAUDE_APP.disabled" "$CLAUDE_APP"        echo "Switched to Claude.app (Cowork)"        echo "Restart Chrome to apply"    else        echo "Current state unclear. Check configs:"        ls -la "$CONFIG_DIR"/com.anthropic*.json* 2>/dev/null    fi}

Usage: chrome-mcp-toggle then restart Chrome (and Claude Code if switching to CLI).

Quick Diagnosis

bash
# 1. Which native host binary is running?ps aux | grep chrome-native-host | grep -v grep# Claude.app: /Applications/Claude.app/Contents/Helpers/chrome-native-host# Claude Code: ~/.local/share/claude/versions/X.X.X --chrome-native-host
# 2. Where is the socket?# For Claude Code (single file in TMPDIR):ls -la "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER" 2>&1
# For Claude.app (directory with PID files):ls -la /tmp/claude-mcp-browser-bridge-$USER/ 2>&1
# 3. What's the native host connected to?lsof -U 2>&1 | grep claude-mcp-browser-bridge
# 4. Which configs are active?ls ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic*.json

Critical Insight

MCP connects at startup. If the browser bridge wasn't ready when Claude Code started, the connection will fail for the entire session. The fix is usually: ensure Chrome + extension are running with correct config, THEN restart Claude Code.

Full Reset Procedure (Claude Code CLI)

bash
# 1. Ensure correct config is activemv ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json \   ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json.disabled 2>/dev/null
# 2. Update the wrapper to use latest Claude Code versioncat > ~/.claude/chrome/chrome-native-host << 'EOF'#!/bin/bashLATEST=$(ls -t ~/.local/share/claude/versions/ 2>/dev/null | head -1)exec "$HOME/.local/share/claude/versions/$LATEST" --chrome-native-hostEOFchmod +x ~/.claude/chrome/chrome-native-host
# 3. Kill existing native host and clean socketspkill -f chrome-native-hostrm -rf /tmp/claude-mcp-browser-bridge-$USER/rm -f "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER"
# 4. Restart Chromeosascript -e 'quit app "Google Chrome"' && sleep 2 && open -a "Google Chrome"
# 5. Wait for Chrome, click Claude extension icon
# 6. Verify correct native host is runningps aux | grep chrome-native-host | grep -v grep# Should show: ~/.local/share/claude/versions/X.X.X --chrome-native-host
# 7. Verify socket existsls -la "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER"
# 8. Restart Claude Code

Other Common Causes

Multiple Chrome Profiles

If you have the Claude extension installed in multiple Chrome profiles, each spawns its own native host and socket. This can cause confusion.

Fix: Only enable the Claude extension in ONE Chrome profile.

Multiple Claude Code Sessions

Running multiple Claude Code instances can cause socket conflicts.

Fix: Only run one Claude Code session at a time, or use /mcp to reconnect after closing other sessions.

Hardcoded Version in Wrapper

The wrapper at ~/.claude/chrome/chrome-native-host may have a hardcoded version that becomes stale after updates.

Diagnosis:

bash
cat ~/.claude/chrome/chrome-native-host# Bad: exec "/Users/.../.local/share/claude/versions/2.0.76" --chrome-native-host# Good: Uses $(ls -t ...) to find latest

Fix: Use the dynamic version wrapper shown in the Full Reset Procedure above.

TMPDIR Not Set

Claude Code expects TMPDIR to be set to find the socket.

bash
# Checkecho $TMPDIR# Should show: /var/folders/XX/.../T/
# Fix: Add to ~/.zshrcexport TMPDIR="${TMPDIR:-$(getconf DARWIN_USER_TEMP_DIR)}"

Diagnostic Deep Dive

bash
echo "=== Native Host Binary ==="ps aux | grep chrome-native-host | grep -v grep
echo -e "\n=== Socket (Claude Code location) ==="ls -la "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER" 2>&1
echo -e "\n=== Socket (Claude.app location) ==="ls -la /tmp/claude-mcp-browser-bridge-$USER/ 2>&1
echo -e "\n=== Native Host Open Files ==="pgrep -f chrome-native-host | xargs -I {} lsof -p {} 2>/dev/null | grep -E "(sock|claude-mcp)"
echo -e "\n=== Active Native Messaging Configs ==="ls ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic*.json 2>/dev/null
echo -e "\n=== Custom Wrapper Contents ==="cat ~/.claude/chrome/chrome-native-host 2>/dev/null || echo "No custom wrapper"
echo -e "\n=== TMPDIR ==="echo "TMPDIR=$TMPDIR"echo "Expected: $(getconf DARWIN_USER_TEMP_DIR)"

File Reference

FilePurpose
~/.claude/chrome/chrome-native-hostCustom wrapper script for Claude Code
/Applications/Claude.app/Contents/Helpers/chrome-native-hostClaude.app (Cowork) native host
~/.local/share/claude/versions/<version>Claude Code binary (run with --chrome-native-host)
~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.jsonConfig for Claude.app native host
~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_code_browser_extension.jsonConfig for Claude Code native host
$TMPDIR/claude-mcp-browser-bridge-$USERSocket file (Claude Code)
/tmp/claude-mcp-browser-bridge-$USER/<PID>.sockSocket files (Claude.app)

Summary

  1. Primary issue: Claude.app (Cowork) and Claude Code use different native hosts with incompatible socket formats
  2. Fix: Disable the native messaging config for whichever one you're NOT using
  3. After any fix: Must restart Chrome AND Claude Code (MCP connects at startup)
  4. One profile: Only have Claude extension in one Chrome profile
  5. One session: Only run one Claude Code instance

Original skill by @jeffzwang from @ExaAILabs. Enhanced and updated for current versions of Claude Desktop and Claude Code.

來源與署名

來源:trailofbits/skills位於plugins/claude-in-chrome-troubleshooting/skills/chrome-mcp-troubleshooting提交82fe822

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架