New pages: - docs/installation: extension, CLI, and skill install steps - docs/cli: full CLI reference with all commands, flags, context variables - docs/mcp-setup: imports MCP.md, notes CLI+skill is recommended - docs/use-cases: web dev, QA, task automation, API reverse engineering, remote support, screen recording, scraping JS-heavy sites - docs/troubleshooting: relay logs, known issues, common problems - docs/skill: imports skill.md as agent reference with install instructions Also: - docs.json: grouped navigation (Getting Started, Guides, Use Cases, Reference) with lucide icons - remote-access.mdx: add icon, narrow diagrams by 3 chars - MCP.md: fix PLAYWRITER_AUTO_ENABLE docs (enabled by default, show how to disable) Session: ses_125455d3bffeungwcwjb0OcK66
2.7 KiB
MCP Setup
Note: CLI is the recommended way to use Playwriter. See README.md for CLI usage.
Add to your MCP client settings:
{
"mcpServers": {
"playwriter": {
"command": "npx",
"args": ["-y", "playwriter@latest"]
}
}
}
Or auto-configure:
npx -y @playwriter/install-mcp playwriter@latest
Using the MCP
- Enable the extension on at least one tab (click icon → turns green)
- MCP automatically starts relay server and connects to enabled tabs
- Use the
executetool to run Playwright code
The MCP exposes:
executetool - run Playwright code snippetsresettool - reconnect if connection issues occur
Environment Variables
PLAYWRITER_AUTO_ENABLE
Auto-creates a tab when Playwright connects (no manual extension click needed). Enabled by default in both CLI and MCP. The auto-created tab starts at about:blank; navigate it to any URL.
Set PLAYWRITER_AUTO_ENABLE=false to disable and require manually enabling the extension on a tab before connecting:
{
"mcpServers": {
"playwriter": {
"command": "npx",
"args": ["-y", "playwriter@latest"],
"env": {
"PLAYWRITER_AUTO_ENABLE": "false"
}
}
}
}
Direct CDP (no extension needed)
Connect directly to Chrome's DevTools Protocol without the extension. Set PLAYWRITER_DIRECT in your MCP config:
{
"mcpServers": {
"playwriter": {
"command": "npx",
"args": ["-y", "playwriter@latest"],
"env": {
"PLAYWRITER_DIRECT": "1"
}
}
}
}
Enable debugging in Chrome first: open chrome://inspect/#remote-debugging or launch with --remote-debugging-port=9222.
Chrome 136+ may show an approval dialog the first time a connection is made.
You can also pass an explicit WebSocket endpoint: PLAYWRITER_DIRECT=ws://127.0.0.1:9222/devtools/browser/abc.
Limitation: screen recording is unavailable in direct mode.
Remote Agents (Devcontainers, VMs, SSH)
Run agents in isolated environments while controlling Chrome on your host.
On host (where Chrome runs):
npx -y playwriter serve --token <secret>
In container/VM (where agent runs):
{
"mcpServers": {
"playwriter": {
"command": "npx",
"args": ["-y", "playwriter@latest", "--host", "host.docker.internal", "--token", "<secret>"]
}
}
}
Or with environment variables:
{
"mcpServers": {
"playwriter": {
"command": "npx",
"args": ["-y", "playwriter@latest"],
"env": {
"PLAYWRITER_HOST": "host.docker.internal",
"PLAYWRITER_TOKEN": "<secret>"
}
}
}
}
Use host.docker.internal for devcontainers, or your host's IP for VMs/SSH.