SuperAPI AI Directory

playwright-mcp

Playwright browser automation: interact with web pages through structured accessibility snapshots.

Open website

About this tool

Playwright MCP is a Model Context Protocol (MCP) server that provides browser automation capabilities using Playwright. It lets LLMs interact with web pages through structured accessibility snapshots, bypassing the reliance on screenshots or vision-tuned models.

Purpose and positioning: This project provides an MCP interface on top of Playwright. The material points out that if using a coding agent, the CLI+SKILLS approach may be more suitable: CLI calls save more tokens, avoid loading huge tool schemas and lengthy accessibility trees into the model context, and are better suited for high-throughput coding agents that need to balance the context window between large codebases, tests, and reasoning. MCP remains suitable for specialized agent loops that require persistent state, rich introspection, and iterative reasoning about page structure, such as exploratory automation, self-healing tests, or long-running autonomous workflows, where the value of maintaining a continuous browser context outweighs the token cost.

Main capabilities: The material describes its features as fast and lightweight, using Playwright's accessibility tree rather than pixel input; LLM-friendly, requiring no vision model, with purely structured data operations; and highly deterministic tool application, avoiding the common ambiguities of screenshot-based approaches. The tools listed in the documentation include browser_click (performs a click on a web page, supporting double-click, specifying mouse buttons and modifier keys), browser_close (closes the page), browser_console_messages (retrieves console messages, can filter by level, return all session messages, or save to a file), browser_drag (performs drag and drop between two elements), browser_drop (drags and drops files or MIME-type data onto an element), and others.

Environment requirements: Node.js 18 or newer; VS Code, Cursor, Windsurf, Claude Desktop, Goose, Grok, Junie, or any other MCP client.

Usage: First install the Playwright MCP server in the client. Most tools work with the standard configuration (the command is npx @playwright/mcp@latest). The material provides integration methods for various clients, including Amp, Antigravity, Claude Code, Cline, Codex, Copilot, Cursor, Factory, Goose, Grok, Junie, Kiro, opencode, Qodo Gen, VS Code (including VS Code CLI installation), Warp, Windsurf, etc., are added respectively through graphical settings, configuration files, or the command line.

Browser state and configuration: A persistent profile can be used like a normal browser (default), all login information is saved in the persistent profile, and it can also be deleted between sessions to clear offline state; the persistent profile is located in a specific location and can be overridden with the --user-data-dir parameter. Among these, {workspace-hash} is derived from the workspace root directory of the MCP client, so different projects automatically use different profiles. A persistent profile can only be used by one browser instance at a time, and concurrent MCP clients sharing the same workspace will conflict; if multiple clients need to run in parallel, start with --isolated, or point to different --user-data-dir. In isolated mode, each session uses an isolated profile, and the session storage state is lost after the browser closes. The initial storage state can also be provided through the configured contextOptions or the --storage-state parameter. Regarding browser extensions, the Playwright MCP Chrome extension can connect to existing browser tabs and reuse logged-in sessions and browser state.

Ways to provide initial state: Storage state can be started from the user data directory with --user-data-dir (persisting all browser data across sessions), or cookies and local storage can be loaded from a file into an isolated browser context with --storage-state. Page state can be set with --init-page pointing to a TypeScript file that will be evaluated on the Playwright page object to run arbitrary initialization code, or with --init-script pointing to a JavaScript file as an initialization script, evaluated before any script on each page, to override browser APIs or set up the environment.

Configuration files and standalone deployment: The server can be configured through a JSON configuration file, specified with the --config command-line option. When running a headed browser on a system without a display or as an IDE worker process, you can run the MCP server in an environment with DISPLAY and pass --port to enable HTTP transport, then in the MCP client configuration set url to that HTTP endpoint. The material also states that the Docker implementation currently only supports headless Chromium, and the container can be run as a long-term service, with the server listening on host port 8931, accessible to any MCP client, and you can also build the Docker image yourself.

Limitations and security: Playwright MCP is not a security boundary, and the material recommends referring to MCP security best practices to protect the deployment.