playwright-e2e-mcp
The test doctor for AI agents.
Your Playwright test fails. Your AI finds out why, fixes it, and proves the fix works, or tells you it's a real bug.
⭐ If it saves you a debugging session, a star helps other Playwright users find it.
Quick start · Features · Tools · Tool reference · GitHub Action · Benchmark · Changelog
An MCP server and agent skill that gives Claude, Cursor, VS Code Copilot, Codex, Gemini and any other MCP client a full Playwright toolkit: a test runner, a failure detective and a fixer that checks its own work. Browser MCPs let an AI click around a page. This one lets it keep your test suite green, for TypeScript and Python suites, on your laptop and in CI. Free, MIT, no account.
❌ Without it / ✅ With it
Without it, your agent sees Timeout 5000ms exceeded waiting for getByTestId('checkout'),
guesses a new selector, edits the test and hopes. Or it "fixes" the test by deleting the
assertion that caught a real bug.
With it, your agent reads the page as it was when the test failed (from the Playwright trace), swaps in a locator proven unique on that page, re-runs the test and keeps the edit only if it passes. When the button is really gone, it says so: that's an app bug, not a test to patch. And a heal guard blocks any "fix" that went green by checking less.
flowchart LR
A["run-test<br/>or load-report (CI)"] --> B["get-failure<br/>DOM at failure, requests, console"]
B --> C{"suggest-fix"}
C -->|"locator proven on the page"| D["apply + re-run"]
D -->|green| E["✅ fixed and verified"]
D -->|still red| F["↩️ edit reverted"]
C -->|"element really gone"| G["🐞 reported as an app bug"]
D -.-> H["check-test-change<br/>blocks fixes that check less"]
⚡ Quick start
Run this in your project root. It adds the server to every MCP client config it finds (Claude Code, Cursor, VS Code, Gemini CLI, Codex), installs the agent skill and leaves your other servers alone:
npx -y playwright-e2e-mcp init # --client all | cursor,vscode … · --dry-run
npx -y playwright-e2e-mcp doctor # checks Node, Playwright, browsers, client setup and updates
Then restart your client and ask:
Run my Playwright tests and fix whatever fails.
Or let your agent install it. Paste this into any coding agent:
Install the playwright-e2e-mcp server and skill by following https://raw.githubusercontent.com/xsignon-secure/E2E/main/llms-install.md
Or add the standard config by hand (works in most clients):
{
"mcpServers": {
"playwright-e2e": {
"command": "npx",
"args": ["-y", "playwright-e2e-mcp"]
}
}
}
Needs: Node.js 22+, and a project with @playwright/test and a browser
(npx playwright install chromium) or with pytest-playwright.
The server uses its working directory as the project root; if your client starts it elsewhere,
add "env": { "PW_MCP_PROJECT_ROOT": "/path/to/your/project" }.
Claude Code
Server and skill, as a plugin:
/plugin marketplace add xsignon-secure/E2E
/plugin install playwright-e2e-mcp@xsignon-secure
Or the server only:
claude mcp add playwright-e2e -- npx -y playwright-e2e-mcp
Claude Desktop
Download the .mcpb extension from the latest release
and double-click it. It ships its own dependencies, so no Node setup is needed. On install it
asks for your project root: choose the project folder, not your home directory.
You can also add the standard config to claude_desktop_config.json.
Cursor
Click Install in Cursor,
or go to Settings → MCP → Add new MCP server and paste the standard config. For one
project only, put it in .cursor/mcp.json.
Only fixing failing tests? Install the core tools only: the seven-tool fix loop
(--tools=core), about 2.3k tokens of tool definitions instead of 12.1k.
VS Code / GitHub Copilot
Click the Install in VS Code button above, or run:
code --add-mcp '{"name":"playwright-e2e","command":"npx","args":["-y","playwright-e2e-mcp"]}'
Codex
codex mcp add playwright-e2e -- npx -y playwright-e2e-mcp
A Playwright run with retries can take longer than Codex's default 60 s tool timeout. Raise
the timeouts in ~/.codex/config.toml:
[mcp_servers.playwright-e2e]
command = "npx"
args = ["-y", "playwright-e2e-mcp"]
startup_timeout_sec = 60
tool_timeout_sec = 600
Gemini CLI / Qwen Code
Server and skill, as an extension:
gemini extensions install https://github.com/xsignon-secure/E2E
Or paste the standard config into .gemini/settings.json (Qwen Code: .qwen/settings.json).
Windsurf, Cline, Zed, Freebuff and other clients
Add the standard config to the client's MCP config file (Cline: MCP Servers → Configure).
Clients that take a command, such as Zed, run npx with the arguments -y playwright-e2e-mcp.
Freebuff / Codebuff: drop an mcp.json with the standard config into your project's .agents/
folder. This repo ships one in .agents/mcp.json; Freebuff asks you to trust
a repository's .agents/ on first run.
ChatGPT, claude.ai and other remote-only clients
Some clients only accept a remote HTTPS server. This repo ships a Streamable HTTP bridge you can host for free on Vercel, with OAuth sign-in for claude.ai connectors (dynamic registration and Client ID Metadata Documents). See Hosted endpoint. On Vercel the page tools (inspect a page, check selectors, accessibility and Web Vitals audits) run on a bundled Chromium against public URLs. Running and fixing your own tests needs your project, so use the local install for that.
Other ways to install: skill only, Docker, registry, tarball
| Route | How |
|---|---|
| Skill only, any agent | npx skills add xsignon-secure/E2E |
| MCP Registry | io.github.xsignon-secure/E2E (listing); registry-aware clients find it there |
| Docker | docker run -i --rm -v "$PWD:/work" ghcr.io/xsignon-secure/playwright-e2e-mcp (published on each release; see Development) |
| Straight from GitHub, no npm | npx -y github:xsignon-secure/E2E#v0.13.0 (pin a release tag) |
| Release tarball | npm install -D https://github.com/xsignon-secure/E2E/releases/download/v0.13.0/playwright-e2e-mcp-0.13.0.tgz |
| Local checkout | "command": "node", "args": ["/path/to/E2E/dist/index.js"] |
Updating
| Installed with | To update |
|---|---|
npx -y playwright-e2e-mcp (the setup above, and what init writes) |
Restart your MCP client. npx (npm 10, which comes with Node 22) asks npm for the latest version on each launch and fetches it. |
npm install -D playwright-e2e-mcp in the project |
npm install -D playwright-e2e-mcp@latest |
npm install -g playwright-e2e-mcp |
npm install -g playwright-e2e-mcp@latest |
GitHub Action uses: xsignon-secure/E2E@v0.x.y |
Change the tag (Dependabot's github-actions updates do it for you) |
| Docker | docker pull ghcr.io/xsignon-secure/playwright-e2e-mcp:latest |
Claude Desktop bundle (.mcpb) |
Download the new bundle from the latest release and open it |
| Git clone | git pull && npm ci |
Agent skill copied by init or npx skills add |
Run the same command again |
npx -y playwright-e2e-mcp doctor tells you whether a newer version is out and prints the
command for your setup. Upgrade notes for each release are on the
releases page.
💬 What you can ask
| You ask your AI… | It does this | |
|---|---|---|
| 🏃 | "Run my tests" | Runs the suite and reports every failure with file, line, cause and a fix hint. One root cause breaking 30 tests shows up as one problem. |
| 🔍 | "Why did this fail?" | Reads Playwright's trace: the page at the moment of failure, the broken request, the console error. No guessing. |
| 🛠️ | "Fix it" | Swaps in a locator proven unique on that page, re-runs the test and undoes the edit if it's still red. If the element is really gone, it tells you it's an app bug. |
| ☁️ | "Why did CI fail?" | Loads the CI job's report (sharded blob reports too) and its traces, so the same diagnosis and fixes work on CI failures. |
| 🎲 | "Is this test flaky?" | Re-runs it with retries off, alone and in shuffled order, and names the race, the shared state or the test it depends on, with the seed that reproduces it. |
| 🎯 | "Which commit broke this?" | Bisects git history in a throwaway worktree and names the first bad commit, its diff and the failure there. |
| 📈 | "What's been breaking lately?" | Ranks flaky, newly broken and slow tests from the run history and names the commit where each went bad. |
| 🧊 | "Quarantine this flaky test" | Keeps it running and reported but stops it failing the build, with an owner and an expiry date. |
| 🛡️ | "Did that fix cheat?" | Compares the changed tests with git and blocks a fix that passes by deleting assertions, skipping tests or adding .only. |
| ✍️ | "Write a test for this flow" | Walks the steps on the live page, writes a spec with real locators and assertions on where the flow landed, and runs it once to prove it passes. |
| 🔑 | "Log in and save the session" | Signs in once, 2FA codes included (generated from your TOTP secret), checks the session and saves it. The password never passes through the chat. |
| ♿ | "Check this page for accessibility" | Runs axe-core (WCAG 2.2 AA) and returns each problem with a verified locator and a ready regression test. |
| ⚡ | "Why is this page slow?" | Measures Web Vitals (LCP, CLS, INP, TBT) on desktop or a throttled phone, names the slow and shifting elements, and hands back a budget test. |
| 🐍 | "Run my pytest suite" | Runs pytest-playwright projects with the same failure diagnosis and traces. |
✨ What you get
🩺 A fix loop that proves itself
- Fixes are verified, not guessed.
suggest-fixpicks a locator proven unique on the DOM at failure, writes it, re-runs the test and reverts if it's still red. Strict-mode violations get the locator of the intended match; changed copy gets the new expected text. - Honest about real bugs. When the element is really gone, it refuses to patch the test and reports an app bug.
- Heal guard.
check-test-change(andplaywright-e2e-mcp guardin CI) blocks a "fix" that went green by deleting an assertion, skipping the test, adding.only, swallowing the error or moving an assertion under anif, and warns on weaker matchers, hard waits, forced clicks, early returns and raised timeouts.runtime: truealso runs the old and new version and blocks a test that now executes fewer assertions, which catches what no code scan can. Works for pytest-playwright files too. - Asks before it writes. Applying a fix, writing a test, quarantining or replacing a visual
baseline shows you the exact diff and waits for your yes in clients that support MCP
questions (
PW_MCP_CONFIRM_WRITES).
🔬 Flaky tests, history and the breaking commit
- Flaky verdicts with evidence.
diagnose-flakytells a race from shared state from a test-order dependency, and gives the seed that replays it. - Quarantine with an owner and an expiry. The test keeps running and being reported; it stops blocking the build until the date you set.
- Memory of every run.
analyze-historyranks flaky, regressed, broken and slow tests and names the commit where each went bad. Share one history across every CI job and laptop with the free, self-hosted history server (onedocker run, dashboard included). bisect-failurefinds the first bad commit without touching your checkout.audit-testsfinds flake risks in the test code (hard waits, one-shot assertions, missingawaits, fragile selectors, clicks right aftergotoon a server-rendered app), ranks them by real flakiness and applies the safe rewrites with a verifying run.
⚡ Hydration races and stale mocks
- The "too fast" click. On Next.js, Nuxt, Remix, Astro and other server-rendered apps the HTML
is clickable before JavaScript attaches its handlers, so a test clicks, the step passes and
nothing happens.
inspect-pagenames the framework and measures how long controls were on screen before hydration;get-failureanddiagnose-flakyflag a click made while the page's scripts were still downloading and hydration errors in the console; each comes with the wait to add. - Mocks that drifted from the API.
check-mocks(andplaywright-e2e-mcp mocksin CI) finds everyroute.fulfillJSON body androuteFromHARrecording, calls the real endpoint (GET only) and reports the fields the mock relies on that the API no longer sends, changed types, new nulls and removed endpoints, so a green suite stops hiding a broken contract.
🔗 CI runs by URL, remote browsers, Python fixes and AI chat UIs
-
Paste the CI run, skip the download. Give
load-reporta GitHub Actions run or GitLab job URL. It fetches the report and traces with your ownGITHUB_TOKEN/GITLAB_TOKEN, maps them onto your checkout, andget-failureandsuggest-fixwork on that run.{ "report": "https://github.com/acme/shop/actions/runs/123456789" } -
Any browser, anywhere. The page tools take
connect: a Playwright server (npx playwright run-server), a browser grid or device cloud, or a Chrome over CDP. Keys stay in the environment as{{env:…}}, never in chat.{ "url": "https://staging.example.com", "connect": "wss://grid.example.com/playwright?key={{env:E2E_GRID_KEY}}" } -
Fixes for pytest suites.
suggest-fixnow patchestest_*.pyfiles in Python syntax and re-runs the test with pytest before keeping the change:- page.get_by_test_id("checkout-button").click() + page.get_by_role("button", name="Checkout").click() -
AI chat and streaming UIs. The agent skill shows how to test answers that stream in: mock the model's stream, wait for the "done" signal instead of the text, and check shape rather than exact wording against a live model.
await expect(page.getByRole('button', { name: 'Stop' })).toBeHidden(); await expect(page.getByTestId('message').last()).toHaveText('Hello, world!');
🤖 CI that comments with working fixes
- GitHub Action that writes the diagnosis to the job summary, keeps one PR comment up to date and posts each verified fix as a suggested change reviewers apply with one click.
- GitLab CI template and a plain
cicommand for Jenkins, CircleCI or anything else. - Diagnose CI locally:
load-reportmaps a CI job's report and traces onto your checkout.
🌐 Page tools with locators that already work
inspect-pagereturns a compact map of verified Playwright locators (about 570 tokens for a storefront page, against 2,300 for a Playwright MCP snapshot), or the full DOM inventory, or the accessibility snapshot with a readytoMatchAriaSnapshotassertion.- Reaches the hard screens: saved logins, headers, click and fill steps, popups and new tabs, API mocks (500s, empty lists, slow calls), HAR record and replay, phone and tablet presets, Chromium, Firefox, WebKit, Chrome and Edge.
- Look without changing anything:
blockWritesstops POST, PUT, PATCH and DELETE requests from reaching a real backend. - Accessibility, Web Vitals and visual diffs that return locators and ready tests, not just a score.
🚀 Built for agents in 2026
- Lean on context. Start with
--tools=auto(about 2.4k tokens of tool definitions instead of 12.1k) and the agent loads the page, audit or history tools when it needs them, or pick a profile:core,triage,inspect,author. - Interactive test report in MCP Apps clients (Claude, ChatGPT, Cursor): filter failures, see expected vs. received, re-run or "Ask to fix" in one click.
- Current MCP: the stateless 2026-07-28 revision (2025 clients still work), structured results with output schemas, tool annotations for accurate safety prompts, the skill served over the Skills extension, and a Server Card for discovery.
- Everywhere you work: npm, Claude Code plugin, Claude Desktop bundle, Gemini CLI extension, Docker image on GHCR, and an HTTP bridge with OAuth for remote-only clients.
🧰 Tools
| Tool | Purpose |
|---|---|
run-test |
Run Playwright tests and return stats, failures grouped by root cause, diagnostics and hints; background: true returns a run id for long suites |
get-run-status |
Progress or final result of a background run; can wait for it or cancel it |
get-failure |
Deep analysis of one failure: stack, expected/actual, DOM snapshot at failure (from the trace), failed requests, console errors, next steps |
load-report |
Load a run from CI (JSON report, sharded blob reports, or straight from a GitHub Actions run or GitLab job URL), map its paths onto the checkout and find the traces, so every other tool works on it |
suggest-fix |
Patch a failure with a locator proven unique on the DOM at failure or the new expected text; apply: true writes it, re-runs and reverts if still red |
check-test-change |
Heal guard: BLOCK deleted assertions, skipped or removed tests, .only and assertions moved under an if; WARN on weaker matchers, hard waits, force: true |
