The Playwright MCP server enables LLMs to interact with web pages through structured accessibility snapshots, providing browser automation capabilities without requiring screenshots or vision models. It uses Playwright's accessibility tree to create a fast, lightweight solution for deterministic web interactions.
To get started with the Playwright MCP server, you'll need Node.js 18 or newer and a compatible MCP client such as VS Code, Cursor, Windsurf, Claude Desktop, or Goose.
Install the Playwright MCP server with your client using this standard configuration:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
You can install in VS Code manually by going to the settings, then to MCP section, and adding a new MCP server with the configuration above. Alternatively, use the VS Code CLI:
# For VS Code
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
Go to Cursor Settings
→ MCP
→ Add new MCP Server
. Name it as you prefer, use command
type with the command npx @playwright/mcp@latest
.
For other MCP clients, follow their respective documentation for adding MCP servers and use the standard configuration provided above.
The Playwright MCP server supports various configuration options that can be passed as arguments:
npx @playwright/mcp@latest --browser chrome # Choose browser: chrome, firefox, webkit, msedge
npx @playwright/mcp@latest --headless # Run in headless mode (default is headed)
npx @playwright/mcp@latest --viewport-size "1280, 720" # Set viewport size
By default, Playwright MCP uses a persistent profile that stores login information. You have three profile options:
Persistent Profile (Default):
--user-data-dir
)Isolated Mode:
npx @playwright/mcp@latest --isolated
Browser Extension:
--extension
flag# Allow only specific origins
npx @playwright/mcp@latest --allowed-origins "example.com;github.com"
# Block specific origins
npx @playwright/mcp@latest --blocked-origins "ads.example.com;tracking.com"
# Ignore HTTPS errors
npx @playwright/mcp@latest --ignore-https-errors
# Configure proxy
npx @playwright/mcp@latest --proxy-server "http://myproxy:3128"
Instead of command-line arguments, you can use a JSON configuration file:
npx @playwright/mcp@latest --config path/to/config.json
Example configuration file:
{
"browser": {
"browserName": "chromium",
"isolated": false,
"launchOptions": {
"channel": "chrome",
"headless": false
},
"contextOptions": {
"viewport": {
"width": 1280,
"height": 720
}
}
},
"server": {
"port": 8931,
"host": "localhost"
},
"capabilities": ["tabs", "pdf"],
"network": {
"allowedOrigins": ["example.com", "github.com"],
"blockedOrigins": ["ads.example.com"]
}
}
To run the MCP server on a system without display or from worker processes:
npx @playwright/mcp@latest --port 8931
Then in your MCP client config, set the URL:
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/mcp"
}
}
}
The Playwright MCP server provides a comprehensive set of tools for browser automation:
Enable additional capabilities using the --caps
flag:
# Enable PDF generation
npx @playwright/mcp@latest --caps pdf
# Enable coordinate-based interactions
npx @playwright/mcp@latest --caps vision
# Enable multiple capabilities
npx @playwright/mcp@latest --caps "vision,pdf"
With these tools, you can automate nearly any browser interaction through your MCP client, enabling AI assistants to effectively navigate and interact with web content.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "playwright" '{"command":"npx","args":["@playwright/mcp@latest"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect