screenbox.dev / blog

Playwright MCP Server Guide: Setup and Browser Options

Playwright MCP Server Guide: Configure Playwright MCP, explore options, and compare with virtual desktop environments

The Playwright MCP server gives language models structured browser automation through accessibility snapshots rather than raw visual pixels. As of 2026-12-01, Microsoft ships it on npm as @playwright/mcp and as a Docker image. You can run it locally for direct web interactions, or give your agent a whole virtual desktop when it needs more than one browser. The choice depends on your execution model and on how much browser state you need to keep.

How do you run the Playwright MCP server locally?

A Playwright MCP install needs Node.js 20 or newer and an MCP client. Supported clients include VS Code, Cursor, Windsurf, Claude Desktop, and Goose. The package distributes under the name @playwright/mcp and executes directly using npx.

When configuring standard desktop clients, you register the package within your client settings JSON file:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

The Playwright MCP Claude Code setup is one command in your terminal:

claude mcp add playwright npx @playwright/mcp@latest

Claude Code supports adding stdio servers using double hyphens to separate Claude options from the command itself, as detailed in the Claude Code MCP documentation. The CLI also supports scope definitions: local scope applies only to you in the current directory, project scope writes settings to a shared .mcp.json file at the repository root, and user scope applies across all your projects. Claude Code prompts for confirmation before executing project-scoped servers found in version control. A detailed walkthrough of scoping mechanisms appears in this guide to configuring MCP in Claude Code. You can inspect active connections with claude mcp list or review connection health inside Claude Code using the /mcp command.

Several execution flags alter how the browser runs. By default, the browser launches in headed mode. Pass --headless to suppress the window, or pick another browser with --browser (chrome, firefox, webkit or msedge). --viewport-size sets the viewport, for example "1280x720". Extra tool groups, such as vision tools for coordinate-based clicking or the pdf group with browser_pdf_save, are enabled with --caps.

The server provides a wide set of core automation tools. These include navigation actions like browser_navigate and browser_navigate_back, content inspection tools like browser_snapshot, interaction actions like browser_click, browser_type, browser_fill_form, browser_select_option, browser_hover, and browser_drag, along with state helpers such as browser_wait_for, browser_take_screenshot, browser_resize, and browser_close. Tab handling occurs through browser_tabs.

By default, the server maintains browser profiles on disk, preserving authenticated sessions and site data between executions. On Linux, cache data defaults to ~/.cache/ms-playwright/mcp-{channel}-{workspace-hash}, while macOS stores profiles under ~/Library/Caches/ and Windows stores them under %USERPROFILE%\AppData\Local\ms-playwright\. Each project generates its own profile hash. Because a persistent profile supports only one active browser process at a time, parallel agent sessions need --isolated, which keeps the profile in memory, or a separate --user-data-dir for each client. Security relies on the host environment: the official Playwright MCP repository notes that the server is not a security boundary and that origin allowlists do not restrict redirects.

The Playwright MCP documentation notes that coding agents may do better with Playwright CLI plus skills because command-line calls use tokens more efficiently than loading full tool schemas and accessibility trees. MCP remains best suited for agent loops that require persistent browser state and structural reasoning over pages.

How do you deploy the server in Docker or on remote hosts?

When running automated pipelines or working on headless remote servers, you can decouple the browser process from your local desktop. If you need a headed browser on a remote machine without a physical display, start the server in an environment where DISPLAY is defined, bind it to a network port, and expose HTTP transport:

npx @playwright/mcp@latest --port 8931

Your client then connects over HTTP rather than stdio:

{
  "mcpServers": {
    "playwright": {
      "url": "http://localhost:8931/mcp"
    }
  }
}

Claude Code connects to remote endpoints using the transport flag:

claude mcp add --transport http playwright http://localhost:8931/mcp

For containerized workflows, Microsoft maintains the mcr.microsoft.com/playwright/mcp container image. The container implementation currently supports only headless Chromium. You can launch ephemeral container instances on demand:

{
  "mcpServers": {
    "playwright": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "--init", "--pull=always", "mcr.microsoft.com/playwright/mcp"]
    }
  }
}

If you prefer a long-lived container service that stays available for incoming agent requests, start the container with bound network interfaces:

docker run -d -i --rm --init --pull=always --entrypoint node --name playwright -p 8931:8931 mcr.microsoft.com/playwright/mcp /app/cli.js --headless --browser chromium --no-sandbox --port 8931 --host 0.0.0.0

When should you use Screenbox for desktop environments?

Playwright MCP controls a single browser engine, and its official container deployment remains limited to headless Chromium. When an agent requires an entire operating system workspace rather than an isolated browser tab, a virtual desktop container provides broader system access.

The self-hosted Screenbox website documents an open source AGPL-3.0 architecture hosted on the Screenbox repository. Each desktop operates as an independent Docker container packing XFCE, Xvnc, xrdp, and a full Chromium browser. Containers require roughly 2 GB of RAM and do not need a GPU. Agents connect via the standard MCP endpoint at http://localhost:8080/mcp:

{
  "mcpServers": {
    "screenbox": {
      "url": "http://localhost:8080/mcp"
    }
  }
}

Screenbox does not bundle or wrap Playwright MCP. Instead, it provides desktop control and browser inspection through its own toolset. Its desktop_chrome tool with the page_map action extracts structured headings, links, input fields, and buttons alongside viewport pixel coordinates. This structure lets agents click elements deterministically without relying on visual inspection models. Human operators can watch live execution over RDP or noVNC streams and take immediate control of the mouse and keyboard when human intervention is needed.

Containers provide process isolation rather than hardened virtual machine sandboxes, meaning the MCP API must never be exposed directly to the public internet. Architectural trade-offs between API-driven interfaces and graphical workstations are covered in this review of Claude computer use on Linux, while container boundaries are explored in detail in this guide on sandboxing agents with gVisor.

Which route fits your agent workflow?

FeatureLocal Playwright MCPContainerized Playwright MCPScreenbox Virtual Desktop
Runtime environmentLocal Node.js 20 or newerOfficial Docker imageAGPL-3.0 Docker container
Supported browserschrome, firefox, webkit, msedgeHeadless Chromium onlyDesktop Chromium
Page inspectionAccessibility tree snapshotsAccessibility tree snapshotsStructured page_map coordinates
Visual observationHeaded browser window by defaultHeadless, screenshots through browser_take_screenshotLive view over noVNC or RDP
Human takeoverNot covered in the READMENot covered in the READMETake over mouse and keyboard, then release
Client transportStdio, or HTTP with --portStdio or HTTPHTTP
Memory footprintNot stated in the READMENot stated in the READMEAbout 2 GB RAM per desktop, no GPU

A feature matrix evaluating Local Playwright MCP, Containerized Playwright MCP, and Screenbox Virtual Desktop across Runtime environment, Supported...

Frequently asked questions

Does the Playwright MCP server require a vision model?

No. The server inspects web pages by generating structured accessibility snapshots directly from the Playwright engine. Language models interpret structural trees rather than parsing visual screenshots, making standard text-based models effective for page navigation without vision capabilities.

Can you run multiple browser instances using the same profile?

No. The persistent browser profile stored on disk can only be held open by one active browser instance at a time. If you run multiple agent clients in parallel, use the isolated flag to store profiles entirely in temporary memory, or specify separate profile destinations using the user-data-dir option.

A decision tree branching from parallel agent sessions into two resolution paths: passing the isolated flag to keep profiles in temporary memory, or...

Is the Playwright MCP server a secure sandbox?

No. The official project repository explicitly notes that Playwright MCP does not constitute a security boundary. In addition, origin restrictions configured via allowed-origins do not prevent navigation redirects. Any untrusted code execution or browser sessions must be isolated using host-level security controls or container boundaries.

How do you run a headed browser on a server without a display?

You must launch the server on an environment where the DISPLAY variable points to an active display server, then supply the port argument to serve the MCP protocol over HTTP. Your client connects to the resulting HTTP URL. The official Docker image cannot be used for headed workflows because it only supports headless Chromium.