home / mcp / playwright mcp server
Provides Playwright-based browser automation via structured accessibility snapshots for LLMs and MCP clients.
Configuration
View docs{
"mcpServers": {
"georgelochner-playwright-mcp-mod": {
"url": "http://localhost:8931/mcp"
}
}
}Playwright MCP is a lightweight server that exposes browser automation capabilities through Playwright’s accessibility tree. It lets you drive web pages using structured data, which is fast, deterministic, and friendly to language models that don’t rely on pixel-based inputs.
You connect to the Playwright MCP server from an MCP client (such as VS Code, Windsurf, or Claude) and issue automation commands through a defined tool API. Use the accessible snapshot and context data to navigate pages, interact with elements, and extract information without rendering full screenshots. This approach helps you build reliable automations that remain robust across visual changes.
Typical usage patterns include navigating to URLs, clicking elements, filling forms, taking page snapshots for accessibility, and inspecting network activity. You can also run arbitrary Playwright code snippets against the current page when needed, or manage browser tabs and view console output for debugging.
Prerequisites you need before installing the Playwright MCP server:
Install the Playwright MCP server using the standard configuration. The server runs locally via a package manager command.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}If you run the server as a standalone process, you can expose it over HTTP so clients connect via a URL. Start the server on a display-enabled system or from an IDE worker process, and provide the HTTP endpoint to your MCP client.
Start the server on port 8931 and connect clients via the HTTP URL.
npx @playwright/mcp@latest --port 8931
```
```json
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/mcp"
}
}
}You can run the Playwright MCP server in Docker as a headless container. The container version is suitable for automated environments and CI pipelines.
{
"mcpServers": {
"playwright": {
"command": "docker",
"args": ["run", "-i", "--rm", "--init", "--pull=always", "mcr.microsoft.com/playwright/mcp"]
}
}
}
```
Or run the container long-lived with a mapped port and an entrypoint for the MCP server:
```bash
docker run -d -i --rm --init --pull=always \
--entrypoint node \
--name playwright \
-p 8931:8931 \
mcr.microsoft.com/playwright/mcp \
cli.js --headless --browser chromium --no-sandbox --port 8931You can integrate Playwright MCP directly into a Node.js service. The following snippet shows how to create a connection and expose an SSE transport for client communication.
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.connect(transport);
// ...
});
```
"
]},{Click on a web page element using a target reference and optional modifiers and mouse button.
Close the current page or browser context.
Capture an accessibility snapshot of the current page, preferred over pixel-based screenshots.
Capture a screenshot of the current page or a specific element.
Navigate the browser to a specified URL.
Type text into an editable element with optional submission and speed controls.
Wait for specific text to appear, disappear, or a timeout to elapse.
Manage tabs: list, create, close, or switch between tabs.
Retrieve console messages from the page.
Run a block of Playwright code against the current page.
Verify that specific text is visible on the page.
Verify that a specific element is visible using accessibility data.