Set Up Playwright MCP: Install, First Task, Safe Defaults
Configure Playwright MCP in a compatible client, verify the first browser tool call, and choose safer profile, origin, and version-pinning defaults.
Updated · Markdown version
Playwright MCP is a Model Context Protocol server that lets an MCP client, such as Claude Code, control a real browser through tool calls. You install it with one command, run a first task on a page you choose, and then tighten the defaults before you let an agent browse widely.
Before you start
Playwright MCP requires Node.js 20 or newer, checked 2026-11-25. The documented configuration launches @playwright/mcp@latest through npx; npx may download and cache the package, so this is still third-party code execution. Review the package and consider pinning a tested version for reproducible or sensitive environments.
Steps
- Configure the server. In an MCP client that accepts an
mcpServersobject, add"command": "npx"and"args": ["@playwright/mcp@latest"]. Client-specific menus and CLI syntax differ; the supplied source establishes the standard configuration, not the current Claude Code command. - Choose reproducibility.
@latestfollows the current registry tag when resolved. After a successful trial, pin the exact package version your environment approved. - Restrict the first run. Put flags after the package name.
"--headless"hides the browser window,"--isolated"keeps the profile in memory, and"--allowed-origins"takes a semicolon-separated list of trusted origins, not bare hostnames. - Run a first task. Ask the client to open one non-sensitive page you control and identify a visible heading or link.
- Check that it worked. Confirm that the client lists Playwright browser tools, the navigation call succeeds, and the result contains a structured accessibility snapshot or matching page element. If tools are absent, inspect the client's MCP logs and Node version. A text-only answer without a tool call is not proof that the server ran.
Safe defaults
The browser is headed by default. --isolated keeps profile state in memory. Without an explicit userDataDir, the configuration schema says a temporary profile directory is created; do not assume that it reuses your everyday browser profile or persists across separate server starts. The documented idle timeout defaults to one hour for headless browsers and is disabled for headed browsers. Use headed mode when observation matters and headless mode only when an unattended run is appropriate.
Origin controls need care. The configuration exposes allowed and blocked origin lists, but the project states that Playwright MCP itself is not a security boundary. Treat those lists as defense in depth, use full trusted origins, and enforce hard network restrictions outside the browser when isolation is required. The supplied source window does not establish redirect handling or allowlist/blocklist precedence, so verify those details in the current README before relying on them.
Pitfalls
- Accidental logins. A saved profile keeps signed-in sessions on disk. On a shared machine, pass
--isolatedso that no session survives the run. - Origin lists are not a boundary. Playwright MCP explicitly says it is not a security boundary. If the agent must stay on specific networks or origins, enforce that outside the browser too and verify current redirect behavior separately.
- Idle close looks like a fresh start. A headless browser closes after an hour of inactivity. If a later task starts from a blank browser, that idle close is the likely reason.
- Old Node.js. Versions below 20 are not supported. The failure can look like a missing tool list rather than a clear version error.
When to use a skill instead
Use the MCP server for exploration: opening a page, reading its structure, and checking one flow by hand. If you want a repeatable test suite that runs in CI, write it as a test file instead of relying on an agent session each time. The related skill browser-e2e-testing writes, repairs, and audits end-to-end browser tests in Playwright, Cypress, and Selenium, which suits a suite that must stay stable across runs. For a one-off page check, the MCP server alone is usually enough.
FAQ
How do I set up an MCP server? Add an MCP server entry whose command is npx and whose args contain @playwright/mcp@latest, following your client's current configuration instructions. For repeatable use, pin a reviewed version. Confirm that the client lists Playwright's browser tools and that one tool call returns a matching page snapshot before trusting the setup.
What is an MCP server? An MCP server is a program that provides context or capabilities to an MCP client. MCP servers may expose tools, resources, and prompts, depending on their declared capabilities; Playwright MCP is primarily documented here as a browser-automation tool server.
What is MCP in AI? MCP is a protocol for exchanging context between AI applications and servers. The application, called the host, creates one client per server, and each client lists the server's tools with tools/list and runs them with tools/call.
Related skills in this catalog
Platform Score is our assessment under a published method. It is not a safety guarantee.
Related guides
Terms this guide uses
This item is a worked example in the AI glossary for:
Sources
- https://github.com/microsoft/playwright-mcp (accessed 2026-11-25)
- https://modelcontextprotocol.io/docs/learn/architecture (accessed 2026-11-25)