Playwright MCP is a server that enables automation of web browsers through structured accessibility snapshots, allowing Large Language Models (LLMs) to interact with web pages without requiring screenshots or vision-based models.
To install the Playwright MCP server, you need to configure it with your MCP client. Most tools use a standard configuration:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
Click the install button or add manually by following the MCP install guide with the standard config. You can also install using the VS Code CLI:
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
Go to Cursor Settings → MCP → Add new MCP Server. Use command type with the command npx @playwright/mcp@latest.
Follow your client's MCP server installation documentation, using the standard config shown above.
The Playwright MCP server supports numerous command-line arguments to customize its behavior:
npx @playwright/mcp@latest --help
Common options include:
--browser <browser> - Specify browser to use (chrome, firefox, webkit, msedge)--headless - Run browser in headless mode (headed by default)--viewport-size <size> - Set browser viewport size (e.g., "1280x720")--user-agent <ua string> - Specify a custom user agent--caps <caps> - Enable additional capabilities like vision, pdf, testing--isolated - Keep browser profile in memory, don't save to disk--user-data-dir <path> - Specify path to user data directoryPlaywright MCP can run in different profile modes:
All login information is stored in a persistent profile located at:
%USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile~/Library/Caches/ms-playwright/mcp-{channel}-profile~/.cache/ms-playwright/mcp-{channel}-profileOverride with --user-data-dir argument.
Each session starts in an isolated profile with all storage state lost after closing:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--isolated",
"--storage-state={path/to/storage.json}"
]
}
}
}
Connect to existing browser tabs using the Playwright MCP Chrome Extension.
--user-data-dir to persist all browser data between sessions--storage-state to load cookies and local storage from a file--init-page to point to a TypeScript file for page setup:// init-page.ts
export default async ({ page }) => {
await page.context().grantPermissions(['geolocation']);
await page.context().setGeolocation({ latitude: 37.7749, longitude: -122.4194 });
await page.setViewportSize({ width: 1280, height: 720 });
};
--init-script to add initialization scripts:// init-script.js
window.isPlaywrightMCP = true;
Create a JSON configuration file and specify it with --config:
npx @playwright/mcp@latest --config path/to/config.json
Run the MCP server on a separate port for HTTP transport:
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 various tools for browser automation, including:
--caps=pdf)--caps=testing)--caps=vision)--caps=tracing)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.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