MCP Playwright Test
@w1561778301
A Model Context Protocol (MCP) server for automating Playwright tests
Overview
What is MCP Playwright Test?
MCP Playwright Test is a Model Context Protocol (MCP) server for Playwright test automation. It automatically fetches project code (from Git or local), sets up Playwright environments, generates test cases from requirements, executes UI and API tests, and captures network requests and console logs. It is designed for developers using AI tools like Claude Desktop and Cursor.
How to use MCP Playwright Test?
Install via npm/yarn/pnpm (npm install mcp-playwright-test). Set the required ANTHROPIC_API_KEY environment variable (for test case generation). Start the server with npm run start or npx ts-node src/test-mcp.ts. Configure via .playwright-mcp.json for integration with Claude Desktop and Cursor.
Key features of MCP Playwright Test
- Clones Git repositories or uses local projects for testing
- Launches browsers (Chromium, configurable) with headless mode
- Generates test cases from natural language requirements
- Executes both UI and API test suites
- Captures network requests and console logs
- Supports OpenAPI 3.0, Swagger 2.0, and Apifox API specs
- Provides test execution reports and test case resources
- Configurable via environment variables or
.playwright-mcp.json
Use cases of MCP Playwright Test
- Automatically generate and run UI tests for a frontend project
- Create API tests from an OpenAPI specification document
- Run combined UI and API regression tests with a single MCP server
- Integrate test automation into AI-assisted development workflows
FAQ from MCP Playwright Test
What environment variables are required?
At minimum, ANTHROPIC_API_KEY must be set to generate test cases. Optional variables include MCP_PORT (default 8931), CODE_PATH, SIMPLE_GIT_* (for remote repos), API_URL, API_KEY, BROWSER_TYPE (default chromium), BROWSER_HEADLESS (default true), and TEST_STORAGE_DIR (default ./test-results).
What testing modes are supported?
Three modes: UI testing only, API testing only, or both UI and API testing simultaneously. Configure the relevant environment variables accordingly.
How to configure for Claude Desktop or Cursor?
Create a .playwright-mcp.json file in your project root with the MCP server definition. Then add the configuration in Claude Desktop or Cursor’s MCP settings, selecting the server name as defined in the file.
Which API specification formats are supported?
OpenAPI 3.0, Swagger 2.0, and Apifox. The server automatically detects the format, or you can specify it via the format parameter.
What are the dependencies and runtime requirements?
Requires Node.js and Playwright. For test case generation, an Anthropic API key is needed. No other external services are mandatory; Git files can be cloned locally or used from an existing directory.