这是一个模型上下文协议(MCP)服务器,它使像Claude这样的AI助手能够通过Chrome扩展程序和WebSocket通信来控制Chrome浏览器。非常适合跨平台自动化,特别是WSL/Windows环境。
┌─────────────┐ WebSocket ┌─────────────┐ MCP/stdio ┌─────────────┐
│ Windows │ ←─────────────→ │ WSL │ ←─────────────→ │ Claude Code │
│ Chrome │ ws://IP:9222 │ Server │ │ │
│ + Extension │ │ │ │ │
└─────────────┘ └─────────────┘ └─────────────┘
克隆仓库
git clone https://github.com/deoxy/chrome-pilot.git
cd chrome-pilot
安装依赖
cd server
npm install
npm run build
启动WebSocket服务器
node dist/index.js --websocket
加载Chrome扩展程序
chrome://extensions/extension 文件夹配置扩展程序
ws://YOUR_IP:9222/ws添加到 ~/.claude/settings.json:
{
"mcpServers": {
"chrome-pilot": {
"command": "node",
"args": ["/path/to/chrome-pilot/server/dist/index.js", "--websocket"],
"env": {}
}
}
}
添加到Claude Desktop设置中:
{
"mcpServers": {
"chrome-pilot": {
"command": "node",
"args": ["/path/to/chrome-pilot/server/dist/index.js"]
}
}
}
| 工具 | 描述 | 参数 |
|---|---|---|
navigate | 导航到一个URL | url, tabId? |
get_tabs | 获取所有打开的浏览器标签页 | - |
get_current_tab | 获取当前活动的标签页 | - |
close_tab | 关闭浏览器标签页 | tabId |
click | 点击元素 | selector, tabId? |
type | 在输入框中输入文本 | selector, text, tabId? |
scroll | 滚动页面 | direction, amount?, tabId? |
screenshot | 截图 | tabId? |
get_content | 提取页面内容 | selector?, tabId? |
get_interactive_elements | 查找可点击的元素 | tabId? |
wait_for_element | 等待元素出现 | selector, timeout?, tabId? |
ip route | grep default
# 以管理员身份运行
New-NetFirewallRule -DisplayName "Chrome MCP Server" -Direction Inbound -Port 9222 -Protocol TCP -Action Allow
\\wsl$\Ubuntu\path\to\chrome-pilot\extension 访问扩展程序curl http://localhost:9222/info
curl -X POST http://localhost:9222/command \
-H "Content-Type: application/json" \
-d '{"action": "get_tabs", "params": {}}'
你能导航到google.com并截图吗?
chrome-pilot/
├── server/ # MCP Server (TypeScript)
│ ├── src/
│ │ ├── index.ts # 主服务器入口
│ │ ├── websocket-server.ts # WebSocket服务器
│ │ ├── native-host.ts # 本地消息
│ │ └── tools/ # 浏览器自动化工具
│ ├── package.json
│ └── tsconfig.json
├── extension/ # Chrome扩展程序
│ ├── manifest.json # 扩展程序配置
│ ├── background-websocket.js # 服务工作者
│ ├── content.js # 内容脚本
│ ├── popup.html # 扩展程序弹出窗口
│ └── popup.js
├── native-host/ # 本地消息设置
│ ├── install.sh # 安装脚本
│ └── com.chrome_mcp.host.json.template
└── docs/ # 文档
MIT许可证 - 详情见LICENSE文件。