MCPInstall

playwright-mcp-server

Browser automation MCP server using Playwright's accessibility tree for LLM-friendly web interaction

Installs
285
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/reason-machines/mcp-skills --skill playwright-mcp-server
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads playwright-mcp-server automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Playwright MCP Server

Skill by ara.so — MCP Skills collection.

The Playwright MCP server provides browser automation capabilities through the Model Context Protocol. It enables LLMs to interact with web pages using Playwright's accessibility tree instead of screenshots, making it fast, lightweight, and deterministic.

What It Does

  • Structured interaction: Uses accessibility snapshots instead of vision models
  • Browser automation: Navigate, click, fill forms, extract data from web pages
  • Multi-browser support: Chromium, Firefox, and WebKit
  • LLM-optimized: Returns structured data that's easy for language models to parse

Installation

Add to your MCP client configuration:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

Configuration Options

Configure via args in your MCP config:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--allowed-hosts", "example.com,*.trusted-domain.com",
        "--browser", "chromium",
        "--headless", "false"
      ]
    }
  }
}

Common options:

  • --allowed-hosts <hosts...>: Comma-separated hosts (or * to disable check). Env: PLAYWRIGHT_MCP_ALLOWED_HOSTS
  • --browser <browser>: Choose chromium, firefox, or webkit
  • --headless <true|false>: Run browser in headless mode
  • --timeout <ms>: Default timeout for operations

Available Tools

The MCP server exposes these tools to LLM agents:

1. playwright_navigate

Navigate to a URL and get accessibility snapshot.

Parameters:

  • url (string, required): URL to navigate to

Example usage:

// Agent will call this tool
{
  "url": "https://example.com"
}

Returns: Accessibility tree snapshot of the page

2. playwright_click

Click an element identified by its accessibility role and name.

Parameters:

  • selector (string, required): Element selector (role, text, or CSS)
  • button (string, optional): left, right, or middle (default: left)

Example usage:

{
  "selector": "button[name='Submit']",
  "button": "left"
}

3. playwright_fill

Fill an input field with text.

Parameters:

  • selector (string, required): Input field selector
  • value (string, required): Text to fill

Example usage:

{
  "selector": "input[name='email']",
  "value": "user@example.com"
}

4. playwright_screenshot

Take a screenshot of the page or element.

Parameters:

  • selector (string, optional): Element to screenshot (defaults to full page)
  • path (string, optional): File path to save screenshot

Example usage:

{
  "selector": "div.main-content",
  "path": "./screenshots/content.png"
}

5. playwright_evaluate

Execute JavaScript in the page context.

Parameters:

  • expression (string, required): JavaScript to execute

Example usage:

{
  "expression": "document.title"
}

6. playwright_snapshot

Get current accessibility snapshot without navigation.

Example usage:

{}

Common Patterns

Form Automation

// Navigate to login page
await playwright_navigate({ url: "https://app.example.com/login" });

// Fill credentials
await playwright_fill({
  selector: "input[name='username']",
  value: "user@example.com"
});

await playwright_fill({
  selector: "input[type='password']",
  value: process.env.USER_PASSWORD  // Use env vars for secrets
});

// Submit form
await playwright_click({
  selector: "button[type='submit']"
});

// Verify login
const snapshot = await playwright_snapshot({});
// Parse snapshot to confirm successful login

Data Extraction

// Navigate to data page
await playwright_navigate({ url: "https://example.com/products" });

// Extract product information
const products = await playwright_evaluate({
  expression: `
    Array.from(document.querySelectorAll('.product')).map(p => ({
      name: p.querySelector('.name')?.textContent,
      price: p.querySelector('.price')?.textContent
    }))
  `
});

Multi-Step Workflow

// Search flow
await playwright_navigate({ url: "https://example.com" });

await playwright_fill({
  selector: "input[placeholder='Search']",
  value: "playwright automation"
});

await playwright_click({
  selector: "button[aria-label='Search']"
});

// Wait for results by getting snapshot
const results = await playwright_snapshot({});

// Click first result
await playwright_click({
  selector: "a.result-item:first-child"
});

// Capture final page
await playwright_screenshot({
  path: "./evidence/result-page.png"
});

Testing Accessibility

// Navigate to page under test
await playwright_navigate({ url: "https://myapp.com/dashboard" });

// Get accessibility tree
const snapshot = await playwright_snapshot({});

// The snapshot will show:
// - Missing ARIA labels
// - Elements without proper roles
// - Navigation structure
// Parse snapshot to validate accessibility

Accessibility Selectors

Playwright MCP uses accessible selectors. Prefer:

// Good: Role-based selectors
"button[name='Submit']"
"link[name='Documentation']"
"textbox[name='Email']"

// Good: ARIA attributes
"[aria-label='Close dialog']"
"[role='navigation']"

// Okay: Text content
"text=Click here"

// Last resort: CSS selectors
"div.modal > button.close"

Working with Snapshots

Accessibility snapshots are structured representations of the page:

// Example snapshot structure
{
  "role": "WebArea",
  "name": "Example Page",
  "children": [
    {
      "role": "button",
      "name": "Submit",
      "focusable": true
    },
    {
      "role": "textbox",
      "name": "Email",
      "value": "user@example.com"
    }
  ]
}

Use snapshots to:

  • Understand page structure
  • Identify interactive elements
  • Validate content presence
  • Find navigation paths

