Glean 拾遗
日刊 /2026-07-31 / 为 AI 编码助手接管 Chrome 的官方 MCP 服务器

为 AI 编码助手接管 Chrome 的官方 MCP 服务器

原文 github.com 收录 2026-07-31 11:11 阅读 46 min
AI 解读

chrome-devtools-mcp 是 Chrome 团队官方发布的 MCP 服务器,让 Claude、Cursor、Gemini CLI 等编码 Agent 直接操控真实 Chrome 浏览器。它把 DevTools 能力封装成 50+ 个工具,覆盖输入自动化、导航、网络与性能分析、堆快照、控制台调试等,并通过 Puppeteer 自动等待操作结果。除默认启动独立浏览器外,还可连接正在运行的 Chrome 以复用登录与页面状态。适合做 Agent 浏览器自动化、前端调试或性能分析的一线工程师。

原文 46 分钟
原文 github.com ↗
§ 1

Chrome DevTools for agents (chrome-devtools-mcp) is an official Model-Context-Protocol (MCP) server that lets coding agents like Claude, Cursor, Copilot, or Gemini CLI control and inspect a live Chrome browser. Instead of guessing what a page looks like, your agent can click, type, navigate, capture screenshots, read console messages, trace performance, and even take heap snapshots. It also ships a CLI for use without MCP.

Chrome DevTools for agents(chrome-devtools-mcp)是官方推出的 MCP(Model-Context-Protocol)服务器,让 Claude、Cursor、Copilot、Gemini CLI 等编码代理直接控制和检查真实运行的 Chrome 浏览器。代理不再需要猜测页面长什么样,而是可以真实地点击、输入、导航、截图、读取控制台消息、录制性能轨迹,甚至抓取堆快照。项目还附带一个 CLI,可在不使用 MCP 的场景下独立使用。

§ 2

AI coding agents often have to verify web pages, debug front-end issues, and measure performance. Without a live browser, they rely on static analysis or text-only approximations, which miss runtime errors, layout problems, network failures, and real user-perceived performance. chrome-devtools-mcp closes that gap by exposing the full power of Chrome DevTools as MCP tools. It is built on Puppeteer for reliable automation and automatically waits for action results, so clicks and navigations actually settle before the next step runs.

编码代理在验证网页、排查前端问题、评估性能时,往往需要一台真实浏览器。没有它,代理只能依赖静态分析或纯文本近似,无法捕捉运行时错误、布局问题、网络故障和真实用户感知的性能。chrome-devtools-mcp 把 Chrome DevTools 的完整能力封装成 MCP 工具,填补了这一缺口。它基于 Puppeteer 实现自动化,并会自动等待操作结果,确保点击、导航真正完成后再进入下一步。

§ 3

The server exposes dozens of tools grouped by scenario: input automation (click, fill, drag, upload), navigation (new_page, navigate_page, wait_for), emulation (device and viewport), performance tracing (performance_start_trace, performance_analyze_insight), network inspection (list_network_requests, get_network_request), debugging (take_snapshot, evaluate_script, list_console_messages, lighthouse_audit), memory analysis (12 heap snapshot tools), and extension management. An optional --slim mode reduces the surface to three tools when you only need navigation, scripting, and screenshots. There are also bundled skills (e.g., a11y-debugging, memory-leak-debugging) that give agents expert guidance on top of the raw tools.

该服务器按场景提供了数十个工具:输入自动化(click、fill、drag、upload)、导航(new_page、navigate_page、wait_for)、模拟(设备与视口)、性能轨迹(performance_start_traceperformance_analyze_insight)、网络检查(list_network_requestsget_network_request)、调试(take_snapshotevaluate_scriptlist_console_messageslighthouse_audit)、内存分析(12 个堆快照工具),以及扩展管理。如果只需要导航、执行脚本和截图,--slim 模式可以只暴露三个工具。项目还内置了若干技能包(如 a11y-debugging、memory-leak-debugging),在原始工具之上为代理提供专家级使用指导。

§ 4

chrome-devtools-mcp runs as an MCP server over stdio (or HTTP via a proxy). It launches a dedicated Chrome instance with a user data directory that is persisted across runs, or connects to an already-running Chrome through --browser-url, --wsEndpoint, or the newer --autoConnect flow. Under the hood it uses Puppeteer to automate Chrome and the DevTools frontend to extract performance insights. Internally, the codebase is organized around components such as McpPage, ToolHandler, HeapSnapshotManager, and PageCollector, which map MCP tool calls to browser operations. When a client calls a tool that needs a browser, the server starts Chrome on demand; simply connecting to the server does not launch the browser.

