mcp-playwright-test-runner
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-playwright-test-runner run the login tests and tell me what broke"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-playwright-test-runner
An MCP server that lets an AI client (Claude Code, Cursor, any MCP host) list, run and read your Playwright tests.
When an agent writes or fixes tests it needs three things: which tests exist, what happened when they ran, and why one failed. Normally that means copying terminal output back into the chat. This server exposes those three as MCP tools over stdio, so the agent can call them itself and keep working.
Tools
Tool | What it does | What it returns |
| Lists the tests Playwright can see, without running them | count, title, file, line, project |
| Runs the suite, or a filtered part of it ( |
|
| Reads a finished run back by | per-test status, duration, retries, error line |
| Explains a failure | full error, stack, location, captured stdout/stderr, screenshot and trace paths |
Everything is plain JSON in a text content block, so any MCP client can read it.
Related MCP server: Pluswithai MCP Server
Quickstart
git clone https://github.com/AmrAsaad1025/mcp-playwright-test-runner.git
cd mcp-playwright-test-runner
npm install
npx playwright install chromium
npm run buildPoint it at your own Playwright project with Claude Code:
claude mcp add playwright-tests -- node "$(pwd)/dist/index.js" --project-dir /path/to/your/playwright/projectOr drop it into .mcp.json:
{
"mcpServers": {
"playwright-tests": {
"command": "node",
"args": ["/absolute/path/dist/index.js", "--project-dir", "/absolute/path/to/project"],
"env": { "PW_TIMEOUT_MS": "600000" }
}
}
}Then ask the agent something like "run the login tests and tell me what broke".
Try it without your own project
examples/demo-project is a small Playwright suite (a local login + cart page, 4 tests, no network). The demo drives the server over stdio exactly like a client would:
npm run demo→ tools/list
list_tests List the tests Playwright can see in the configured project without running them.
run_tests Run the Playwright suite, or a filtered part of it, and return a compact summary plus a run_id.
get_results Read back a finished run: per-test status, duration, retry count and the first line of any error.
get_failure_details Explain why tests failed: full error message, stack, location, captured stdout/stderr and the screenshot or trace paths Playwright saved.
→ list_tests {}
4 tests
- Cart › adds a product to the cart (cart.spec.ts:12)
- Cart › filters products by name (cart.spec.ts:20)
- Login › shows the shop after a valid login (login.spec.ts:4)
- Login › rejects a wrong password (login.spec.ts:14)
→ run_tests {}
run_id run-001 status passed 3.7s
total 4 passed 4 failed 0 skipped 0 flaky 0
→ get_results { run_id: "run-001" }
passed 517ms Cart › adds a product to the cart
passed 443ms Cart › filters products by name
passed 342ms Login › shows the shop after a valid login
passed 297ms Login › rejects a wrong password
→ run_tests { file: "tests/zz-demo-failure.spec.ts" } (a broken test, written for this demo)
run_id run-002 status failed
order total includes the T-Shirt: Error: expect(locator).toHaveText(expected) failed
→ get_failure_details { run_id: "run-002" }
order total includes the T-Shirt (tests/zz-demo-failure.spec.ts:12:40)
| Error: expect(locator).toHaveText(expected) failed
|
| Locator: locator('#total')
| Expected: "25.00"
| Received: "10.00"
| Timeout: 5000ms
captured output: cart total after one add: 10.00
attachment: screenshot -> test-results/zz-demo-failure-order-total-includes-the-T-Shirt-chromium/test-failed-1.png
attachment: error-context -> test-results/zz-demo-failure-order-total-includes-the-T-Shirt-chromium/error-context.md
attachment: trace -> test-results/zz-demo-failure-order-total-includes-the-T-Shirt-chromium/trace.zipHow it works
The server spawns the Playwright CLI in the target project with
--reporter=jsonandPLAYWRIGHT_JSON_OUTPUT_NAMEpointing at a temp file. The report comes from that file, so anything a test prints to stdout cannot corrupt it.src/playwright/report.tsflattens the nested reporter JSON into one row per test, keeping describe titles, retry counts, attachments and stdout.Each run is stored in memory under a
run_id(last 20 by default), so later tool calls read the detail without running the suite again.A run that goes past
PW_TIMEOUT_MSis killed and reported astimed_out.A non-zero exit that collected no tests is reported as
errorwith the tail of stderr, because "the suite never started" and "the suite failed" need different reactions.Error text is stripped of ANSI colour codes and truncated per field, so it reads properly in a chat.
Configuration
Setting | Flag or env | Default |
Project to test |
| current directory |
Playwright command |
|
|
Run timeout |
| 600000 (10 min) |
Runs kept in memory |
| 20 |
Project layout
src/index.ts entry point, stdio transport
src/server.ts registers the four tools
src/tools/ one file per tool, plain functions over injected deps
src/playwright/report.ts JSON reporter parser
src/playwright/runner.ts child process, output capture, timeout
src/playwright/runs.ts in-memory run history
examples/demo-project/ small Playwright suite used by the demo and the e2e test
scripts/demo.ts MCP client that walks through the whole flow
test/ unit, protocol and end-to-end testsTests
npm test # 17 tests, no browser needed (the Playwright CLI is stubbed)
REAL_PW=1 npm test # also runs a real Chromium run against examples/demo-projectFile | What it covers |
| reporter parsing: passes, failures, flaky retries, skips, global errors, bad JSON |
| each tool's output, the timeout path, run history, unknown run ids |
| the real server over stdio: |
| a real Playwright run through the protocol (needs a browser) |
CI runs the typecheck, the tests with REAL_PW=1, the build, and the demo on every push.
Limits
stdio transport only; no HTTP/SSE server yet.
One project per server process. Run a second server for a second project.
The run history is memory-only, so restarting the server forgets earlier runs.
The environment running the server needs a Playwright browser installed.
It is a way for an agent to read a run it triggered, not a replacement for a CI dashboard.
License
MIT
Available Tools
4 toolsget_failure_detailsGet failure detailsA
Explain why tests failed: full error message, stack, location, captured stdout/stderr and the screenshot or trace paths Playwright saved. Defaults to every failure in the most recent run.
Inputs: test, run_id, max_chars.
get_resultsGet run resultsA
Read back a finished run: per-test status, duration, retry count and the first line of any error. Defaults to the most recent run.
Inputs: run_id, include_attachments.
list_testsList Playwright testsA
List the tests Playwright can see in the configured project without running them. Use it to find out what exists, or to get exact titles before filtering a run with grep.
Inputs: file, grep, project, timeout_ms.
run_testsRun Playwright testsA
Run the Playwright suite, or a filtered part of it, and return a compact summary plus a run_id. Use get_results or get_failure_details with that run_id for detail. A run that goes past the timeout is killed.
Inputs: file, grep, project, retries, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool maps to a distinct phase of the workflow: discovery, execution, result summarization, and failure diagnosis. The boundary between get_results and get_failure_details is explicitly clarified as summary versus detailed diagnostics.
All tools use a consistent snake_case verb_noun pattern: list_tests, run_tests, get_results, get_failure_details. The convention is predictable throughout.
Four tools exactly cover the core test-runner workflow without filler. Each tool earns its place and the surface is well-scoped.
The set covers test discovery, execution, result retrieval, and failure diagnosis. Minor gaps exist around explicitly canceling a run or listing run history, though timeout handling and run_id/default-latest behavior mitigate these.
Maintenance
Related MCP Connectors
Run supported Playwright tools in an authorized persistent Chrome browser and watch in Live View.
Approved test intent, reviewed Playwright automation and run evidence, inside your editor.
Discover Playwright workflows, start runs, and inspect results in Playrunner Cloud.
Persistent memory, hybrid search and a goal graph for AI agents, over stdio or remote HTTP.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables AI agents to run, debug, and inspect Playwright end-to-end tests, returning structured pass/fail stats, failure diagnostics with actionable fix hints, live DOM inspection, selector validation, visual diffs, and flakiness verdicts instead of raw test output.11MIT

Pluswithai MCP Serverofficial
AlicenseNot gradedqualityCmaintenanceEnables AI agents to run tests, read failures, push new tests, and schedule them, either by connecting directly to a hosted endpoint or via a local stdio bridge.10 npmMIT- AlicenseAqualityBmaintenanceEnables AI assistants to inspect the latest Playwright JSON report, list failed or flaky tests, and rerun only those or selected cases by test-case ID, title, tag, spec file, or project.6MIT
- AlicenseBqualityBmaintenanceEnables agents to triage failed CI jobs, inspect failure details, list flaky tests, and retrieve summaries over stdio, returning retry, do-not-retry, or unsure decisions tied to log lines.4MIT