详细分析 ▾
运行时依赖
版本
Initial release of the Playwright MCP skill for browser automation. - Automate Chrome, Firefox, and WebKit browsers using Playwright MCP server. - Navigate websites, click elements, type text, fill forms, extract data, and take screenshots using easy-to-use tools. - Provides quick start instructions, common usage examples, and tool reference. - Supports customization via command-line options for browser settings, security, and output. - Includes troubleshooting steps, security notes, and helpful links.
安装命令 点击复制
技能文档
Browser automation powered by Playwright MCP server. Control Chrome, Firefox, or WebKit programmatically.
Installation
npm install -g @playwright/mcp
# Or
npx @playwright/mcp
Install browsers (first time):
npx playwright install chromium
Quick 开始
开始 MCP Server (STDIO mode)
npx @playwright/mcp
开始 带有 Options
# Headless mode
npx @playwright/mcp --headless# Specific browser
npx @playwright/mcp --browser firefox
# With viewport
npx @playwright/mcp --viewport-size 1280x720
# Ignore HTTPS errors
npx @playwright/mcp --ignore-https-errors
Common 使用 Cases
1. Navigate 和 Extract Data
# MCP tools available:
# - browser_navigate: Open URL
# - browser_click: Click element
# - browser_type: Type text
# - browser_select_option: Select dropdown
# - browser_get_text: Extract text content
# - browser_evaluate: Run JavaScript
# - browser_snapshot: Get page structure
# - browser_close: Close browser
2. 表单 Interaction
1. browser_navigate to form URL
- browser_type into input fields
- browser_click to submit
- browser_get_text to verify result
3. Data Extraction
1. browser_navigate to page
- browser_evaluate to run extraction script
- Parse returned JSON data
MCP Tools Reference
| Tool | Description |
|---|---|
browser_navigate | Navigate to URL |
browser_click | Click element by selector |
browser_type | Type text into input |
browser_select_option | Select dropdown option |
browser_get_text | Get text content |
browser_evaluate | Execute JavaScript |
browser_snapshot | Get accessible page snapshot |
browser_close | Close browser context |
browser_choose_file | Upload file |
browser_press | Press keyboard key |
Configuration Options
# Security
--allowed-hosts example.com,api.example.com
--blocked-origins malicious.com
--ignore-https-errors# Browser settings
--browser chromium|firefox|webkit
--headless
--viewport-size 1920x1080
--user-agent "Custom Agent"
# Timeouts
--timeout-action 10000 # Action timeout (ms)
--timeout-navigation 30000 # Navigation timeout (ms)
# Output
--output-dir ./playwright-output
--save-trace
--save-video 1280x720
Examples
登录 到 Website
browser_navigate: { url: "https://example.com/login" }
browser_type: { selector: "#username", text: "user" }
browser_type: { selector: "#password", text: "pass" }
browser_click: { selector: "#submit" }
browser_get_text: { selector: ".welcome-message" }
Extract 表 Data
browser_navigate: { url: "https://example.com/data" }
browser_evaluate: {
script: "() => { return Array.from(document.querySelectorAll('table tr')).map(r => r.textContent); }"
}
Screenshot
browser_navigate: { url: "https://example.com" }
browser_evaluate: { script: "() => { document.body.style.zoom = 1; return true; }" }
# Screenshot saved via --output-dir or returned in response
Security Notes
- 由 默认 restricts file system access 到 workspace root
- Host validation prevents 导航 到 untrusted domains
- Sandboxing 已启用 由 默认 (使用
--否-sandbox带有 caution) - 服务 workers blocked 由 默认
Troubleshooting
# Update browsers
npx playwright install chromium# Debug mode
npx @playwright/mcp --headless=false --output-mode=stdout
# Check installation
playwright-mcp --version
Links
免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制