playwright-report-mcp
v0.1.0MCP server that reads Playwright JSON reports and returns compact JSON answers (summary, failures, slowest tests, run comparison) so an AI agent never has to…
An MCP server that reads a Playwright JSON report and answers questions about it in compact JSON, so an AI agent never has to load the whole report into its context. A seven-test report is about 20 KB of JSON, most of it stack traces repeated three times with terminal colour codes. get_summary answers from the same file in about 250 characters. Not supported: the HTML report, JUnit XML, blob reports, trace files, and JSON written by other test runners (Jest, Mocha, Cypress, CTRF). Anything else is refused with a NOT_PLAYWRIGHT_REPORT error rather than guessed at.
Summary extracted from the README.
@yahya_mahmudiy/playwright-report-mcp
An MCP server that reads a Playwright JSON report and answers questions about it in compact JSON, so an AI agent never has to load the whole report into its context.
A seven-test report is about 20 KB of JSON, most of it stack traces repeated three times with terminal colour codes. get_summary answers from the same file in about 250 characters.
Supported format
Playwright JSON reporter files only. That is the file Playwright's built-in json reporter writes:
// playwright.config.ts
reporter: [['json', { outputFile: 'test-results/report.json' }]],
or, without touching the config:
# macOS/Linux
PLAYWRIGHT_JSON_OUTPUT_FILE=test-results/report.json npx playwright test --reporter=json
# Windows PowerShell
$env:PLAYWRIGHT_JSON_OUTPUT_FILE = "test-results/report.json"; npx playwright test --reporter=json
Not supported: the HTML report, JUnit XML, blob reports, trace files, and JSON written by other test runners (Jest, Mocha, Cypress, CTRF). Anything else is refused with a NOT_PLAYWRIGHT_REPORT error rather than guessed at. A file counts as a Playwright JSON report when it has a config object and a suites array whose entries carry specs.
Developed and tested against reports from Playwright 1.63. Requires Node.js 20 or later.
Add it to Claude Code
Run this in your project folder:
claude mcp add playwright-report -- npx -y @yahya_mahmudiy/playwright-report-mcp
On native Windows (not WSL), npx has to go through cmd /c:
claude mcp add playwright-report -- cmd /c npx -y @yahya_mahmudiy/playwright-report-mcp
To share the server with everyone who works on the repository, commit a .mcp.json file at the project root instead:
{
"mcpServers": {
"playwright-report": {
"command": "npx",
"args": ["-y", "@yahya_mahmudiy/playwright-report-mcp"]
}
}
}
Check that it connected with claude mcp list, or /mcp inside Claude Code. Then ask something like "Summarise test-results/report.json" or "Compare report-run1.json with report-run2.json".
Add it to Cursor
Create .cursor/mcp.json in your project (or ~/.cursor/mcp.json to have it in every project):
{
"mcpServers": {
"playwright-report": {
"command": "npx",
"args": ["-y", "@yahya_mahmudiy/playwright-report-mcp"],
"env": {
"PW_REPORT_DIR": "${workspaceFolder}"
}
}
}
}
Then switch the server on under Customize in Cursor's sidebar. The tools become available to the agent in chat.
Report paths
Every tool takes the report path as an argument. It can be:
- absolute, to read a report anywhere on disk, or
- relative, resolved against
PW_REPORT_DIRwhen that variable is set, otherwise against the directory the server was started in.
PW_REPORT_DIR is the only setting, and it is optional. Set it when your client does not start servers in the project folder; in Claude Code, pass it with --env before the server name:
claude mcp add --env PW_REPORT_DIR=/path/to/project playwright-report -- npx -y @yahya_mahmudiy/playwright-report-mcp
The six tools
All six are read-only. Durations are in milliseconds. Values in parentheses are defaults.
| Tool | Arguments | Returns |
|---|---|---|
get_summary |
reportPath |
total, passed, failed, flaky, skipped, durationMs, testTimeMs, startTime, globalErrors |
list_failures |
reportPath, includeFlaky (false), maxErrorChars (500) |
Each failed test: name, title, project, result, durationMs, error, errorLocation |
slowest_test |
reportPath, limit (5) |
The N slowest tests with durationMs |
get_execution_times |
reportPath, sort (report, slowest, fastest, name), limit (200) |
Every test with durationMs, plus testTimeMs and averageMs |
get_test_details |
reportPath, name, project (optional) |
One test in full: location, status, every attempt with its error, code snippet and attachments |
compare_reports |
baselinePath, currentPath, minDurationDeltaMs (0), limit (50), maxErrorChars (500) |
Both paths, a summary of both runs with the delta, newlyFailed, newlyPassed, stillFailing, otherStatusChanges, added, removed, durationChanges |
get_summary
The headline numbers for one run.
{
"reportPath": "/project/test-results/report-run1.json",
"total": 7,
"passed": 5,
"failed": 2,
"flaky": 0,
"skipped": 0,
"durationMs": 10763,
"testTimeMs": 36303,
"startTime": "2026-10-10T03:51:17.354Z",
"globalErrors": 0
}
durationMs is the wall-clock time of the run. testTimeMs is the sum of every test's own time, which is larger when tests run in parallel. globalErrors counts errors raised outside any test, such as a spec file that fails to load.
list_failures
Every failed test with its name, title and error message.
{
"reportPath": "/project/test-results/report-run1.json",
"count": 2,
"failures": [
{
"name": "saucedemo.spec.ts › SauceDemo › inventory page lists all products",
"title": "inventory page lists all products",
"project": "chromium",
"status": "failed",
"result": "failed",
"durationMs": 10050,
"error": "Error: inventory should list the full product catalogue\n\nexpect(locator).toHaveCount(expected) failed\n\nLocator: getByTestId('inventory-item')\nExpected: 7\nReceived: 6\nTimeout: 5000ms",
"errorLocation": "saucedemo.spec.ts:38:7"
}
],
"globalErrors": []
}
Error messages have their colour codes removed and stop before Playwright's Call log: section. result is the raw status of the failing attempt (failed, timedOut, interrupted), which tells a timeout from an assertion failure. Set includeFlaky to also list tests that failed and then passed on retry.
slowest_test
The N slowest tests, slowest first. limit is N.
{
"reportPath": "/project/test-results/report-run1.json",
"total": 7,
"count": 2,
"tests": [
{ "name": "saucedemo.spec.ts › SauceDemo › inventory page lists all products", "project": "chromium", "status": "failed", "durationMs": 10050 },
{ "name": "saucedemo.spec.ts › SauceDemo › locked out user sees a locked-out error", "project": "chromium", "status": "failed", "durationMs": 10004 }
]
}
get_execution_times
Every test with its execution time, in report order unless sort says otherwise. Each entry has the same shape as in slowest_test; the answer also carries durationMs, testTimeMs and averageMs for the run.
get_test_details
Everything the report holds about one test. name can be the title, the full name, or any case-insensitive fragment of it. Each attempt comes with its full error message, error location, code snippet and attachment paths (screenshots, traces).
If several tests match, up to five are returned in full and the rest are listed by name. If none match, the answer lists the test names that are available.
compare_reports
What changed between a baseline run and a current run.
{
"baselinePath": "/project/test-results/report-run1.json",
"currentPath": "/project/test-results/report-run2.json",
"summary": {
"baseline": { "total": 7, "passed": 5, "failed": 2, "flaky": 0, "skipped": 0, "durationMs": 10763, "testTimeMs": 36303 },
"current": { "total": 7, "passed": 5, "failed": 2, "flaky": 0, "skipped": 0, "durationMs": 8593, "testTimeMs": 20562 },
"delta": { "total": 0, "passed": 0, "failed": 0, "flaky": 0, "skipped": 0, "durationMs": -2170, "testTimeMs": -15741 }
},
"newlyFailed": [
{
"name": "saucedemo.spec.ts › SauceDemo › adding a product updates the cart badge",
"project": "chromium",
"baselineStatus": "passed",
"currentStatus": "failed",
"error": "Error: cart badge should show the number of items added ..."
}
],
"newlyPassed": [
{
"name": "saucedemo.spec.ts › SauceDemo › inventory page lists all products",
"project": "chromium",
"baselineStatus": "failed",
"currentStatus": "passed"
}
],
"stillFailing": [
{ "name": "saucedemo.spec.ts › SauceDemo › locked out user sees a locked-out error", "project": "chromium" }
],
"otherStatusChanges": [],
"added": [],
"removed": [],
"durationChangeCount": 7,
"durationChanges": [
{
"name": "saucedemo.spec.ts › SauceDemo › inventory page lists all products",
"project": "chromium",
"baselineMs": 10050,
"currentMs": 1572,
"deltaMs": -8478,
"deltaPct": -84
}
]
}
added and removed are tests present in only one of the two reports. durationChanges is sorted by the size of the change, largest first, and trimmed here to one entry.
How the report is read
- Test names are
file › describe › title, with nesteddescribeblocks included. Line numbers are left out so a test keeps its name when the code above it moves. - Matching tests between two reports uses project, file and title path. A renamed test shows up as one removed and one added.
- Status comes from Playwright's own per-test verdict:
expectedispassed,unexpectedisfailed, andflakyandskippedkeep their names. A test markedtest.fail()that fails therefore counts as passed, as it does in Playwright's own output. - A test's duration is the total across all of its attempts, retries included.
- UTF-8, UTF-8 with a byte order mark and UTF-16 LE files are accepted. The last two are what Windows PowerShell writes when output is redirected to a file.
Errors
Every failure is a JSON document with a message and a stable code, returned with isError set:
{
"error": "Not a Playwright JSON report (no \"suites\" array): /project/package.json. Only files written by Playwright's \"json\" reporter are supported.",
"code": "NOT_PLAYWRIGHT_REPORT"
}
| Code | Meaning |
|---|---|
INVALID_ARGUMENTS |
An argument is missing, of the wrong type or out of range |
NOT_JSON_FILE |
The path does not end in .json |
FILE_NOT_FOUND |
No file at that path |
FILE_TOO_LARGE |
The file is larger than 100 MB |
READ_FAILED |
The file exists but could not be read |
INVALID_JSON |
The file is not valid JSON |
NOT_PLAYWRIGHT_REPORT |
Valid JSON, but not a Playwright JSON reporter file |
INTERNAL_ERROR |
Anything unexpected |
Safety rules
- Read-only. No tool writes, moves or deletes anything.
- JSON files only. A path that does not end in
.jsonis refused before the file is opened. - JSON answers only. Every tool result, success or failure, is a single JSON document.
- No API keys. The server needs no credentials and reads no secrets.
- No network calls. It reads the files it is given and nothing else.
- Nothing on stdout but the protocol. stdout carries the MCP JSON-RPC stream, so the code never calls
console.log. Errors are logged to stderr withconsole.error. - Test
stdoutandstderrcaptured in the report are never returned.
Development
npm install
npm test # builds, then drives the server over stdio against real reports
npm run build # compile src/ to build/ only
src/index.ts server setup and the six tool registrations
src/report.ts loading, validation and normalization of a report file
src/tools.ts the answer each tool builds from a normalized report
src/types.ts raw report shape and the normalized model
test/ stdio tests and two real Playwright reports as fixtures
License
MIT