Chrome MCP 服务器
模型上下文协议 (MCP) 服务器通过 Chrome DevTools 协议 (CDP) 提供对 Chrome 浏览器实例的细粒度控制。
先决条件
Bun (推荐)或 Node.js(v14 或更高版本)
启用远程调试的 Chrome 浏览器
Related MCP server: Cloudflare Playwright MCP
设置
安装 Bun
安装 Bun(如果尚未安装):
# macOS, Linux, or WSL
curl -fsSL https://bun.sh/install | bash
# Windows (using PowerShell)
powershell -c "irm bun.sh/install.ps1 | iex"
# Alternatively, using npm
npm install -g bun启动 Chrome 并启用远程调试:
您可以使用附带的脚本自动检测您的操作系统并使用正确的命令启动 Chrome:
# Make the script executable chmod +x start-chrome.sh # Run the script ./start-chrome.sh或者手动启动 Chrome 进行远程调试:
# macOS /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 # Windows start chrome --remote-debugging-port=9222 # Linux google-chrome --remote-debugging-port=9222安装依赖项:
bun install启动服务器:
bun start对于使用热重载进行开发:
bun dev服务器默认在 3000 端口启动。您可以通过设置PORT环境变量来更改此设置。
配置 Roo Code 以使用此 MCP 服务器
要将此 Chrome MCP 服务器与 Roo 代码一起使用:
打开 Roo 代码设置
导航至 MCP 设置配置文件:
macOS:
~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.jsonWindows:
%APPDATA%\Code\User\globalStorage\rooveterinaryinc.roo-cline\settings\cline_mcp_settings.jsonLinux:
~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
向
mcpServers对象添加以下配置:
{
"mcpServers": {
"chrome-control": {
"url": "http://localhost:3000/sse-cursor",
"disabled": false,
"alwaysAllow": []
}
}
}保存文件并重新启动 Roo Code 以应用更改。
您现在可以使用 Roo Code 中的 Chrome MCP 工具来控制浏览器。
可用工具
服务器提供以下浏览器控制工具:
导航
导航到特定的 URL。
参数:
url(字符串):要导航到的 URL
点击
单击特定坐标。
参数:
x(数字):X 坐标y(数字):Y坐标
类型
在当前焦点处输入文本。
参数:
text(字符串):要输入的文本
clickElement
单击页面信息中索引对应的元素。
参数:
selector(字符串):元素索引(例如,“0”表示第一个元素)
获取文本
使用 CSS 选择器获取元素的文本内容。
参数:
selector(字符串):用于查找元素的 CSS 选择器
获取页面信息
获取有关页面的语义信息,包括交互元素和文本节点。
获取页面状态
获取当前页面状态,包括 URL、标题、滚动位置和视口大小。
用法
服务器通过 SSE 传输实现模型上下文协议。请通过以下方式连接到服务器:
SSE 端点:
http://localhost:3000/sse-cursor消息端点:
http://localhost:3000/message?sessionId=...
与 Roo Code 一起使用时,MCP 设置文件中的配置将自动处理连接。
发展
要使用热重载以开发模式运行服务器:
bun dev这使用 Bun 的内置监视模式在文件发生变化时自动重启服务器。
执照
麻省理工学院
This server cannot be installed
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.