Home / MCP / Playwright MCP Server
Provides browser automation via Playwright MCP server using accessibility snapshots for structured interactions.
Configuration
View docs{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}The Playwright MCP server lets you automate browser tasks using Playwright and structured accessibility data, so you can drive web pages with language models without relying on screenshots or vision models. It’s fast, lightweight, and guarantees deterministic tool usage by operating on the page’s accessibility tree.
You interact with a Playwright MCP server through an MCP client. Install the server in your preferred client, then connect to it to automate browser actions such as navigating pages, clicking elements, typing text, and waiting for content. Use the server to perform actions on live pages using structured data rather than pixel-based cues, which helps your model reason about web interactions more reliably.
Prerequisites: Node.js 18 or newer. Ensure you have a compatible MCP client installed (VS Code, Cursor, Windsurf, Claude Desktop, Claude Code, Qodo Gen, etc.). Then install and configure the Playwright MCP server in your client of choice using the provided commands.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}Install in VS Code using the CLI. This adds the Playwright MCP server so you can use it with your GitHub Copilot agent in VS Code.
# For VS Code
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'Install in Cursor by adding a new MCP server with the following configuration, or verify/edit existing settings to include the Playwright MCP server.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}Install in Windsurf by using the same configuration pattern as other MCP servers.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}Install in Claude Desktop by using the same configuration form as other MCP servers.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}Install in Claude Code using the Claude Code CLI to add the Playwright MCP server.
claude mcp add playwright npx @playwright/mcp@latestInstall in Qodo Gen by adding the Playwright MCP server configuration in the chat panel, then Save.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}Standalone startup: you can run the server headless or with a display. To run a standalone instance that exposes an SSE endpoint, start with a port and then configure your client to connect to that SSE URL.
npx @playwright/mcp@latest --port 8931To connect a client to the standalone server, configure the client to use the SSE endpoint at the address you started, for example http://localhost:8931/sse.
Playwright MCP server supports a broad set of command-line arguments and a configuration file. The following options are available when starting the server. They control origins, browser choice, device emulation, storage state, and various features.
> npx @playwright/mcp@latest --help
--allowed-origins <origins> semicolon-separated list of origins to allow the
browser to request. Default is to allow all.
--blocked-origins <origins> semicolon-separated list of origins to block the
browser from requesting. Blocklist is evaluated
before allowlist. If used without the allowlist,
requests not matching the blocklist are still
allowed.
--block-service-workers block service workers
--browser <browser> browser or chrome channel to use, possible
values: chrome, firefox, webkit, msedge.
--browser-agent <endpoint> Use browser agent (experimental).
--caps <caps> comma-separated list of capabilities to enable,
possible values: tabs, pdf, history, wait, files,
install. Default is all.
--cdp-endpoint <endpoint> CDP endpoint to connect to.
--config <path> path to the configuration file.
--device <device> device to emulate, for example: "iPhone 15"
--executable-path <path> path to the browser executable.
--headless run browser in headless mode, headed by default
--host <host> host to bind server to. Default is localhost. Use
0.0.0.0 to bind to all interfaces.
--ignore-https-errors ignore https errors
--isolated keep the browser profile in memory, do not save
it to disk.
--image-responses <mode> whether to send image responses to the client.
Can be "allow", "omit", or "auto". Defaults to
"auto", which sends images if the client can
display them.
--no-sandbox disable the sandbox for all process types that
are normally sandboxed.
--output-dir <path> path to the directory for output files.
--port <port> port to listen on for SSE transport.
--proxy-bypass <bypass> comma-separated domains to bypass proxy, for
example ".com,chromium.org,.domain.com"
--proxy-server <proxy> specify proxy server, for example
"http://myproxy:3128" or "socks5://myproxy:8080"
--save-trace Whether to save the Playwright Trace of the
session into the output directory.
--storage-state <path> path to the storage state file for isolated
sessions.
--user-agent <ua string> specify user agent string
--user-data-dir <path> path to the user data directory. If not
specified, a temporary directory will be created.
--viewport-size <size> specify browser viewport size in pixels, for
example "1280, 720"
--vision Run server that uses screenshots (Aria snapshots
are used by default)You can configure the Playwright MCP server using a JSON configuration file. Specify the path to this file with the --config option when starting the server.
{
// Browser configuration
browser?: {
// Browser type to use (chromium, firefox, or webkit)
browserName?: 'chromium' | 'firefox' | 'webkit';
// Keep the browser profile in memory, do not save it to disk.
isolated?: boolean;
// Path to user data directory for browser profile persistence
userDataDir?: string;
// Browser launch options (see Playwright docs)
// @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch
launchOptions?: {
channel?: string; // Browser channel (e.g. 'chrome')
headless?: boolean; // Run in headless mode
executablePath?: string; // Path to browser executable
// ... other Playwright launch options
};
// Browser context options
// @see https://playwright.dev/docs/api/class-browser#browser-new-context
contextOptions?: {
viewport?: { width: number, height: number };
// ... other Playwright context options
};
// CDP endpoint for connecting to existing browser
cdpEndpoint?: string;
// Remote Playwright server endpoint
remoteEndpoint?: string;
},
// Server configuration
server?: {
port?: number; // Port to listen on
host?: string; // Host to bind to (default: localhost)
},
// List of enabled capabilities
capabilities?: Array<
'core' | // Core browser automation
'tabs' | // Tab management
'pdf' | // PDF generation
'history' | // Browser history
'wait' | // Wait utilities
'files' | // File handling
'install' | // Browser installation
'testing' // Testing
>;
// Enable vision mode (screenshots instead of accessibility snapshots)
vision?: boolean;
// Directory for output files
outputDir?: string;
// Network configuration
network?: {
// List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
allowedOrigins?: string[];
// List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
blockedOrigins?: string[];
};
/**
* Do not send image responses to the client.
*/
noImageResponses?: boolean;
}If you run the MCP server in an environment with a display, you can start it as a standalone service that exposes an SSE endpoint. Pass a port, then connect your MCP client to the SSE URL.
npx @playwright/mcp@latest --port 8931
// In the client configuration, point to the SSE endpoint
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/sse"
}
}
}You can run the Playwright MCP server in Docker. The Docker image currently supports headless chromium.
{
"mcpServers": {
"playwright": {
"command": "docker",
"args": ["run", "-i", "--rm", "--init", "--pull=always", "mcr.microsoft.com/playwright/mcp"]
}
}
}If you prefer to build the image yourself, you can run: docker build -t mcr.microsoft.com/playwright/mcp .
You can create a server programmatically and expose an SSE transport to integrate with your MCP client. The example below shows creating a headless Playwright MCP server with an SSE transport.
import http from 'http';
import { createConnection } from '@playwright/mcp';
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
http.createServer(async (req, res) => {
// ...
// Creates a headless Playwright MCP server with SSE transport
const connection = await createConnection({ browser: { launchOptions: { headless: true } } });
const transport = new SSEServerTransport('/messages', res);
await connection.sever.connect(transport);
// ...
});The Playwright MCP server offers a collection of actions you can invoke to interact with web pages. These tools run through the MCP client and operate on the page's accessibility snapshots or, optionally, vision-based interactions if you enable vision mode.
Key interactions include browsing, clicking, typing, selecting options, dragging, waiting for text, and handling dialogs. You can also capture page snapshots, take screenshots or PDFs, and manage browser tabs.
Capture accessibility snapshot of the current page, this is better than screenshot.
Perform click on a web page.
Drag and drop between two elements.
Hover over element on page.
Type text into an editable element.
Select an option in a dropdown.
Press a key on the keyboard.
Wait for text to appear or disappear or a specified time to pass.
Upload one or multiple files.
Handle a dialog by accepting or providing prompt text.
Navigate to a URL.
Go back to the previous page.
Go forward to the next page.
Take a screenshot of the current page.
Save page as PDF.
List all network requests since page load.
Get console messages.
Install the browser specified in the config.
Close the browser.
Resize the browser window.
List browser tabs.
Open a new tab.
Select a tab by index.
Close a tab by index.
Generate a Playwright test for a given scenario.
Take a screenshot in Vision mode.
Move the mouse to a position on screen.
Click at a position on screen.
Drag the mouse from one position to another.
Type text in Vision mode.
Wait for text or time in Vision mode.