Playwright MCP Server: Let an Assistant Drive a Real Browser
Playwright MCP is Microsoft's open-source MCP server that gives an AI assistant a real browser to click, type, fill forms and read pages. Instead of looking at screenshots, it reads the page's accessibility tree, a structured list of buttons, links and text. It needs Node.js 18 or newer and installs with one npx line.
| Item | Value |
|---|---|
| npm package | @playwright/mcp |
| Requirement | Node.js 18 or newer |
| How it sees pages | Accessibility snapshots, not pixels |
| Browsers | chrome, firefox, webkit, msedge |
| Default window | Headed (visible); add --headless to hide it |
Updated
If you run a website or store, Playwright MCP is a practical way to have an assistant walk through your own pages like a customer would: open the menu, add something to the cart, submit the contact form, and report what broke. It is built on Playwright, a widely used browser testing library. Pick your options below and copy a config, then read the safety notes before pointing it at anything logged in.
Playwright MCP config builder
Choose options and copy the JSON. This page only writes text; it does not start a browser.
Config JSON
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--browser",
"chrome",
"--isolated"
]
}
}
}Options worth knowing
Each option also has an environment variable form, listed in the README.
| Option | What it does |
|---|---|
| --browser <browser> | chrome, firefox, webkit or msedge |
| --headless | Runs without a visible window; headed is the default |
| --isolated | Keeps the browser profile in memory, not on disk |
| --storage-state <path> | Loads cookies and local storage into an isolated session |
| --device <device> | Emulates a device, for example "iPhone 15" |
| --viewport-size <size> | Sets the viewport in pixels, for example "1280x720" |
| --caps <caps> | Turns on extra tool groups, such as pdf or vision |
| --allowed-origins / --blocked-origins | Allow or block request origins; not a security boundary |
| --timeout-action / --timeout-navigation | Defaults 5000 ms and 60000 ms |
| --port <port> | Serves over HTTP so a client can connect by URL |
Core tools
| Tool | Purpose | Read-only |
|---|---|---|
| browser_navigate | Open a URL | No |
| browser_snapshot | Capture the accessibility snapshot of the page | Yes |
| browser_click | Click an element | No |
| browser_type | Type into a field | No |
| browser_fill_form | Fill several fields at once | No |
| browser_take_screenshot | Save a screenshot | Yes |
| browser_console_messages | Read console messages | Yes |
| browser_network_requests | List network requests | Yes |
| browser_resize | Resize the window | No |
| browser_run_code_unsafe | Run Playwright code | No |
Config examples
Standard config
The minimal setup the README gives for most MCP apps.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}Run as an HTTP server and connect by URL
Useful when the app cannot open a window itself. The client then points at http://localhost:8931/mcp.
npx @playwright/mcp@latest --port 8931
Persistent, isolated or your own browser
Playwright MCP can run in three ways. The default persistent profile keeps cookies and logins in a folder per project. Isolated mode keeps everything in memory, which suits repeatable tests. The browser extension mode connects to a Chrome or Edge window you already have open, which is convenient but means the assistant acts with your real logins.
Only one browser can use a persistent profile at a time. If you run two assistant sessions on the same project, start the second with --isolated or a different --user-data-dir.
Good jobs for it on your own site
Checking that every link in the main menu opens a page that loads. Filling the contact form with test details and confirming the thank-you message appears. Reading the console messages on a page that seems slow. Resizing to a phone width and listing anything that overflows.
Write the results down as a checklist you can repeat after each change, so the assistant's run becomes your regression test.
How it works
- Choose a browser and whether the window should be visible or headless.
- Turn on isolated mode if you want every session to start clean, with nothing saved to disk.
- Add any extra capability groups you need, such as PDF saving or test assertions.
- Copy the JSON into your MCP app's config and restart it. The first run downloads the package.
Tips
- Test against a staging copy or a test account, not your live admin login.
- Use --isolated for test runs so cookies from one session never leak into the next.
- Ask for a snapshot before asking for clicks: the assistant targets elements from that list.
- Give exact steps ("open /pricing, click the second plan, report the total") rather than vague goals.
- Keep browser_run_code_unsafe in mind: it runs any Playwright code, so only use it with prompts you trust.
Frequently asked questions
What is an accessibility snapshot?
Browsers keep an accessibility tree, the same structured view screen readers use: each button, link, heading and field with its name and role. Playwright MCP hands the assistant that tree, so it can say "click the Add to cart button" without guessing from an image.
Is Playwright MCP a security boundary?
No, and its README says so in bold. Options like --allowed-origins and --blocked-origins are described as not a security boundary either. Treat it as a tool you supervise, and run it where a mistake cannot reach real customer data.
Does it remember logins between sessions?
By default it uses a persistent profile, so logins are stored on disk like a normal browser. With --isolated the profile lives in memory and is lost when the browser closes. You can preload cookies into an isolated session with --storage-state.
Can it take screenshots or save PDFs?
browser_take_screenshot is a core tool. PDF saving (browser_pdf_save) is opt-in with --caps=pdf, and click-by-coordinates tools need --caps=vision.
Should I use Playwright MCP or the Playwright CLI?
The README suggests coding agents may do better with the separate Playwright CLI, which uses fewer tokens. It keeps MCP for longer exploratory sessions where holding the browser state open is worth that cost.
Related: What is an MCP server?, Filesystem MCP server, How to build an MCP server, AI agent test checklist, Connect MCP in We.Inc.
Start a 7-day free trial or see all free tools. On We.Inc you get a 7-day free trial, not a free plan: card needed, $0 today, cancel before it ends and you pay nothing. AI building is on paid plans from $20 a month.
More in Guides
- Plumber SEO: A Practical Local SEO Checklist
- pnpm vs npm: What Actually Differs
- Website Portfolio Examples: Photographers, Designers and Architects | How-to Guide
- Respecting prefers-reduced-motion
- How to Build a Print-on-Demand Website
- Ecommerce Product Page Design: Anatomy and Examples
- How to Turn Your Website into a Progressive Web App
- Public Library Website Accessibility: Catalogs, Event Calendars and the Vendors Behind Them | How-to Guide
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App