Install browser binaries (if not already installed)
npx playwright install chromium
Verify installation
playwright-mcp --version </setup>
<architecture> Playwright MCP is an MCP server that exposes Playwright's browser automation capabilities through the Model Context Protocol. It communicates via stdio and provides tools for: - Page navigation (goto, goBack, goForward, reload) - Element interaction (click, fill, hover, select) - Screenshots and snapshots - JavaScript evaluation - Network and console monitoringKey advantage: Snapshot-based approach takes incremental DOM snapshots instead of full page state, making it significantly faster and more reliable for AI-driven automation. </architecture>
<configuration> ## MCP Server ConfigurationFor Claude Desktop or compatible MCP clients, add to configuration:
json
{
"mcpServers": {
"playwright": {
"command": "playwright-mcp",
"args": [
"--headless",
"--browser", "chromium",
"--snapshot-mode", "incremental"
]
}
}
}
Common Options
- •
--browser <browser>: chrome, firefox, webkit, msedge - •
--headless: Run headless (no visible window) - •
--device <device>: Emulate device (e.g., "iPhone 15") - •
--viewport-size <size>: Set viewport (e.g., "1280x720") - •
--snapshot-mode <mode>: incremental, full, or none - •
--caps <caps>: Enable vision, pdf, devtools capabilities - •
--save-trace: Save Playwright trace for debugging - •
--save-video <size>: Record video (e.g., "800x600") - •
--user-data-dir <path>: Persistent browser profile - •
--storage-state <path>: Load saved auth state </configuration>
The MCP server exposes tools that can be called from any MCP-compatible client:
javascript
// Navigate to a page
await mcp.call("playwright_navigate", {
url: "https://example.com"
});
// Click an element
await mcp.call("playwright_click", {
selector: "button#submit"
});
// Fill a form field
await mcp.call("playwright_fill", {
selector: "input[name='email']",
value: "user@example.com"
});
// Take a screenshot
await mcp.call("playwright_screenshot", {
path: "screenshot.png",
fullPage: true
});
// Get page snapshot (incremental DOM state)
await mcp.call("playwright_snapshot");
Advanced Patterns
Persistent Session (with login state)
bash
playwright-mcp \ --user-data-dir ./browser-profile \ --storage-state ./auth.json
Visual Debugging
bash
playwright-mcp \ --headless=false \ --caps vision \ --save-trace
Device Emulation
bash
playwright-mcp \ --device "iPhone 15" \ --caps vision
Recording Sessions
bash
playwright-mcp \ --save-video=1920x1080 \ --save-trace \ --output-dir ./recordings
Current Status: Playwright MCP is installed and functional as a standalone tool. Direct integration with OpenClaw's agent system is pending investigation.
Workarounds:
- •Use via subprocess: Spawn playwright-mcp and communicate via stdio
- •Use traditional Playwright library (see
skills/playwright/SKILL.md) - •Use OpenClaw's built-in
browsertool for simpler automation
Future Work:
- •Investigate OpenClaw's MCP server configuration mechanism
- •Create plugin/extension for native MCP server support
- •Document integration with OpenClaw's agent context </integration>
Server won't start
bash
# Check installation playwright-mcp --version which playwright-mcp # Check browser binaries npx playwright install --dry-run chromium
Automation fails
bash
# Run headed to see what's happening playwright-mcp --headless=false # Enable trace recording playwright-mcp --save-trace --output-dir ./debug # Check console logs playwright-mcp --console-level debug
Performance issues
bash
# Use incremental snapshots (default) playwright-mcp --snapshot-mode incremental # Disable unnecessary features playwright-mcp --image-responses omit --caps none
Trace Viewer
bash
# View saved traces npx playwright show-trace trace.zip