The Playwright MCP server provides browser automation capabilities using Playwright, enabling language models to interact with web pages through structured accessibility snapshots without requiring screenshots or visually-tuned models.
You can configure the Playwright MCP server using NPX in your MCP configuration:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
You can install the Playwright MCP server in VS Code using the command line:
# For VS Code
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
# For VS Code Insiders
code-insiders --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.
Docker implementation currently only supports headless chromium:
{
"mcpServers": {
"playwright": {
"command": "docker",
"args": ["run", "-i", "--rm", "--init", "mcp/playwright"]
}
}
}
To build the Docker image yourself:
docker build -t mcp/playwright .
The Playwright MCP server supports the following options:
--browser <browser>
: Choose which browser to use (chrome, firefox, webkit, msedge, chrome-beta, etc.)--caps <caps>
: Comma-separated list of capabilities to enable (tabs, pdf, history, wait, files, install)--cdp-endpoint <endpoint>
: CDP endpoint to connect to--executable-path <path>
: Path to the browser executable--headless
: Run browser in headless mode (headed by default)--port <port>
: Port to listen on for SSE transport--host <host>
: Host to bind server to (default: localhost)--user-data-dir <path>
: Path to the user data directory--vision
: Run server that uses screenshots instead of accessibility snapshotsFor background or batch operations without a GUI:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--headless"
]
}
}
}
For systems without a display or when running in a remote environment:
npx @playwright/mcp@latest --port 8931 --host 0.0.0.0
In your MCP client config, use:
{
"mcpServers": {
"playwright": {
"url": "http://{$server-ip}:8931/sse"
}
}
}
The server offers two modes:
To use Vision Mode:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--vision"
]
}
}
}
Capture a snapshot:
browser_snapshot
Navigate to a URL:
browser_navigate
url
(string)Take a screenshot:
browser_take_screenshot
raw
(boolean, optional): Return without compression if trueelement
(string, optional): Element descriptionref
(string, optional): Element referenceClick an element:
browser_click
element
(string): Human-readable element descriptionref
(string): Element reference from snapshotHover over an element:
browser_hover
element
(string): Element descriptionref
(string): Element referenceType text into an element:
browser_type
element
(string): Element descriptionref
(string): Element referencetext
(string): Text to typesubmit
(boolean, optional): Whether to press Enter after typingslowly
(boolean, optional): Whether to type one character at a timeSelect dropdown options:
browser_select_option
element
(string): Element descriptionref
(string): Element referencevalues
(array): Values to selectDrag and drop:
browser_drag
startElement
(string): Source element descriptionstartRef
(string): Source element referenceendElement
(string): Target element descriptionendRef
(string): Target element referenceCapture screen:
browser_screen_capture
Click at coordinates:
browser_screen_click
element
(string): Element descriptionx
(number): X coordinatey
(number): Y coordinateType text:
browser_screen_type
text
(string): Text to typesubmit
(boolean, optional): Whether to press Enter afterList tabs:
browser_tab_list
Create new tab:
browser_tab_new
url
(string, optional): URL to navigate toSelect a tab:
browser_tab_select
index
(number): Tab indexClose a tab:
browser_tab_close
index
(number, optional): Tab index to closePress a key:
browser_press_key
key
(string): Key name (e.g., ArrowLeft
or a
)Upload files:
browser_file_upload
paths
(array): Absolute paths to filesWait for a specified time:
browser_wait
time
(number): Time in secondsResize browser window:
browser_resize
width
(number): Window widthheight
(number): Window heightSave page as PDF:
browser_pdf_save
Handle dialogs:
browser_handle_dialog
accept
(boolean): Whether to accept the dialogpromptText
(string, optional): Text for prompt dialogsThere 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.