claude-in-chrome-troubleshooting
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaude in Chrome MCP Troubleshooting
Chrome中Claude MCP扩展故障排查
Use this skill when Claude in Chrome MCP tools fail to connect or work unreliably.
当Claude in Chrome MCP工具无法连接或运行不稳定时,使用本技能。
When to Use
使用场景
- tools fail with "Browser extension is not connected"
mcp__claude-in-chrome__* - 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
- 工具失败并返回“Browser extension is not connected”
mcp__claude-in-chrome__* - 浏览器自动化运行异常或超时
- 更新Claude Code或Claude.app之后
- 在Claude Code CLI和Claude.app(Cowork)之间切换时
- 原生主机进程正在运行,但MCP工具仍然失败
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)
- Linux或Windows用户 - 本技能仅涵盖macOS特定路径和工具(、
~/Library/Application Support/)osascript - 与Claude扩展无关的通用Chrome自动化问题
- Claude.app桌面端问题(非浏览器相关)
- 网络连接问题
- Chrome扩展安装问题(请使用Chrome网上应用店支持)
The Claude.app vs Claude Code Conflict (Primary Issue)
Claude.app与Claude Code的冲突(主要问题)
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.
背景: 当Claude.app添加Cowork支持(从桌面应用进行浏览器自动化)时,引入了一个竞争的原生消息主机,与Claude Code CLI产生冲突。
Two Native Hosts, Two Socket Formats
两个原生主机,两种套接字格式
| Component | Native Host Binary | Socket Location |
|---|---|---|
| Claude.app (Cowork) | | |
| Claude Code CLI | | |
| 组件 | 原生主机二进制文件 | 套接字位置 |
|---|---|---|
| Claude.app (Cowork) | | |
| Claude Code CLI | | |
Why They Conflict
冲突原因
-
Both register native messaging configs in Chrome:
- → Claude.app helper
com.anthropic.claude_browser_extension.json - → Claude Code wrapper
com.anthropic.claude_code_browser_extension.json
-
Chrome extension requests a native host by name
-
If the wrong config is active, the wrong binary runs
-
The wrong binary creates sockets in a format/location the MCP client doesn't expect
-
Result: "Browser extension is not connected" even though everything appears to be running
-
两者都在Chrome中注册了原生消息配置:
- → Claude.app助手
com.anthropic.claude_browser_extension.json - → Claude Code包装器
com.anthropic.claude_code_browser_extension.json
-
Chrome扩展按名称请求原生主机
-
如果错误的配置处于激活状态,会运行错误的二进制文件
-
错误的二进制文件会在MCP客户端不期望的格式/位置创建套接字
-
结果:即使所有组件看似都在运行,仍会返回“Browser extension is not connected”
The Fix: Disable Claude.app's Native Host
修复方案:禁用Claude.app的原生主机
If you use Claude Code CLI for browser automation (not Cowork):
bash
undefined如果您使用Claude Code CLI进行浏览器自动化(而非Cowork):
bash
undefinedDisable the Claude.app native messaging config
Disable the Claude.app native messaging config
mv ~/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
~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json.disabled
mv ~/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
~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json.disabled
Ensure the Claude Code config exists and points to the wrapper
Ensure the Claude Code config exists and points to the wrapper
cat ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_code_browser_extension.json
**If you use Cowork (Claude.app) for browser automation:**
```bashcat ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_code_browser_extension.json
**如果您使用Cowork(Claude.app)进行浏览器自动化:**
```bashDisable the Claude Code native messaging config
Disable the Claude Code native messaging config
mv ~/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
~/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.mv ~/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
~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_code_browser_extension.json.disabled
**您无法同时使用两者。** 选择其中一个并禁用另一个。Toggle Script
切换脚本
Add this to or run directly:
~/.zshrcbash
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: then restart Chrome (and Claude Code if switching to CLI).
chrome-mcp-toggle将以下内容添加到或直接运行:
~/.zshrcbash
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
}用法:运行,然后重启Chrome(如果切换到CLI,还需重启Claude Code)。
chrome-mcp-toggleQuick Diagnosis
快速诊断
bash
undefinedbash
undefined1. Which native host binary is running?
1. 哪个原生主机二进制文件正在运行?
ps aux | grep chrome-native-host | grep -v grep
ps aux | grep chrome-native-host | grep -v grep
Claude.app: /Applications/Claude.app/Contents/Helpers/chrome-native-host
Claude.app: /Applications/Claude.app/Contents/Helpers/chrome-native-host
Claude Code: ~/.local/share/claude/versions/X.X.X --chrome-native-host
Claude Code: ~/.local/share/claude/versions/X.X.X --chrome-native-host
2. Where is the socket?
2. 套接字位置在哪里?
For Claude Code (single file in TMPDIR):
对于Claude Code(TMPDIR中的单个文件):
ls -la "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER" 2>&1
ls -la "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER" 2>&1
For Claude.app (directory with PID files):
对于Claude.app(包含PID文件的目录):
ls -la /tmp/claude-mcp-browser-bridge-$USER/ 2>&1
ls -la /tmp/claude-mcp-browser-bridge-$USER/ 2>&1
3. What's the native host connected to?
3. 原生主机连接到了什么?
lsof -U 2>&1 | grep claude-mcp-browser-bridge
lsof -U 2>&1 | grep claude-mcp-browser-bridge
4. Which configs are active?
4. 哪些配置处于激活状态?
ls ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic*.json
undefinedls ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic*.json
undefinedCritical 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.
MCP在启动时连接。 如果Claude Code启动时浏览器桥未就绪,整个会话的连接都会失败。通常的修复方法是:确保Chrome和扩展使用正确的配置运行,然后重启Claude Code。
Full Reset Procedure (Claude Code CLI)
完整重置流程(Claude Code CLI)
bash
undefinedbash
undefined1. Ensure correct config is active
1. 确保正确的配置处于激活状态
mv ~/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
~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic.claude_browser_extension.json.disabled 2>/dev/null
mv ~/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
~/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 version
2. 更新包装器以使用最新的Claude Code版本
cat > ~/.claude/chrome/chrome-native-host << 'EOF'
#!/bin/bash
LATEST=$(ls -t ~/.local/share/claude/versions/ 2>/dev/null | head -1)
exec "$HOME/.local/share/claude/versions/$LATEST" --chrome-native-host
EOF
chmod +x ~/.claude/chrome/chrome-native-host
cat > ~/.claude/chrome/chrome-native-host << 'EOF'
#!/bin/bash
LATEST=$(ls -t ~/.local/share/claude/versions/ 2>/dev/null | head -1)
exec "$HOME/.local/share/claude/versions/$LATEST" --chrome-native-host
EOF
chmod +x ~/.claude/chrome/chrome-native-host
3. Kill existing native host and clean sockets
3. 终止现有原生主机进程并清理套接字
pkill -f chrome-native-host
rm -rf /tmp/claude-mcp-browser-bridge-$USER/
rm -f "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER"
pkill -f chrome-native-host
rm -rf /tmp/claude-mcp-browser-bridge-$USER/
rm -f "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER"
4. Restart Chrome
4. 重启Chrome
osascript -e 'quit app "Google Chrome"' && sleep 2 && open -a "Google Chrome"
osascript -e 'quit app "Google Chrome"' && sleep 2 && open -a "Google Chrome"
5. Wait for Chrome, click Claude extension icon
5. 等待Chrome启动,点击Claude扩展图标
6. Verify correct native host is running
6. 验证正确的原生主机正在运行
ps aux | grep chrome-native-host | grep -v grep
ps aux | grep chrome-native-host | grep -v grep
Should show: ~/.local/share/claude/versions/X.X.X --chrome-native-host
应显示:~/.local/share/claude/versions/X.X.X --chrome-native-host
7. Verify socket exists
7. 验证套接字存在
ls -la "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER"
ls -la "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER"
8. Restart Claude Code
8. 重启Claude Code
undefinedundefinedOther Common Causes
其他常见原因
Multiple Chrome Profiles
多个Chrome配置文件
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.
如果您在多个Chrome配置文件中安装了Claude扩展,每个配置文件都会生成自己的原生主机和套接字,这可能导致混乱。
修复方案: 仅在一个Chrome配置文件中启用Claude扩展。
Multiple Claude Code Sessions
多个Claude Code会话
Running multiple Claude Code instances can cause socket conflicts.
Fix: Only run one Claude Code session at a time, or use to reconnect after closing other sessions.
/mcp运行多个Claude Code实例可能导致套接字冲突。
修复方案: 一次仅运行一个Claude Code会话,或在关闭其他会话后使用重新连接。
/mcpHardcoded Version in Wrapper
包装器中的硬编码版本
The wrapper at may have a hardcoded version that becomes stale after updates.
~/.claude/chrome/chrome-native-hostDiagnosis:
bash
cat ~/.claude/chrome/chrome-native-host位于的包装器可能包含硬编码版本,更新后会过时。
~/.claude/chrome/chrome-native-host诊断:
bash
cat ~/.claude/chrome/chrome-native-hostBad: exec "/Users/.../.local/share/claude/versions/2.0.76" --chrome-native-host
错误示例:exec "/Users/.../.local/share/claude/versions/2.0.76" --chrome-native-host
Good: Uses $(ls -t ...) to find latest
正确示例:使用$(ls -t ...)查找最新版本
**Fix:** Use the dynamic version wrapper shown in the Full Reset Procedure above.
**修复方案:** 使用上述完整重置流程中的动态版本包装器。TMPDIR Not Set
TMPDIR未设置
Claude Code expects to be set to find the socket.
TMPDIRbash
undefinedClaude Code需要设置才能找到套接字。
TMPDIRbash
undefinedCheck
检查
echo $TMPDIR
echo $TMPDIR
Should show: /var/folders/XX/.../T/
应显示:/var/folders/XX/.../T/
Fix: Add to ~/.zshrc
修复:添加到~/.zshrc
export TMPDIR="${TMPDIR:-$(getconf DARWIN_USER_TEMP_DIR)}"
undefinedexport TMPDIR="${TMPDIR:-$(getconf DARWIN_USER_TEMP_DIR)}"
undefinedDiagnostic 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)"bash
echo "=== 原生主机二进制文件 ==="
ps aux | grep chrome-native-host | grep -v grep
echo -e "\n=== 套接字(Claude Code位置) ==="
ls -la "$(getconf DARWIN_USER_TEMP_DIR)/claude-mcp-browser-bridge-$USER" 2>&1
echo -e "\n=== 套接字(Claude.app位置) ==="
ls -la /tmp/claude-mcp-browser-bridge-$USER/ 2>&1
echo -e "\n=== 原生主机打开的文件 ==="
pgrep -f chrome-native-host | xargs -I {} lsof -p {} 2>/dev/null | grep -E "(sock|claude-mcp)"
echo -e "\n=== 激活的原生消息配置 ==="
ls ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.anthropic*.json 2>/dev/null
echo -e "\n=== 自定义包装器内容 ==="
cat ~/.claude/chrome/chrome-native-host 2>/dev/null || echo "无自定义包装器"
echo -e "\n=== TMPDIR ==="
echo "TMPDIR=$TMPDIR"
echo "预期值: $(getconf DARWIN_USER_TEMP_DIR)"File Reference
文件参考
| File | Purpose |
|---|---|
| Custom wrapper script for Claude Code |
| Claude.app (Cowork) native host |
| Claude Code binary (run with |
| Config for Claude.app native host |
| Config for Claude Code native host |
| Socket file (Claude Code) |
| Socket files (Claude.app) |
| 文件 | 用途 |
|---|---|
| Claude Code的自定义包装器脚本 |
| Claude.app (Cowork) 原生主机 |
| Claude Code二进制文件(使用 |
| Claude.app原生主机的配置文件 |
| Claude Code原生主机的配置文件 |
| 套接字文件(Claude Code) |
| 套接字文件(Claude.app) |
Summary
总结
- Primary issue: Claude.app (Cowork) and Claude Code use different native hosts with incompatible socket formats
- Fix: Disable the native messaging config for whichever one you're NOT using
- After any fix: Must restart Chrome AND Claude Code (MCP connects at startup)
- One profile: Only have Claude extension in one Chrome profile
- 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.
- 主要问题: Claude.app (Cowork)和Claude Code使用不同的原生主机,套接字格式不兼容
- 修复方案: 禁用您不使用的那一个的原生消息配置
- 修复后: 必须重启Chrome和Claude Code(MCP在启动时连接)
- 单一配置文件: 仅在一个Chrome配置文件中安装Claude扩展
- 单一会话: 一次仅运行一个Claude Code实例
本技能由@jeffzwang从@ExaAILabs提供,已针对当前版本的Claude桌面端和Claude Code进行增强和更新。