The Playwright MCP server provides browser automation capabilities using Playwright, enabling LLMs to interact with web pages through structured accessibility snapshots without requiring screenshots or visually-tuned models.
To install the Playwright MCP server, you'll need Node.js 18 or newer and an MCP client like VS Code, Cursor, Windsurf, or Claude Desktop.
Add the Playwright MCP server to your client 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"]}'
After installation, the Playwright MCP server will be available for use with your GitHub Copilot agent in VS Code.
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
Key options include:
--browser <browser>
: Specify browser to use (chrome, firefox, webkit, msedge)--headless
: Run browser in headless mode (headed by default)--viewport-size <size>
: Specify browser viewport size in pixels--user-agent <ua string>
: Specify user agent string--isolated
: Keep browser profile in memory, not saved to disk--port <port>
: Port to listen on for SSE transport--vision
: Run server using screenshots instead of accessibility snapshotsThe Playwright MCP server can run with either persistent or isolated user profiles.
By default, all logged-in information is stored in a persistent profile. This profile is located at:
# 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 profile location with the --user-data-dir
argument.
In isolated mode, each session runs in an isolated profile. When the browser is closed, all storage state for that session is lost:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--isolated",
"--storage-state={path/to/storage.json}"
]
}
}
}
You can use a JSON configuration file to set up the Playwright MCP server:
npx @playwright/mcp@latest --config path/to/config.json
When running a headed browser on a system without a display, run the MCP server with the --port
flag:
npx @playwright/mcp@latest --port 8931
Then in your MCP client config, set the url
to the SSE endpoint:
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/sse"
}
}
}
The server supports two modes:
To use Vision Mode, add the --vision
flag:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--vision"
]
}
}
}
The Playwright MCP server provides various tools for browser automation:
Each tool has specific parameters and usage patterns that can be used to automate browser interactions through the MCP protocol.
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.