The Playwright MCP server provides browser automation capabilities using Playwright, enabling Large Language Models (LLMs) to interact with web pages through structured accessibility snapshots rather than requiring screenshots or visually-tuned models.
The Playwright MCP server can be installed and configured with various MCP clients. The basic installation requires Node.js 18 or newer and a compatible MCP client like VS Code, Cursor, Windsurf, or Claude Desktop.
Install the Playwright MCP server with this typical configuration:
{
"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
. You can verify config or add command arguments by clicking Edit
.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
The Playwright MCP server supports various command-line arguments that can be provided in the JSON configuration:
npx @playwright/mcp@latest --help
Key configuration options include:
--browser <browser>
: Choose the browser to use (chrome, firefox, webkit, msedge)--headless
: Run browser in headless mode (headed by default)--isolated
: Keep the browser profile in memory, not on disk--vision
: Run server that uses screenshots (Aria snapshots used by default)--port <port>
: Port to listen on for SSE transport--allowed-origins <origins>
: Semicolon-separated list of origins to allow--blocked-origins <origins>
: Semicolon-separated list of origins to blockThe Playwright MCP server can run in two profile modes:
All logged-in information is stored in a persistent profile. Default locations:
# Windows
%USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile
# macOS
~/Library/Caches/ms-playwright/mcp-{channel}-profile
# Linux
~/.cache/ms-playwright/mcp-{channel}-profile
You can override the location with the --user-data-dir
argument.
In isolated mode, each session starts with a fresh profile. Storage state is lost when the browser closes:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--isolated",
"--storage-state={path/to/storage.json}"
]
}
}
}
You can specify a JSON configuration file using the --config
option:
npx @playwright/mcp@latest --config path/to/config.json
The configuration file can include browser settings, server configuration, capabilities, network settings, and more.
For running a headed browser on systems without display or from worker processes:
npx @playwright/mcp@latest --port 8931
Then in the MCP client config, set the URL to the SSE endpoint:
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/sse"
}
}
}
The server provides tools in two modes:
Uses accessibility snapshots for better performance and reliability.
Uses screenshots for visual-based interactions. Enable with the --vision
flag:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--vision"
]
}
}
}
browser_snapshot
: Capture accessibility snapshot of the current pagebrowser_click
: Perform click on a web pagebrowser_drag
: Perform drag and drop between elementsbrowser_hover
: Hover over element on pagebrowser_type
: Type text into editable elementbrowser_select_option
: Select an option in a dropdownbrowser_press_key
: Press a key on the keyboardbrowser_wait_for
: Wait for text to appear/disappearbrowser_navigate
: Navigate to a URLbrowser_navigate_back
: Go back to the previous pagebrowser_navigate_forward
: Go forward to the next pagebrowser_take_screenshot
: Take a screenshot of the current pagebrowser_pdf_save
: Save page as PDFbrowser_network_requests
: List all network requestsbrowser_console_messages
: Get console messagesbrowser_install
: Install the browser specified in the configbrowser_close
: Close the pagebrowser_resize
: Resize the browser windowbrowser_tab_list
: List browser tabsbrowser_tab_new
: Open a new tabbrowser_tab_select
: Select a tab by indexbrowser_tab_close
: Close a tabTo 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