chrome-devtools-remote
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesechrome-devtools-remote
chrome-devtools-remote
You are operating the CLI in remote mode against a server that the user has running on another host. The remote server owns the browser; your job is to drive it.
chrome-devtoolschrome-devtools-mcp你将以远程模式操作 CLI,连接到用户在另一台主机上运行的服务器。远程服务器拥有浏览器的控制权,你的任务是驱动该服务器执行操作。
chrome-devtoolschrome-devtools-mcpWhen to use this skill
何时使用此技能
Trigger on any request that:
- Names a remote machine ("on the lab mac", "on host X", "on my tailnet box") and asks you to do something a browser would do
- Provides a HTTPS URL (typically ending in
chrome-devtools-mcp) and asks for an interactive browser action/mcp - Mentions environment variables or
CHROME_DEVTOOLS_MCP_REMOTE_URLCHROME_DEVTOOLS_MCP_REMOTE_INSECURE
If the user wants to drive a local browser, use the regular CLI (without ) or the MCP tools instead.
chrome-devtools--remotemcp__chrome-devtools__*当用户的请求满足以下任意条件时,触发此技能:
- 指定了远程机器(如“在实验室Mac上”、“在主机X上”、“在我的tailnet设备上”)并要求执行浏览器相关操作
- 提供了的HTTPS URL(通常以
chrome-devtools-mcp结尾)并要求执行交互式浏览器操作/mcp - 提到了环境变量或
CHROME_DEVTOOLS_MCP_REMOTE_URLCHROME_DEVTOOLS_MCP_REMOTE_INSECURE
如果用户想要驱动本地浏览器,请使用常规的 CLI(不带参数)或系列MCP工具。
chrome-devtools--remotemcp__chrome-devtools__*Install (on the local box, once)
安装(仅需在本地设备执行一次)
The client CLI ships in the same npm package as the server. Install globally on the machine where the agent runs — not on the remote host:
chrome-devtoolsbash
npm install -g @vibebrowser/chrome-devtools-mcp
chrome-devtools --version # should print 0.26.6 or newerYou do not install anything on the remote host — that host is whoever already serves and is set up out-of-band.
https://.../mcpTroubleshooting:
- — npm's global bin isn't on
command not found: chrome-devtools. AddPATHto$(npm config get prefix)/bin, or on macOS Homebrew addPATHto your shell rc.eval "$(brew shellenv)" - on first run — known bundling gap (issue dzianisv/chrome-devtools-mcp#17). Workaround:
Cannot find package 'pkce-challenge'.cd "$(npm root -g)/@vibebrowser/chrome-devtools-mcp" && npm install pkce-challenge --no-save
chrome-devtoolsbash
npm install -g @vibebrowser/chrome-devtools-mcp
chrome-devtools --version # 应显示0.26.6或更高版本无需在远程主机上安装任何内容——该主机已预先配置好服务。
https://.../mcp故障排查:
- ——npm全局bin目录不在
command not found: chrome-devtools中。将PATH添加到$(npm config get prefix)/bin,或在macOS Homebrew环境下,将PATH添加到shell配置文件中。eval "$(brew shellenv)" - 首次运行时出现——已知打包问题(issue dzianisv/chrome-devtools-mcp#17)。解决方法:
Cannot find package 'pkce-challenge'。cd "$(npm root -g)/@vibebrowser/chrome-devtools-mcp" && npm install pkce-challenge --no-save
Connect
连接配置
Configure the endpoint once per shell session and verify connectivity before doing anything else.
bash
export CHROME_DEVTOOLS_MCP_REMOTE_URL="https://lab.tailnet.ts.net/mcp"
chrome-devtools status --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"A healthy response prints plus a JSON body. Anything else is a hard stop — surface the error to the user instead of retrying.
status=ok http=200If the URL is unset, ask the user once for the endpoint. Conventional shape: (the path is required — the bare host returns a 404).
https://<host>/mcp/mcpConnection-time flags:
| Situation | What to pass |
|---|---|
| Self-signed cert (common on tailnets without Tailscale-issued certs) | |
| Bearer-token gateway | |
Custom static header (e.g. | |
Endpoint behind Tailscale and | |
Once is green, every subsequent call reuses the same server-side tab via a sticky session id cached at .
statuschrome-devtools <tool> ... --remote "$URL"~/.cache/chrome-devtools-mcp/remote/<hash>.session每个shell会话只需配置一次端点,在执行其他操作前先验证连接性。
bash
export CHROME_DEVTOOLS_MCP_REMOTE_URL="https://lab.tailnet.ts.net/mcp"
chrome-devtools status --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"健康的响应会输出及JSON格式的响应体。如果出现其他结果,请立即终止操作并向用户反馈错误,不要重试。
status=ok http=200如果未设置URL,请向用户询问一次端点地址。标准格式为:(必须包含路径——仅输入主机地址会返回404错误)。
https://<host>/mcp/mcp连接时可用的参数:
| 场景 | 需传入的参数 |
|---|---|
| 使用自签名证书(在未使用Tailscale颁发证书的tailnet中很常见) | 每次调用时添加 |
| 需Bearer令牌验证的网关 | |
自定义静态请求头(例如 | |
端点位于Tailscale后,且 | 在本地执行 |
当命令返回正常后,后续所有调用都会通过存储在中的粘性会话ID,复用同一服务器端标签页。
statuschrome-devtools <tool> ... --remote "$URL"~/.cache/chrome-devtools-mcp/remote/<hash>.sessionSession model — read this before chaining commands
会话模型——执行链式命令前请阅读
Each CLI invocation reuses a sticky session id stored under . This means:
~/.cache/chrome-devtools-mcp/remote/<hash>.session- →
navigate_page→take_snapshot→clickall hit the same server-side tab. You can chain them as separate CLI calls and assume continuity.take_screenshot - If the server restarts between calls, the next call transparently re-initializes against a fresh session. Tab state on the server is lost — re-navigate before assuming anything.
- To explicitly end the server-side session and free its browser context, run .
chrome-devtools stop --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
每个CLI调用都会复用存储在中的粘性会话ID,这意味着:
~/.cache/chrome-devtools-mcp/remote/<hash>.session- →
navigate_page→take_snapshot→click所有操作都会作用于同一服务器端标签页。你可以将它们作为独立的CLI调用链式执行,无需担心上下文中断。take_screenshot - 如果在两次调用之间服务器重启,下一次调用会自动重新初始化新会话。服务器端标签页的状态会丢失——请重新导航后再执行后续操作。
- 要显式终止服务器端会话并释放浏览器上下文,请执行。
chrome-devtools stop --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
Common operations
常用操作
All commands accept to return structured output you can pipe into .
--output-format jsonjqbash
undefined所有命令都支持参数,返回结构化输出可通过管道传入工具处理。
--output-format jsonjqbash
undefinedOpen a page
打开页面
chrome-devtools navigate_page "https://example.com" --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
chrome-devtools navigate_page "https://example.com" --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
Get a structured a11y snapshot (use for finding clickable uids)
获取结构化无障碍快照(用于查找可点击元素的uid)
chrome-devtools take_snapshot --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL" --output-format json
chrome-devtools take_snapshot --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL" --output-format json
Click an element by uid from the snapshot
通过快照中的uid点击元素
chrome-devtools click "$UID" --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
chrome-devtools click "$UID" --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
Fill an input
填充输入框
chrome-devtools fill "$UID" "value" --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
chrome-devtools fill "$UID" "value" --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
Take a screenshot (saved to /tmp/<uuid>.png locally)
截图(保存到本地/tmp/<uuid>.png)
chrome-devtools take_screenshot --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
chrome-devtools take_screenshot --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
Evaluate JS in the page — return value must be JSON-serializable
在页面中执行JS代码——返回值必须可序列化为JSON
chrome-devtools evaluate_script '() => document.title' --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
chrome-devtools evaluate_script '() => document.title' --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
Read console messages from the page
读取页面的控制台消息
chrome-devtools list_console_messages --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
chrome-devtools list_console_messages --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
List network requests since page load
列出页面加载后的网络请求
chrome-devtools list_network_requests --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
undefinedchrome-devtools list_network_requests --remote "$CHROME_DEVTOOLS_MCP_REMOTE_URL"
undefinedRecipes
操作示例
Smoke-check a deployed web app
冒烟测试已部署的Web应用
bash
URL="$CHROME_DEVTOOLS_MCP_REMOTE_URL"
chrome-devtools navigate_page "https://app.example.com" --remote "$URL"
chrome-devtools evaluate_script '() => ({title: document.title, ready: document.readyState})' --remote "$URL"
chrome-devtools list_console_messages --remote "$URL" --output-format json
chrome-devtools take_screenshot --remote "$URL"If contains any entries, surface them — they are usually the root cause of "the page looks broken" reports.
console_messageslevel: "error"bash
URL="$CHROME_DEVTOOLS_MCP_REMOTE_URL"
chrome-devtools navigate_page "https://app.example.com" --remote "$URL"
chrome-devtools evaluate_script '() => ({title: document.title, ready: document.readyState})' --remote "$URL"
chrome-devtools list_console_messages --remote "$URL" --output-format json
chrome-devtools take_screenshot --remote "$URL"如果中包含的条目,请向用户反馈——这些通常是“页面显示异常”问题的根本原因。
console_messageslevel: "error"Drive a login form
驱动登录表单
bash
chrome-devtools navigate_page "https://app.example.com/login" --remote "$URL"
chrome-devtools take_snapshot --remote "$URL" --output-format json > /tmp/snap.jsonbash
chrome-devtools navigate_page "https://app.example.com/login" --remote "$URL"
chrome-devtools take_snapshot --remote "$URL" --output-format json > /tmp/snap.jsonFind the uid of the email input + password input + submit button from /tmp/snap.json
从/tmp/snap.json中找到邮箱输入框、密码输入框和提交按钮的uid
chrome-devtools fill "<email-uid>" "$LOGIN_EMAIL" --remote "$URL"
chrome-devtools fill "<password-uid>" "$LOGIN_PASSWORD" --remote "$URL"
chrome-devtools click "<submit-uid>" --remote "$URL"
undefinedchrome-devtools fill "<email-uid>" "$LOGIN_EMAIL" --remote "$URL"
chrome-devtools fill "<password-uid>" "$LOGIN_PASSWORD" --remote "$URL"
chrome-devtools click "<submit-uid>" --remote "$URL"
undefinedCapture a CrUX-style trace
捕获CrUX风格的性能追踪数据
bash
chrome-devtools performance_start_trace --remote "$URL"
chrome-devtools navigate_page "https://app.example.com" --remote "$URL"
chrome-devtools performance_stop_trace --remote "$URL" --output-format jsonbash
chrome-devtools performance_start_trace --remote "$URL"
chrome-devtools navigate_page "https://app.example.com" --remote "$URL"
chrome-devtools performance_stop_trace --remote "$URL" --output-format jsonOutput discipline
输出规范
- Always print the URL of the page you navigated to so the user knows which tab they're looking at.
- For screenshots, print the path of the saved file () — the CLI already writes that line on stdout.
Saved to /tmp/<uuid>.png. - For , prefer
evaluate_scriptand forward only the relevant field instead of dumping the whole structuredContent envelope.--output-format json - If the user asks "what's on the page", prefer over
take_snapshot— the snapshot is text and cheaper to reason over.take_screenshot
- 始终输出你导航到的页面URL,让用户清楚当前操作的标签页。
- 截图完成后,输出保存的文件路径(如)——CLI会自动在标准输出中打印该信息。
Saved to /tmp/<uuid>.png. - 执行时,优先使用
evaluate_script参数,仅转发相关字段而非完整的structuredContent信封结构。--output-format json - 如果用户询问“页面上有什么”,优先使用而非
take_snapshot——快照是文本格式,更便于分析。take_screenshot
Failure modes
故障排查
| Symptom | Cause | Fix |
|---|---|---|
| DNS, Tailscale offline, or wrong URL | |
| Server restarted; sticky id was stale. Retried once internally — if you see this it means the retry also 404'd | |
TLS verify error ( | Server uses a self-signed cert (no Tailscale-issued cert) | Add |
| Local cache directory was wiped mid-session | First call after the wipe will mint a fresh session; just retry |
| Hangs on first call after a long idle | Server idle reaper closed the session | Same fix as the 404 row — |
| 症状 | 原因 | 解决方法 |
|---|---|---|
| DNS解析失败、Tailscale离线或URL错误 | 在本地执行 |
| 服务器重启,粘性会话ID失效。已自动重试一次——出现此提示说明重试也失败了 | 执行 |
TLS验证错误( | 服务器使用自签名证书(未使用Tailscale颁发的证书) | 添加 |
| 本地缓存目录在会话中途被清空 | 清空后的首次调用会生成新会话,直接重试即可 |
| 长时间闲置后的首次调用出现卡顿 | 服务器闲置回收机制已关闭会话 | 与404错误的解决方法相同——执行 |
Don'ts
注意事项
- Don't loop to "wait for the page to load" — use
navigate_pagewith a text selector instead.wait_for - Don't for every step in a chain — the user almost always wants one final screenshot, not five intermediate ones.
take_screenshot - Don't pass for a hosted endpoint with a real cert. It silently disables TLS for the whole CLI process.
--insecure - Don't try to a server with
start— that subcommand only manages local daemons.--remote
- 不要通过循环调用来“等待页面加载完成”——应使用
navigate_page配合文本选择器。wait_for - 不要在链式操作的每一步都调用——用户通常只需要最终的一张截图,而非中间过程的多张截图。
take_screenshot - 不要对拥有有效证书的托管端点使用参数——这会静默禁用整个CLI进程的TLS验证。
--insecure - 不要尝试使用参数执行
--remote命令——该子命令仅用于管理本地守护进程。start