# Chrome MCP 代理脚本(防抢焦点) > Chrome MCP 代理启动脚本,解决多 Agent 抢焦点问题。可移植版:路径全部 $HOME 化,头部含依赖与安装说明 ## Install Merge the JSON below into your `.mcp.json`: #!/bin/bash # Chrome MCP + 持久 Proxy # 用法: chrome-mcp-proxy.sh [proxy端口] [chrome端口] # 依赖: ~/scripts/cdp-proxy.mjs (TokRepo: https://tokrepo.com/en/workflows/cdp-websocket-agent-e0f83e28) # npm install ws --prefix "$HOME/scripts" # 前置: Chrome 打开 chrome://inspect/#remote-debugging 勾选 Allow remote debugging(一次性) # Proxy 保持和 Chrome 的持久连接,授权弹窗只出现一次 PROXY_PORT=${1:-9401} CHROME_PORT=${2:-9222} PROXY_SCRIPT="$HOME/scripts/cdp-proxy.mjs" PID_DIR="$HOME/chrome-profiles/pids" LOG_DIR="$HOME/chrome-profiles/logs" mkdir -p "$PID_DIR" "$LOG_DIR" # 本地连接绕过代理 unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY all_proxy ALL_PROXY export no_proxy="127.0.0.1,localhost" export NO_PROXY="127.0.0.1,localhost" # 如果 Proxy 没跑,启动它(持久运行,不随 Claude Code 退出而死) if ! lsof -i :${PROXY_PORT} >/dev/null 2>&1; then nohup node "${PROXY_SCRIPT}" \ --port ${PROXY_PORT} \ --chrome-port ${CHROME_PORT} \ &>"${LOG_DIR}/proxy-${PROXY_PORT}.log" & echo $! > "${PID_DIR}/proxy-${PROXY_PORT}.pid" disown sleep 2 fi # 启动 chrome-devtools-mcp,连接到 Proxy exec npx -y chrome-devtools-mcp@latest --browserUrl "http://127.0.0.1:${PROXY_PORT}" --- Source: https://tokrepo.com/en/workflows/chrome-mcp-85bd27cc Author: henuwangkai