Skip to content
Back to search

playwright-rerun-mcp

MCP server that lets an AI assistant list failed or flaky Playwright tests and rerun only those, or rerun by test-case ID

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/ibtsam2666--playwright-rerun-mcp/badge.svg)](/listings/ibtsam2666--playwright-rerun-mcp)

HTML

<a href="/listings/ibtsam2666--playwright-rerun-mcp"><img src="/api/listings/ibtsam2666--playwright-rerun-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 103 lines
  1. # playwright-rerun-mcp
  2. [![CI](https://github.com/ibtsam2666/playwright-rerun-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/ibtsam2666/playwright-rerun-mcp/actions/workflows/ci.yml)
  3. An [MCP](https://modelcontextprotocol.io) server that lets an AI assistant (Claude Code, Claude Desktop, or any MCP client) see which Playwright tests failed and rerun only those, or rerun tests by test-case ID.
  4. I built the same kind of tool at work, where it reran failed specs by their test-management ID. This is a clean, public version.
  5. ![An assistant runs the example tests, lists the failure, explains TC-3 with show_trace, then reruns TC-3 by ID after the fix](media/demo.gif)
  6. <sub>Real replies from the server on the example suite, replayed as a terminal. Re-record with `node scripts/record-demo.mjs`.</sub>
  7. ## Add it to Claude Code
  8. From your Playwright project root:
  9. ```bash
  10. claude mcp add playwright-rerun -- npx -y github:ibtsam2666/playwright-rerun-mcp
  11. ```
  12. Or add it to any MCP client config:
  13. ```json
  14. {
  15. "mcpServers": {
  16. "playwright-rerun": {
  17. "command": "npx",
  18. "args": ["-y", "github:ibtsam2666/playwright-rerun-mcp"],
  19. "env": { "PLAYWRIGHT_PROJECT_ROOT": "/path/to/your/project" }
  20. }
  21. }
  22. }
  23. ```
  24. On Windows, start it through `cmd`: `"command": "cmd", "args": ["/c", "npx", "-y", "github:ibtsam2666/playwright-rerun-mcp"]`.
  25. Your project needs `@playwright/test` installed (`npm ci`). The server uses your project's own Playwright and config.
  26. ## Tools
  27. | Tool | What it does |
  28. |---|---|
  29. | `list_failed_tests` | Reads the last JSON report and lists failed and flaky tests with file, line, error and case IDs. Read-only |
  30. | `show_trace` | Explains one failed test, found by case ID or title: full error, where it was thrown, the failing `test.step`, and the trace, screenshot and video paths with the `show-trace` command. Read-only |
  31. | `list_tests` | Lists tests with their case IDs, file and project without running them (`--list`), filtered by `grep` or `project`. Read-only |
  32. | `rerun_failed` | Reruns only the tests that failed last time, optionally filtered by title |
  33. | `rerun_by_id` | Reruns tests by case ID, e.g. `["TC-301", "TC-405"]` |
  34. | `run_tests` | Runs tests by title pattern, tag (`@smoke`), spec file or project |
  35. Each tool returns a short text summary plus structured content. The run tools return `{ exitCode, timedOut, counts: { passed, failed, flaky, skipped } }`.
  36. `show_trace` lists a trace only if the project saves one, e.g. `use: { trace: 'retain-on-failure' }` in `playwright.config`.
  37. Case IDs come from Playwright tags or from test titles:
  38. ```ts
  39. test('order total includes tax', { tag: ['@smoke', '@TC-301'] }, async ({ page }) => { /* ... */ });
  40. ```
  41. ## Settings
  42. | Variable | Default | Purpose |
  43. |---|---|---|
  44. | `PLAYWRIGHT_PROJECT_ROOT` | current directory | The Playwright project to run |
  45. | `RERUN_TIMEOUT_MS` | `600000` (10 min) | A run that takes longer is stopped |
  46. The report is written to `test-results/results.json` in the project root.
  47. ## CI job summary
  48. The package also installs `playwright-rerun-summary`, which turns a Playwright JSON report into a GitHub Actions job summary: a pass/fail/flaky/skipped table plus one row per failed or flaky test with its case IDs.
  49. ```yaml
  50. - name: Job summary
  51. if: ${{ !cancelled() }}
  52. run: npx -y -p github:ibtsam2666/playwright-rerun-mcp playwright-rerun-summary test-results/results.json --title "UI tests"
  53. ```
  54. ## Safety
  55. - Spec paths must stay inside the project and end in `.spec.ts` or `.spec.js`.
  56. - Only one run at a time, so the report is never written twice at once.
  57. - Every run has a timeout. Project names and case IDs are checked against strict patterns.
  58. ## Develop
  59. ```bash
  60. npm ci
  61. npm test # unit tests: report parser, trace and listing helpers, path guard, job summary
  62. npm run smoke # builds, then lists, runs, explains and reruns the example suite over stdio
  63. npm run lint # ESLint with typescript-eslint and eslint-plugin-playwright
  64. npm run format:check # Prettier
  65. ```
  66. The smoke test sets `DEMO_BREAK=1` so example test TC-3 fails on purpose and `show_trace` has something to explain.
  67. `src/report.ts` parses the report (pure functions), `src/tools.ts` defines the tools, `src/cli.ts` starts the server and `src/summary.ts` writes the CI summary.
  68. The same server also runs inside my [Playwright portfolio](https://github.com/ibtsam2666/IbtsamAyyaz-Portfolio) against a full UI and API suite.
  69. ## License
  70. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.