The Playwright MCP Server is the #1 most searched MCP server globally in 2026 — beating GitHub and Figma. Its superpower is simple: it lets your AI agent drive a real browser.
Your agent can navigate pages, click buttons, fill forms, take screenshots, run E2E tests, and debug visual regressions — all through natural language commands. For developers, this means saying “write an E2E test for the checkout flow” instead of spending 30 minutes writing Playwright selectors manually.
What Is Playwright MCP?
Playwright MCP wraps Playwright (Microsoft’s browser automation framework) behind the Model Context Protocol. It exposes browser capabilities as MCP tools, letting any AI client control Chromium, Firefox, or WebKit through natural language.
Without Playwright MCP:
$ claude "Write an E2E test for the login flow" → Writes the test code but you need to run it yourself → You: copy, paste, run, debug, fix selectors...With Playwright MCP:
$ claude "Run an E2E test for the login flow" → Agent opens a real browser → Navigates to localhost:3000/login → Types credentials, clicks submit → Verifies redirect to dashboard → Takes screenshot on failure → Generates the test code from the recorded sessionInstallation
Prerequisites
- Node.js 18+
- Playwright browsers installed:
npx playwright install chromium
Docker (Recommended)
docker pull mcr.microsoft.com/playwright-mcp/server:latestClaude Code:
claude mcp add playwright \ --command docker \ --args "run -i --rm --init -e PLAYWRIGHT_MCP_HEADLESS=true mcr.microsoft.com/playwright-mcp/server"Cursor (.cursor/mcp.json):
{ "mcpServers": { "playwright": { "command": "docker", "args": [ "run", "-i", "--rm", "--init", "-e", "PLAYWRIGHT_MCP_HEADLESS=true", "mcr.microsoft.com/playwright-mcp/server" ] } }}npx Method (No Docker)
claude mcp add playwright -- npx -y @playwright/mcp@latestKey Options
| Option | What It Does | Default |
|---|---|---|
PLAYWRIGHT_MCP_HEADLESS | Run browser in headless mode | true |
PLAYWRIGHT_MCP_PORT | Server port | Random |
PLAYWRIGHT_CHROMIUM_DEBUG | See browser actions visually | false |
PLAYWRIGHT_MCP_USER_DATA_DIR | Persistent browser profile | Temp |
Verify
claude "Open https://example.com and tell me the page title" → "The page title is: Example Domain"Tools Overview
Playwright MCP exposes a rich set of browser tools:
| Tool | What It Does |
|---|---|
| browser_navigate | Go to a URL |
| browser_click | Click an element (text, selector, coordinates) |
| browser_fill | Type text into an input field |
| browser_select | Choose an option from a dropdown |
| browser_screenshot | Capture visible page or full-page |
| browser_evaluate | Run JavaScript in the page context |
| browser_wait | Wait for element or navigation |
| browser_takeover | Connect to an existing browser session |
| browser_close | Close current page |
| browser_pdf | Save page as PDF |
Real-World Workflows
Workflow 1: E2E Test Generation
The killer use case — generate Playwright tests by describing what to do:
$ claude "Record an E2E test for the checkout process"
Agent: 1. Opens browser to localhost:3000 2. Adds product to cart 3. Goes to checkout 4. Fills shipping info 5. Selects payment method 6. Completes purchase 7. Records all actions as Playwright test code 8. Saves: `tests/e2e/checkout.spec.ts`
→ You get a complete Playwright test without writing a single selector.The generated test looks like:
import { test, expect } from '@playwright/test';
test('complete checkout flow', async ({ page }) => { await page.goto('http://localhost:3000'); await page.click('text=Add to Cart'); await page.click('text=Checkout'); await page.fill('[name="email"]', 'test@example.com'); await page.fill('[name="address"]', '123 Main St'); await page.click('text=Place Order'); await expect(page.locator('text=Order Confirmed')).toBeVisible();});Workflow 2: Visual Regression Debugging
$ claude "Check what the new landing page looks like in mobile viewport"
Agent: 1. Opens browser at 375x812 (iPhone viewport) 2. Navigates to localhost:3000/landing 3. Takes a full-page screenshot 4. Compares with the baseline 5. Reports: "The hero section overlaps with the nav on mobile. Here's a screenshot showing the issue."
→ Debug visual bugs without manually resizing your browser.Workflow 3: Automated Form Testing
$ claude "Test the signup form with invalid data and verify error messages"
Agent: 1. Navigates to /signup 2. Submits empty form — verifies "Email is required" error 3. Types invalid email — verifies "Invalid email format" error 4. Types valid email, weak password — verifies password strength indicator 5. Completes full flow with valid data — verifies success redirect 6. Generates comprehensive test suiteWorkflow 4: Cross-Browser Testing
$ claude "Run the checkout test in Firefox and WebKit too"
Agent: 1. Opens Chromium → runs checkout flow 2. Opens Firefox → runs checkout flow 3. Opens WebKit → runs checkout flow 4. Compares results: "All three browsers pass. But Firefox has a 2px layout shift in the payment form."Playwright MCP vs. Other Browser Tools
| Tool | Who Controls the Browser | Best For |
|---|---|---|
| Playwright MCP | The AI agent | Automated testing, visual debugging |
| Browser Use MCP | The AI agent | General web automation (form filling, scraping) |
| Puppeteer MCP | The AI agent | Chrome-specific tasks |
| DevTools Protocol | You, manually | Debugging, profiling |
| Selenium | Scripts | Legacy browser testing |
| Cypress | Scripts | Component testing in JS |
Performance & Token Costs
Browser automation is inherently expensive in terms of tokens. Each page visit means the agent needs to process the page content, decide what to click, and interpret the result.
| Operation | Approx. Token Cost |
|---|---|
| Navigate to page | 1,000 - 3,000 tokens |
| Simple click + verify | 500 - 2,000 tokens |
| Complex form fill (5+ fields) | 3,000 - 8,000 tokens |
| Screenshot capture | 200 tokens (but image processing varies) |
| Full E2E test generation | 10,000 - 30,000 tokens |
Tips to reduce costs:
- Use
browser_waitinstead of polling - Take screenshots only when needed
- Reuse page sessions instead of opening new ones
- Limit viewport size to reduce page content token count
Security Considerations
- Headless by default: Run in headless mode for CI/CD and production. Use headed mode (
HEADLESS=false) only for debugging - Port binding: When using Docker, bind to
127.0.0.1to prevent external access - Session isolation: Each Docker container starts fresh. Don’t share user data directories across sessions
- Rate limiting: Consider using a queue system if running multiple concurrent test suites
- Never run on production: Playwright MCP is for development and staging environments only
Troubleshooting
“Browser doesn’t open”
- Did you install browsers?
npx playwright install chromium - Is Docker running?
docker ps - Try non-headless mode: set
PLAYWRIGHT_MCP_HEADLESS=false
“Can’t find elements”
- The page might be client-side rendered — add a wait:
browser_wait - Selectors might need adjustment — try using visible text:
text=Submit - The page might have loaded slowly — increase timeouts
“Tests are slow”
- Run in headed mode temporarily to see what’s happening
- Use
browser_screenshotto debug element positions - Reduce viewport size for faster rendering
Summary
Playwright MCP is the #1 trending MCP server for good reason. It turns natural language descriptions into real browser interactions. For teams writing and maintaining E2E tests, it’s arguably the most impactful MCP server you can install.
The killer combo: Playwright MCP for test generation + GitHub MCP for PR review + Firecrawl MCP for test fixture data.
Series: Practical MCP Servers for Developers — 2026 Edition. Day 4 of 6.
Advertisement
Advertisement