Troubleshooting

Host Not Allowed

Error: Host not allowed: example.com

Solution: Add to allowed hosts:

{
  "args": [
    "@playwright/mcp@latest",
    "--allowed-hosts", "example.com,*.example.com"
  ]
}

Or disable checks (development only):

{
  "args": ["@playwright/mcp@latest", "--allowed-hosts", "*"]
}

Element Not Found

Error: Element not found: button[name='Submit']

Solutions:

  1. Get current snapshot to see available elements:

    const snapshot = await playwright_snapshot({});
    
  2. Use more flexible selectors:

    // Instead of exact match
    "button[name*='submit']"  // Contains 'submit'
    "text=/submit/i"           // Case-insensitive regex
    
  3. Wait for element by evaluating:

    await playwright_evaluate({
      expression: `
        new Promise(resolve => {
          const check = () => {
            if (document.querySelector('button[name="Submit"]')) {
              resolve(true);
            } else {
              setTimeout(check, 100);
            }
          };
          check();
        })
      `
    });
    

Timeout Issues

Error: Timeout waiting for element

Solution: Increase timeout:

{
  "args": ["@playwright/mcp@latest", "--timeout", "60000"]
}

Or wait explicitly:

await playwright_evaluate({
  expression: "new Promise(r => setTimeout(r, 2000))"
});

Browser Not Launching

Error: Failed to launch browser

Solutions:

  1. Check browser installation:

    npx playwright install chromium
    
  2. Try different browser:

    {
      "args": ["@playwright/mcp@latest", "--browser", "firefox"]
    }
    
  3. Run in headed mode for debugging:

    {
      "args": ["@playwright/mcp@latest", "--headless", "false"]
    }
    

Best Practices

  1. Use environment variables for secrets:

    // Never hardcode credentials
    await playwright_fill({
      selector: "input[type='password']",
      value: process.env.PASSWORD
    });
    
  2. Take snapshots for debugging:

    // Before and after critical actions
    const beforeSnapshot = await playwright_snapshot({});
    await playwright_click({ selector: "button[name='Delete']" });
    const afterSnapshot = await playwright_snapshot({});
    
  3. Prefer accessibility selectors:

    // Robust to UI changes
    "button[name='Save']"
    // vs fragile CSS
    "div.container > div:nth-child(2) > button.primary"
    
  4. Handle navigation timing:

    await playwright_navigate({ url: "https://example.com" });
    // Snapshot after navigate includes wait for load
    const snapshot = await playwright_snapshot({});
    
  5. Combine tools for complex workflows:

    // Navigate → Inspect → Act → Verify
    await playwright_navigate({ url: "..." });
    const structure = await playwright_snapshot({});
    await playwright_fill({ ... });
    await playwright_click({ ... });
    const result = await playwright_snapshot({});
    

vs Playwright CLI

Use Playwright MCP when:

  • Building chat-based automation agents
  • Need persistent browser state across tool calls
  • Iterative reasoning over page structure
  • Long-running autonomous workflows

Use Playwright CLI + SKILLS when:

  • Working with coding agents that favor CLI tools
  • Token efficiency is critical
  • Managing large codebases alongside automation
  • Need concise, purpose-built commands

FAQ

What does the playwright-mcp-server skill do?

Browser automation MCP server using Playwright's accessibility tree for LLM-friendly web interaction

How do I install playwright-mcp-server?

Run npx skills add https://github.com/reason-machines/mcp-skills --skill playwright-mcp-server in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/playwright-mcp-server/ (personal) or .claude/skills/playwright-mcp-server/ (project).

Which AI agents can use playwright-mcp-server?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is playwright-mcp-server safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains playwright-mcp-server?

It is published by reason-machines in reason-machines/mcp-skills. It has 285 recorded installs.

More from reason-machines/mcp-skills

View all →

codebase-memory-mcp-intelligence

reason-machines/mcp-skills

High-performance code intelligence MCP server that indexes codebases into knowledge graphs for structural queries, call traces, and architecture analysis

AI & Agents505 installs

tradingview-mcp-assistant

reason-machines/mcp-skills

Open the skill to read its SKILL.md instructions.

AI & Agents256 installs

lanhu-mcp-collaboration

reason-machines/mcp-skills

Open the skill to read its SKILL.md instructions.

AI & Agents245 installs

github-mcp-server

reason-machines/mcp-skills

Open the skill to read its SKILL.md instructions.

AI & Agents237 installs

google-meta-ads-ga4-mcp

reason-machines/mcp-skills

Open the skill to read its SKILL.md instructions.

AI & Agents233 installs

chrome-devtools-mcp-automation

reason-machines/mcp-skills

Open the skill to read its SKILL.md instructions.

AI & Agents233 installs

Popular ai & agents skills

View category →

google-agents-cli-publish

google/agents-cli

This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).

AI & Agents513.9K installs

google-agents-cli-eval

google/agents-cli

This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).

AI & Agents513.5K installs

skill-creator

anthropics/skills

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

OfficialAI & Agents416.4K installs

codex-pet

prime-skills/runcomfy-agent-skills

Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.

AI & Agents402.1K installs

full-output-enforcement

leonxlnx/taste-skill

Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.

AI & Agents401K installs

executing-plans

obra/superpowers

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

AI & Agents245.7K installs