chrome-devtools-mcp 以 MCP 服务器形式运行,默认走 stdio(也可通过代理使用 HTTP)。它会启动一个专用 Chrome 实例,并使用跨运行持久化的用户数据目录;也可以通过 --browser-url--wsEndpoint 或更新的 --autoConnect 方式连接到已在运行的 Chrome。底层通过 Puppeteer 驱动 Chrome,并借助 DevTools 前端提取性能洞察。代码内部围绕 McpPageToolHandlerHeapSnapshotManagerPageCollector 等组件组织,把 MCP 工具调用映射为浏览器操作。当客户端调用需要浏览器的工具时,服务器才会按需启动 Chrome;仅连接服务器不会自动打开浏览器。

§ 5

Add the following to your MCP client configuration:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest"]
    }
  }
}

Then ask your agent:

Check the performance of https://developers.chrome.com

If the tool requires a browser, the server starts Chrome on demand. The @latest tag ensures your client always pulls the newest version.

在 MCP 客户端配置中加入:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest"]
    }
  }
}

然后让代理执行:

Check the performance of https://developers.chrome.com

如果工具需要浏览器,服务器会按需启动 Chrome。使用 @latest 可以确保客户端始终拉取最新版本。

§ 6

You can tune behavior through CLI flags. Common ones include --headless for no UI, --isolated to use a temporary user-data-dir that is cleaned up after the browser closes, --channel=canary|dev|beta|stable to pick a Chrome channel, and --browser-url=http://127.0.0.1:9222 to attach to a running Chrome with remote debugging enabled. Use --wsEndpoint plus --wsHeaders for authenticated WebSocket connections. --autoConnect (Chrome 144+) connects to a running browser from the designated Chrome channel. For minimal contexts, --slim --headless exposes only three tools. Screenshot output can be tuned with --screenshot-format=jpeg|webp and --screenshot-max-width to keep AI context small. Run npx chrome-devtools-mcp@latest --help for the full list.

服务器行为可通过 CLI 参数调整。常用项包括:--headless(无界面)、--isolated(使用临时用户数据目录,浏览器关闭后自动清理)、--channel=canary|dev|beta|stable(选择 Chrome 版本通道)、--browser-url=http://127.0.0.1:9222(连接已开启远程调试的 Chrome)。需要带认证的 WebSocket 连接时,用 --wsEndpoint 配合 --wsHeaders--autoConnect(Chrome 144+)可以自动连接到正在运行的指定通道浏览器。如果只想跑简单任务,用 --slim --headless 只暴露三个工具。截图输出可用 --screenshot-format=jpeg|webp--screenshot-max-width 控制体积,减少 AI 对话的上下文占用。完整参数可运行 npx chrome-devtools-mcp@latest --help 查看。

§ 7

Best suited for: end-to-end web automation, performance analysis (tracing + CrUX field data), console/network debugging, memory leak diagnosis via heap snapshots, extension testing, and integrating a browser subagent into your own agentic tooling. Caveats: officially only Google Chrome and Chrome for Testing are supported; other Chromium browsers may behave unexpectedly. Since the server exposes browser content to MCP clients, avoid sharing sensitive or personal information you don't want those clients to see. Usage statistics are collected by default (opt out with --no-usage-statistics or set CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS/CI). Performance tools may send trace URLs to the CrUX API unless --no-performance-crux is set. Opening a remote debugging port exposes control of the browser to any local application, so use a dedicated --user-data-dir and avoid working on sensitive sites while it's open.

最适合:端到端 Web 自动化、性能分析(tracing 加上 CrUX 真实用户数据)、控制台/网络调试、通过堆快照做内存泄漏诊断、扩展测试,以及在自有 agent 产品中集成浏览器 subagent。需要注意:官方只支持 Google Chrome 和 Chrome for Testing,其他 Chromium 内核浏览器可能工作但行为不受保证;服务器会把浏览器内容暴露给 MCP 客户端,因此不要在上面处理你不想让这些客户端看到的敏感或个人数据;默认收集使用统计(可通过 --no-usage-statistics 或设置 CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS/CI 环境变量关闭);性能工具会向 CrUX API 发送 trace URL 获取真实用户体验数据,除非指定 --no-performance-crux;开启远程调试端口会让本机任意应用获得浏览器控制权,务必使用专用 --user-data-dir,并在开端口期间避免访问敏感网站。

打开原文 ↗