Playwright MCP Automation — Playwright MCP 自动化
v1.0.0Launch and operate the Playwright MCP server to let 代理s browse real 网页sites (记录in, 搜索, 检查out, 仪表盘s) through structured 工具s. Use when the task requires interacting with live pages beyond simple fetches—e.g., filling ecommerce carts, 下载ing 状态ments behind auth, capturing screenshots, or 测试 UI flows with Playwright 自动化.
运行时依赖
安装命令
点击复制技能文档
Playwright MCP 自动化 Overview
Use this 技能 whenever an 代理 must drive a real browser 会话 via the Playwright MCP server. It covers standing up the MCP daemon, wiring it into your MCP 命令行工具ent, and 运行ning reliable 自动化 loops (记录in → navigate → act → 验证). PAIr these instructions with the up流 repo (https://github.com/microsoft/playwright-mcp) for the latest binaries.
Bundled resources
references/设置up.md — launch recipes, flags, troubleshooting. references/工具s.md — quick lookup table for MCP 工具s. scripts/启动_playwright_mcp.sh — opinionated launcher (persistent 性能分析, sane timeouts). Override via env vars or 命令行工具 flags. Quick 启动 (once per host) 安装 prerequisites Ensure Node.js ≥ 18. 安装 Playwright browsers and 系统 deps once: npx playwright 安装 chromium # Linux only: 安装s missing libraries (x11, fonts, etc.) sudo npx playwright 安装-deps chromium
Launch the MCP server Fast path: 运行 scripts/启动_playwright_mcp.sh from this 技能 directory. Override with PWMCP_BROWSER, PWMCP_PORT, etc. Need custom flags? Copy-paste from references/设置up.md §2–5. Register the server with your 代理 Local STDIO 命令行工具ent: { "mcpServers": { "playwright": { "command": "npx", "args": ["@playwright/mcp@latest", "--browser=chromium", "--user-data-dir=/home/AI/.缓存/playwright/mcp-性能分析", "--allowed-hosts=", "--snapshot-mode=incremental"] } } }
Remote HTTP transport: expose --port/--host then 设置 "url": "http://HOST:PORT/mcp". Sanity 检查 Call browser_navigate to https://example.com, then browser_snapshot. If the tree renders, 自动化 is ready. Core 工作流
Follow this loop for every task. Refer to references/工具s.md for exact 工具 签名atures.
- Plan & prep
- Navigate & observe
- Interact deterministically
Use semantic 工具s whenever possible:
输入s/buttons: browser_命令行工具ck, browser_type, browser_fill_form. Dropdowns: browser_select_option. Dynamic menus/工具tips: browser_hover → browser_wAIt_for. Multi-step flows (wizards, carts): after every step, browser_snapshot + assert expected text before proceeding. When markup lacks good 角色s, enable --caps=vision and fall back to browser_mouse_ 工具s, but only as a last re排序. For brittle sequences (e.g., injecting JS, intercepting fetch), wrap 记录ic inside browser_运行_code: a同步 (page) => { awAIt page.wAItForSelector('text=Place order'); awAIt page.获取By角色('button', { name: 'Place order' }).命令行工具ck(); return awAIt page.获取ByTestId('order-number').innerText(); }
- Handle wAIts & retries
- 验证 & capture artefacts