The Playwright MCP server provides browser automation capabilities using Playwright, enabling LLMs to interact with web pages through structured accessibility snapshots. This lightweight solution doesn't require screenshots or visually-tuned models, making it ideal for automated web interaction.
The Playwright MCP server can be installed with your MCP client. A typical configuration looks like this:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
You can install the Playwright MCP server using 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 to your liking, use command
type with the command npx @playwright/mcp
.
Use the Claude Code CLI to add the Playwright MCP server:
claude mcp add playwright npx @playwright/mcp@latest
The Playwright MCP server supports various configuration arguments that can be provided in the JSON configuration as part of the "args"
list:
npx @playwright/mcp@latest --help
--allowed-origins <origins>
: Semicolon-separated list of origins to allow--blocked-origins <origins>
: Semicolon-separated list of origins to block--browser <browser>
: Browser to use (chrome, firefox, webkit, msedge)--headless
: Run browser in headless mode (headed by default)--isolated
: Keep browser profile in memory, not saving to disk--vision
: Use screenshots instead of accessibility snapshotsYou can run Playwright MCP with:
# Windows
%USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile
# macOS
~/Library/Caches/ms-playwright/mcp-{channel}-profile
# Linux
~/.cache/ms-playwright/mcp-{channel}-profile
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--isolated",
"--storage-state={path/to/storage.json}"
]
}
}
}
You can specify a JSON configuration file:
npx @playwright/mcp@latest --config path/to/config.json
For environments without a display or from worker processes of IDEs:
npx @playwright/mcp@latest --port 8931
Then in your MCP client config:
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/sse"
}
}
}
The tools are available in two modes:
Uses accessibility snapshots for better performance and reliability
Uses screenshots for visual-based interactions. Enable with:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--vision"
]
}
}
}
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