The Playwright MCP Server provides an integration with Cursor IDE to enable AI-powered generation of Playwright tests. Operating as a custom Model Context Protocol (MCP) server, it analyzes a project's site context, existing test patterns, and authentication configurations to generate new tests based on user prompts. The server is currently at version 1.0.0, suggesting its initial stable release. Its release cadence is not explicitly stated but is likely tied to its primary use case with the Cursor IDE. Key differentiators include its deep integration with Cursor's chat interface, intelligent code reuse from existing tests, and sophisticated project structure analysis to ensure generated tests adhere to established conventions, making it a specialized tool for accelerating Playwright test development within the Cursor ecosystem.
npm install playwright-mcp-serverVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the essential steps to set up the OpenAI API key, install dependencies, start the Playwright MCP server, and configure the Cursor IDE to interact with it for AI-powered test generation.
Set `export OPENAI_API_KEY="your-key-here"` in your shell or `.env` file before starting the server.
Ensure `site-context.json` is correctly formatted and placed in one of the expected locations (project root, `data/`, `config/`, `playwright-mcp-system/`). Validate its JSON structure using a linter.
Review `.playwright-mcp-auth.json` for correct `username`, `password`, `loginUrl`, and selector values (`usernameSelector`, `passwordSelector`, `submitSelector`). Ensure `requiresLogin` patterns accurately match protected routes.
Double-check the `command` (e.g., `npx` or `node`) and `args` (e.g., `playwright-mcp-server` or `/path/to/src/index.js`) in `.cursor/settings.json`. If using `npm link`, `npx` is generally reliable.
Operate the `playwright-mcp-server` as a background process and configure your Cursor IDE as instructed in the README, rather than attempting direct programmatic imports of its core server logic.
Set the environment variable: `export OPENAI_API_KEY="your-key-here"` in your terminal or ensure it's loaded via an `.env` file when starting the server.
Run `npm install` in the package's directory. If using `npx`, ensure the package is globally linked (`npm link`) or specify the full path to `src/index.js` in `.cursor/settings.json`.
Create `site-context.json` in one of the specified locations (e.g., project root) and ensure it's correctly formatted according to the schema.
Review `.playwright-mcp-auth.json` for correct `username`, `password`, `loginUrl`, and selector values (`usernameSelector`, `passwordSelector`, `submitSelector`). Ensure they match your site's login form.
Verify the `mcpServers` configuration for the `playwright` entry in `.cursor/settings.json`. Check the `command` and `args` paths. Ensure the `playwright-mcp-server` is runnable from your terminal and check its console logs for any startup errors.