Home / MCP / Playwright MCP Server
Provides live Playwright browser context to MCP clients for reliable AI-assisted test generation.
Configuration
View docs{
"mcpServers": {
"playwright_mcp": {
"command": "npx",
"args": [
"-y",
"playwright-mcp"
]
}
}
}Playwright MCP gives your AI assistants real browser context by exposing a Playwright-controlled browser to the MCP workflow. It lets you record interactions, capture screenshots, extract the DOM, and run JavaScript inside the page, so your AI can generate solid, context-aware Playwright tests instead of guessing selectors or guessing how pages work.
Use Playwright MCP with an MCP client to give your AI tools live page context. You can connect through local stdio servers or via an MCP-enabled IDE or desktop assistant. With the server running, you can record interactions, take screenshots, fetch the full DOM, and execute arbitrary code inside the browser to debug and automate tests.
Prerequisites you need before installing are straightforward.
• Node.js installed on your system
• Playwright and its Chromium browser installed
• An MCP-capable IDE or assistant (for example Cursor)
Follow these concrete steps to get up and running quickly.
1) Install the MCP package globally for CLI access
2) Set up your MCP client (Cursor or Claude) to connect to the local MCP server
Playwright MCP can be connected to your MCP client in two common ways, depending on your preferred workflow.
{
"mcpServers": {
"playwright-mcp": {
"command": "npx",
"args": [
"-y",
"playwright-mcp"
]
}
}
}If you want to use Claude Desktop, install the MCP server CLI and wire it into Claude’s config so Claude can talk to Playwright MCP.
Install the MCP server globally.
Run the installation command.
Update Claude’s configuration so Claude can find the MCP server. Then restart Claude Desktop and verify by asking Claude to list available MCP tools.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "playwright-mcp"]
}
}
}After setup, you should be able to prompt your AI assistant to initialize a browser session and start producing tests with live page context. The assistant can list and use available MCP tools to get context, DOM, screenshots, and to run code inside the page.
You gain access to several MCP tools that the AI can call to interact with the page and gather context.
- If you don’t see the expected tools, ensure the MCP server is running and that the client is connected to the correct endpoint.
- Restart the client after installing or changing MCP server configurations to apply changes.
Fetches the current browser context from the running Playwright instance so the AI can reason about available pages, frames, and interactions.
Extracts the full page DOM as HTML along with relevant metadata to help the AI generate accurate selectors and actions.
Captures screenshots of elements or entire pages to provide visual context for test generation and debugging.
Runs arbitrary JavaScript inside the browser context to help with debugging, data extraction, or custom automation steps.
Launches a new browser instance and initializes the Playwright context for subsequent interactions and test recording.
Validates and normalizes selectors against the current DOM to reduce flaky tests and improve reliability.