Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

MCP Setup

The CLI with the skill is the recommended way to use Playwriter. It gives agents comprehensive instructions and the full Playwright API through a single execute command. Use the MCP setup below only if your client doesn't support skills or you specifically need the MCP protocol.
Note: CLI is the recommended way to use Playwriter. See quick start 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

  1. Enable the extension on at least one tab (click icon → turns green)
  2. MCP automatically starts relay server and connects to enabled tabs
  3. Use the execute tool to run Playwright code
The MCP exposes:
  • execute tool - run Playwright code snippets
  • reset tool - reconnect if connection issues occur

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.