Playwright MCP is a Model Context Protocol server that enables browser automation using structured accessibility snapshots instead of screenshots. This approach allows language models to interact with web pages efficiently through a structured data format without requiring vision models.
To use the Playwright MCP server, you need to install it with your MCP client. The installation process is straightforward with most tools.
The following configuration works with most MCP clients:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
You can customize the Playwright MCP server behavior by providing additional arguments in the configuration:
npx @playwright/mcp@latest --help
Some common configuration options include:
--browser <browser>: Specify which browser to use (chrome, firefox, webkit, msedge)--headless: Run the browser in headless mode--viewport-size <size>: Set browser viewport size (e.g., "1280x720")--isolated: Keep the browser profile in memory, not saving to disk--user-data-dir <path>: Specify path to user data directory--block-service-workers: Block service workers--ignore-https-errors: Ignore HTTPS errorsFor more advanced setups, you can use a JSON configuration file:
npx @playwright/mcp@latest --config path/to/config.json
You can use Playwright MCP in different profile modes:
All logged-in information is stored in the profile. Default locations vary by platform:
%USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile~/Library/Caches/ms-playwright/mcp-{channel}-profile~/.cache/ms-playwright/mcp-{channel}-profileYou can override this location with the --user-data-dir argument.
In isolated mode, each session starts with a fresh profile:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--isolated",
"--storage-state={path/to/storage.json}"
]
}
}
}
You can run the MCP server as a standalone service by specifying a port:
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 several tool categories:
browser_snapshot: Capture accessibility snapshot of the current pagebrowser_navigate: Navigate to a URLbrowser_click: Click on elementsbrowser_type: Type text into elementsbrowser_hover: Hover over elementsbrowser_select_option: Select options in dropdownsbrowser_fill_form: Fill multiple form fieldsbrowser_wait_for: Wait for text or timebrowser_take_screenshot: Take a screenshotbrowser_close: Close the browserThe server also offers optional capabilities:
To perform a basic web interaction:
browser_navigate to go to a URLbrowser_snapshot to get an accessibility tree of the pagebrowser_click or browser_typeTo 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.json2. Add this to your configuration file:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect