playwright-generate-mcp
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., "@playwright-generate-mcpGenerate a Playwright login spec with page objects, then run it and score quality."
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.
playwright-generate-mcp
An enterprise-grade Model Context Protocol (MCP) server that empowers AI coding assistants (Cursor, Claude Desktop, Antigravity, Roo Code, etc.) to generate, score, run, and auto-heal robust, maintainable, and flake-resistant Playwright E2E tests.
It enforces a Domain-Driven Page Object Model (POM) architecture, provides cross-file quality scoring, extracts rich single-turn failure diagnostics, and adheres to strict web-first anti-flakiness rules.
⨠Key Features
šļø Domain-Driven POM Architecture: Enforces separation of concerns between Declarative Specs, Page Objects, Custom Fixtures, and Dynamic Data Factories.
š Cross-File POM Quality Scoring:
score_test_qualityandrun_playwright_testautomatically traverse import dependencies (.spec.ts$\rightarrow$.fixture.ts$\rightarrow$*.page.ts/*.component.ts), scoring locators and anti-patterns across all related files.ā” Single-Turn Rich Diagnostics: When a test fails,
run_playwright_testimmediately returns the exact file & line location, error category, the last 3ā5 action steps before failure, browser console logs, failed HTTP requests (4xx/5xx), and screenshot paths in a single turn.š”ļø Strict Anti-Flakiness Rules: Detects and discourages arbitrary sleeps (
waitForTimeout,setTimeout), un-awaited actions,networkidledependencies, and manual text extractions in favor of web-first auto-retrying assertions.š§ Stateless Root Auto-Discovery: Automatically traverses parent directories to discover
playwright.config.{ts,js,mjs,cjs,mts,cts}without requiring manual path configuration.š¬ Adaptive Interactive Confirmations: Supports interactive UI modals (
ask_question,vscode_askQuestions) or formatted numbered lists before applying test heals.
Related MCP server: Limetest MCP Server
š Architecture Standard
This MCP guides AI agents to structure tests under a clean Domain-Driven hierarchy:
tests/e2e/
āāā domain/ # Grouped by business features
ā āāā {feature}/
ā āāā pages/ # Page Objects / Component Objects
ā ā āāā {step}.page.ts
ā āāā {feature}.fixture.ts # Custom Fixture injecting Page Objects & Data
āāā factory/ # Dynamic test data builders
ā āāā {entity}.factory.ts # Unique data per run (timestamp / Faker)
āāā specs/ # Declarative, readable test specs
āāā {feature}.spec.tsCore Design Rules
Strict Separation: No raw locators or direct DOM manipulations inside
*.spec.tsfiles. All UI interactions live inside Page/Component Objects.Custom Fixtures: Inject Page Objects and test data using
test.extend<Fixtures>()instead of manualnew Page()instantiations in specs.Dynamic Data Factories: Generate unique test data per run to prevent database unique-constraint collisions on test re-runs.
Semantic Locators: Prioritize
getByRole>getByLabel/getByPlaceholder>getByText>getByTestId. Deep nested CSS (div > div > span) is strictly forbidden.Tagging Conventions:
@smoke: Critical happy paths.@regression: Comprehensive user flows.@ui: Pure UI/frontend tests usingpage.route()to stub API responses.@integration: Tests validating against real backend APIs.
š ļø MCP Tools
Tool | Description |
| Runs a Playwright spec file in the target project. Returns pass/fail status, comprehensive multi-file |
| Scores a spec file and its imported Page Objects on measurable quality signals: |
| Deep diagnostic inspector to re-inspect specific test failure details from a previous run report. |
| Audits |
| Runtime fallback to manually set the target project root if auto-detection is not applicable. |
š MCP Prompts
playwright_e2e_workflow: Complete end-to-end prompt instructing AI agents on the Domain-Driven POM architecture, code generation sequences (Step A to Step E), strict anti-flakiness writing rules, single-turn diagnostics, and safe healing workflows.
š Installation & Setup
1. Build from Source
git clone https://github.com/your-username/playwright-generate-mcp.git
cd playwright-generate-mcp
npm install
npm run build2. Configure MCP Client
Add the server to your MCP configuration file (e.g. claude_desktop_config.json, Cursor Settings, or Antigravity MCP settings):
{
"mcpServers": {
"playwright-generate": {
"command": "node",
"args": ["/absolute/path/to/playwright-generate-mcp/dist/index.js"]
}
}
}Or when published to NPM:
{
"mcpServers": {
"playwright-generate": {
"command": "npx",
"args": ["-y", "playwright-generate-mcp"]
}
}
}š§āš» Development
npm run dev # tsx watch mode
npm run build # Compile TypeScript to dist/
npm start # Run compiled MCP serverš License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Browser-based QA for AI-built software. Test pages with real browsers via agents.
Direct access to Cypress tests results and accessibility reports in your AI workflow.
Agentic testing: HyperExecute jobs, test failure triage, SmartUI visual diffs, a11y audits
AI QA that runs your app in a browser on every pull request: projects, test targets, test cases.
Related MCP Servers
- AlicenseAqualityDmaintenanceGenerates intelligent Playwright locators with reliability rankings, creates Page Object Models, and runs test automation scripts directly from your IDE or AI assistant.56 npm1MIT
- AlicenseNot gradedqualityCmaintenanceEnables automated end-to-end testing powered by Playwright where test cases are defined in natural language and executed by AI. Uses lightweight snapshot analysis with vision mode fallback for sophisticated testing scenarios.3Apache 2.0
- FlicenseNot gradedqualityCmaintenanceEnables AI assistants to execute browser automation, perform QA tasks, and generate test code through natural language commands using Playwright.5-
- AlicenseNot gradedqualityDmaintenanceAutomates repository analysis, test planning, and generation of end-to-end tests with Playwright, acting as an intelligent quality assistant.10 npmMIT