Playwright AI Agent POM MCP Server
Playwright AI Agent POM MCP ServerPlaywright AI Agent using Page Object Model (POM) architecture with MCP Server integration for automated web and mobile testi…
A practical Playwright, Page Object Model (POM), and AI-agent testing framework for web, API, accessibility, security, resilience, and mobile checks.
Quick start
Requirements: Node.js 20+.
npm ci
npx playwright install --with-deps
npm run test:smoke
Use Chromium for the fastest local feedback:
npm run test:chromium
npm run test:headed
npm run test:report
Set a target application with an environment variable:
E2E_BASE_URL=https://your-app.example npm run test:smoke
E2E_API_TOKEN=your-token npm run test:chromium
PowerShell:
$env:E2E_BASE_URL="https://your-app.example"
npm run test:smoke
Common commands
| Command | Purpose |
|---|---|
npm test |
Run the complete configured suite |
npm run test:unit |
Run platform and utility unit tests |
npm run test:integration |
Run integration tests |
npm run test:smoke |
Run the smoke suite in Chromium |
npm run test:a11y |
Run accessibility and keyboard checks |
npm run test:security |
Run security-focused Playwright specs |
npm run test:mobile |
Run mobile-project coverage |
npm run test:chromium |
Run the full suite in Chromium |
npm run test:headed |
Run in headed mode |
npm run test:report |
Open the HTML report |
npm run typecheck |
Check TypeScript types |
npm run format:check |
Check formatting |
npm run mcp:server |
Start the JSON-RPC/MCP server |
To run one spec or category:
npx playwright test tests/indiaRealtime.spec.ts --project=chromium
npx playwright test tests/security-tests/ --project=chromium
npx playwright test tests/indiaRealtime.spec.ts --project=chromium --headed
Architecture
AI agent / MCP client
|
v
mcp-server.ts ── test selection, failure analysis, reporting, guarded healing
|
v
Playwright runner
|
+-- tests/*.spec.ts
+-- tests/pages/*Page.ts
+-- tests/data/*.ts
+-- tools/ai-reporter.ts
+-- tools/platform/*
- Specs orchestrate scenarios and assertions.
- Page Objects own selectors and UI actions. Keep selectors out of spec files.
- Test data belongs in
tests/data/; configure URLs and tokens through environment variables. - Fixtures provide API contexts and failure tracing.
- Reporter creates an AI-readable failure report.
- MCP server lets compatible agents run tests and inspect results without bypassing framework guardrails.
Repository layout
tests/
data/ Centralized URLs, users, thresholds
pages/ Page Objects and shared BasePage
fixtures.ts Shared Playwright fixtures
indiaRealtime.spec.ts Main smoke coverage
unit-tests/ Fast platform tests
integration-tests/ Multi-step workflows
accessibility/ Axe and keyboard checks
security-tests/ Authentication and XSS checks
validation-tests/ Broken links and invalid inputs/routes
network-resilience/ Offline/network scenarios
contract-tests/ API contract checks
...
tools/
ai-reporter.ts Structured run output
platform/ Failure analysis, trace summaries, healing,
test selection, metrics, and redaction
mcp-server.ts MCP/JSON-RPC entrypoint
playwright.config.ts Browser projects and reporters
Writing tests
Create a Page Object for UI selectors and actions:
From the project's README.