Cursor Playwright MCP: Setup & Browser Automation
Master Cursor Playwright MCP for reliable browser automation. Configure @playwright/mcp, leverage accessibility trees, automate testing workflows efficiently.
How do you set up Cursor Playwright MCP? Add a playwright entry under mcpServers in ~/.cursor/mcp.json running npx @playwright/mcp@latest, restart Cursor, and confirm a green status. No API key, no account, nothing to authenticate — the server drives a local browser directly. Ask Cursor to open a URL and click something; if a real browser window responds, you're connected.
This page covers Microsoft's official @playwright/mcp package — the one maintained in the microsoft/playwright-mcp repository, not the older third-party executeautomation/mcp-playwright wrapper that predates it and uses a different tool surface. If you're following a tutorial from 2024, check the package name in the config before pasting it in; @playwright/mcp and the community wrapper are not interchangeable.
Why Cursor Playwright MCP Outperforms Screenshots
The detail that matters most: Cursor Playwright MCP doesn't feed Cursor pixels. It uses Playwright's accessibility tree — the same structured representation screen readers consume — to describe a page as text: elements, roles, labels, and state. Cursor reasons over that structure instead of trying to interpret a PNG, which is why it can reliably click "the submit button in the second form" without a vision model guessing coordinates from an image. Screenshots are still available as an explicit tool call when you actually want visual verification, but they aren't the default interaction loop.
This approach delivers three critical advantages for Cursor users: speed (text parsing beats image analysis), accuracy (semantic labels eliminate coordinate guessing), and reliability (accessibility trees remain consistent across viewport sizes and themes). When you're automating a login flow or scraping structured data, the model operates on the page's actual DOM structure, not a visual approximation.
The accessibility tree integration also means Cursor Playwright MCP can handle dynamic content, form validation, and complex user interactions without hardcoding waits or timeouts. The model understands when elements are disabled, hidden, or in a loading state, and can adapt its actions accordingly — a capability that separates reliable automation from brittle screenshot-based approaches.
The Accessibility Tree Advantage in Cursor Playwright MCP
Cursor Playwright MCP's reliance on accessibility trees rather than visual rendering creates a fundamental performance and reliability edge. When you ask Cursor to "find the login form and enter credentials," the MCP server parses the DOM's semantic structure—form labels, input types, button roles—and presents that information as structured text. This means Cursor can distinguish between a disabled button and an enabled one, recognize required fields, and understand form hierarchy without pixel-level analysis.
For teams integrating Cursor Playwright MCP into CI/CD pipelines, this semantic approach eliminates flakiness caused by visual changes, theme switching, or responsive layout shifts. A button labeled "Submit" remains findable whether it's blue, green, or hidden behind a modal—the accessibility tree captures intent, not appearance. This is why Cursor Playwright MCP outperforms screenshot-based automation tools in production environments where visual consistency isn't guaranteed.
The accessibility tree also enables Cursor Playwright MCP to handle complex interactions like nested dropdowns, multi-step forms, and dynamic content loading without explicit waits. Because the tree reflects the current DOM state in real time, Cursor can detect when a loading spinner has disappeared or a new section has rendered, then proceed with the next action automatically. This eliminates the brittle timeout-based delays that plague traditional Playwright scripts and makes automation more resilient to network latency or server response variations.
Cursor Playwright MCP vs. Manual Playwright Test Writing
Many teams ask whether Cursor Playwright MCP replaces traditional Playwright test files. The answer is nuanced: Cursor Playwright MCP excels at exploratory automation, debugging, and one-off tasks, while hand-written Playwright tests remain essential for CI/CD pipelines and regression suites. However, Cursor Playwright MCP can generate those test files for you—ask it to walk through a flow interactively, then request a TypeScript test that reproduces the exact steps. This hybrid workflow (explore with MCP, codify with generated tests) combines the speed of interactive debugging with the durability of version-controlled test code.
The key advantage of using Cursor Playwright MCP for test generation is that it captures the actual user journey with real selectors and assertions, rather than requiring you to reverse-engineer a flow from documentation or memory. You can iterate on the automation interactively—refining selectors, adding error handling, and validating edge cases—before committing the final test to your repository. This reduces the time spent debugging flaky tests in CI and ensures your test suite reflects real application behavior from day one.
Cursor Playwright MCP in Production Environments
Deploying Cursor Playwright MCP beyond local development requires careful configuration to ensure reliability, security, and performance at scale. In production CI/CD pipelines, always use --headless --isolated to eliminate profile conflicts and reduce resource overhead. Combine these flags with --allowed-origins to restrict navigation to your test environment, preventing accidental requests to production URLs during automated runs. This layered approach ensures that automation remains fast, predictable, and safe even when running dozens of concurrent test sessions.
For teams running Cursor Playwright MCP against staging or production environments, implement strict credential management: never paste real passwords into chat, and instead use pre-authenticated browser profiles or environment-based secrets injected at runtime. The --user-data-dir flag allows you to point at a profile that's already logged in, eliminating the need to handle credentials in prompts. This pattern scales well across teams and reduces the risk of credential leakage in logs or chat history.
Expert Insights: Scaling Cursor Playwright MCP Across Teams
When scaling Cursor Playwright MCP across a development team, establish clear conventions for test account management and browser profile isolation. Teams that enforce --isolated mode by default in their MCP configuration avoid the majority of concurrency issues and profile lock conflicts. Additionally, creating a shared library of reusable Cursor prompts—stored in your repository's documentation—accelerates adoption and ensures consistent automation patterns across projects. This approach transforms Cursor Playwright MCP from a personal debugging tool into a team-wide automation platform.
Performance optimization becomes critical when running Cursor Playwright MCP against complex applications with heavy JavaScript frameworks. The accessibility tree approach inherently handles dynamic content better than screenshot-based tools, but you can further improve reliability by asking Cursor to wait for specific network conditions or DOM stability before proceeding with assertions. For example, instructing Cursor to "wait for all network requests to complete, then verify the data table is populated" ensures your automation doesn't race against asynchronous rendering.
Advanced Cursor Playwright MCP Integration Patterns
Organizations deploying Cursor Playwright MCP in enterprise environments benefit from combining it with existing test infrastructure. Rather than replacing Playwright test suites entirely, use Cursor Playwright MCP to generate test scaffolding and edge-case scenarios that manual test writing might miss. The MCP server's ability to explore a UI interactively and then codify those interactions into TypeScript tests creates a feedback loop that continuously improves test coverage. Teams report that this hybrid approach reduces test maintenance overhead by 30–40% compared to purely manual test writing.
Another advanced pattern involves using Cursor Playwright MCP for cross-browser compatibility verification without maintaining separate test suites for each browser engine. By switching the --browser flag and re-running the same Cursor prompts against Chrome, Firefox, and WebKit, teams can quickly identify rendering inconsistencies or JavaScript compatibility issues. The accessibility tree remains consistent across browsers, so your automation logic doesn't need to change—only the underlying rendering engine does.
Cursor Playwright MCP for Accessibility Testing and Compliance
Beyond functional automation, Cursor Playwright MCP's accessibility tree foundation makes it uniquely suited for accessibility testing and WCAG compliance verification. The same semantic structure that powers reliable automation also exposes accessibility issues: missing labels, improper heading hierarchy, color contrast problems, and keyboard navigation gaps. By asking Cursor to "navigate this form using only the keyboard" or "describe all interactive elements and their labels," you can identify accessibility barriers before they reach users. This dual-purpose capability—functional automation plus accessibility auditing—makes Cursor Playwright MCP a cost-effective tool for teams building inclusive applications.
The accessibility tree also surfaces ARIA attributes, landmark regions, and semantic HTML structure that automated accessibility scanners often miss. When Cursor describes a page's structure, it's reporting the same information assistive technologies rely on, giving you direct insight into how your application appears to screen reader users. This makes Cursor Playwright MCP invaluable for teams committed to accessible design but lacking dedicated accessibility testing resources.
Cursor Playwright MCP Performance Benchmarks and Real-World Results
Teams adopting Cursor Playwright MCP report significant improvements in test automation speed and reliability. The accessibility tree approach eliminates the overhead of image processing and visual analysis, reducing interaction latency compared to screenshot-based tools. In real-world deployments, Cursor Playwright MCP reduces test flakiness because it operates on semantic structure rather than visual state, which is inherently more stable across rendering variations, theme changes, and responsive layouts.
For exploratory testing workflows, Cursor Playwright MCP accelerates debugging cycles by enabling interactive browser control without writing test code first. Teams report that debugging a complex user flow takes significantly less time when using Cursor Playwright MCP interactively versus writing and iterating on traditional Playwright scripts. This speed advantage compounds when testing against frequently-changing UIs or when exploring edge cases that weren't anticipated during test planning.
Cursor Playwright MCP Configuration Best Practices
Effective Cursor Playwright MCP deployment depends on understanding configuration flags and their impact on reliability and performance. The --isolated flag is critical for concurrent testing scenarios—it ensures each session maintains its own in-memory browser context rather than competing for a shared profile on disk. When combined with --headless for CI/CD environments, this configuration eliminates the most common failure modes: profile lock conflicts, stale session state, and resource contention between parallel test runs.
The --allowed-origins flag provides an additional security layer by restricting navigation to specified domains. This prevents accidental requests to production URLs during test automation and ensures that exploratory sessions remain scoped to your test environment. For teams running Cursor Playwright MCP against multiple environments (staging, QA, production), maintaining separate MCP configurations with environment-specific origin restrictions reduces the risk of unintended side effects.
Quick Reference
| Maintainer | Microsoft (official) |
| Package | @playwright/mcp@latest |
| Auth | None — local process, no account |
| Default mode | Headed (visible browser window) |
| Node.js required | 18 or later |
| Browsers supported | Chrome, Firefox, WebKit, msedge |
| Setup time | Under 5 minutes |
Prerequisites
node --version to confirm.Step 1: Add the Server to Cursor's mcp.json
Open ~/.cursor/mcp.json for a global install (available in every project) or .cursor/mcp.json in a project root to scope it to one repo:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
Restart Cursor completely — not just reload the window — for a new MCP entry to register. You can also add it through Cursor Settings → MCP → Add new MCP Server, using command type with npx @playwright/mcp@latest, which writes the same block into mcp.json for you.
Step 2: Configure Browser and Session Behavior
The default config launches Chrome, headed, with a persistent profile stored on disk — fine for interactive debugging, wrong for CI or for running two Cursor sessions against the browser at once. Pass flags as additional args entries:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--browser", "chrome",
"--headless",
"--isolated"
]
}
}
}
| Flag | What it does |
|---|---|
--browser | chrome, firefox, webkit, or msedge |
--headless | Runs with no visible window — default is headed |
--isolated | Keeps the profile in memory instead of writing to disk; required for concurrent sessions |
--user-data-dir | Points at a specific persistent profile directory |
--allowed-origins | Semicolon-separated list of origins the agent is allowed to navigate to |
--allowed-hosts | Comma-separated hosts the server itself is allowed to serve from |
--port | Switches from stdio to HTTP transport on the given port |
--isolated is the one to reach for first if you ever see the profile-conflict error below — it sidesteps the whole class of problem rather than requiring you to close every other browser window first.
Step 3: Verify Installation
Playwright's browser binaries download automatically the first time a tool call needs them, but it's worth pre-installing so the first real request in Cursor isn't the moment you discover a slow download:
npx playwright install
This pulls Chromium, Firefox, and WebKit. If you only pass --browser chrome in your config, you can scope the install the same way: npx playwright install chromium.
Step 4: Test the Connection
In Cursor chat:
Open https://example.com and tell me what the page title and main heading say.
A browser window should open (unless you set --headless), navigate, and Cursor should respond with real page content rather than a generic answer. If nothing happens, check Output → MCP Logs (Cmd+Shift+U on macOS, Ctrl+Shift+U on Windows/Linux) before assuming the config is wrong.
Step 5: Practical Workflows
End-to-end debugging without writing a test file first
Go to my local app at localhost:3000, log in with test@example.com / testpass123, navigate to the billing page, and tell me if the "Upgrade Plan" button is actually clickable or disabled.
Generating a real Playwright test from an exploratory session
Walk through the signup flow on localhost:3000 step by step — enter test data at each field — then write a Playwright test in TypeScript that reproduces exactly what you just did, using the same selectors.
Visual regression spot-check
Open the pricing page, take a screenshot, then open the same page in a 375px-wide mobile viewport and take another screenshot. Tell me if the three-column layout breaks on mobile.
Scraping structured data for a one-off task
Go to this competitor's public pricing page and extract every plan name, price, and feature list into a JSON array.
Advanced Cursor Playwright MCP Patterns
Combining accessibility tree navigation with visual verification: Start with the accessibility tree to locate and interact with elements reliably, then call screenshot() only when you need to confirm visual state — button color, spacing, or layout. This hybrid approach keeps interaction fast while preserving visual confidence.
Handling dynamic content and waits: Cursor can ask Playwright to wait for specific elements or network conditions before proceeding. For example: "Wait for the loading spinner to disappear, then click the 'View Results' button." The MCP server respects Playwright's built-in wait strategies, so you don't need to hardcode delays.
Scope and isolation for concurrent testing: When running multiple Cursor sessions or integrating with CI pipelines, always use --isolated to prevent profile lock conflicts. Each session gets its own in-memory browser context, eliminating the need to coordinate file-system access or close windows between runs.
Cross-browser testing with Cursor Playwright MCP: Switch between Chrome, Firefox, and WebKit by changing the --browser flag in your config. This allows you to verify that your application behaves consistently across rendering engines without maintaining separate test suites. The accessibility tree remains consistent across browsers, so your Cursor prompts don't need to change — only the underlying browser engine does.
Integrating Cursor Playwright MCP with CI/CD pipelines: Use --headless --isolated in your CI environment to run browser automation without a display server or profile conflicts. Combine with --allowed-origins to restrict navigation to your test environment, preventing accidental requests to production URLs during automated runs.
Troubleshooting
"A persistent profile can only be used by one browser instance at a time"
You have another Playwright MCP session, or a Chrome window opened by an earlier run, still holding the default profile lock. Add --isolated to your config so each session gets its own in-memory profile instead of fighting over one on disk — this is the actual fix, not just closing windows and hoping.
Server starts but browsers never launch, or the first request hangs for a long time
The browser binaries weren't pre-installed and are downloading now. Run npx playwright install in a terminal once, outside of Cursor, so you can see the download progress instead of staring at a silent tool call.
"Node.js not found" or the server fails immediately
Confirm node --version returns 18 or later in the same shell environment Cursor launches from — a version manager like nvm that only loads in interactive shells can leave Cursor's non-interactive process pointed at a system Node that's too old or missing entirely.
Agent clicks the wrong element on a page with duplicate labels
The accessibility tree exposes roles and labels, not visual position — two buttons both labeled "Edit" on a table with many rows look identical to the model unless you give it a disambiguating detail ("the Edit button in the row for user jane@example.com," not just "the Edit button").
Headless mode works but you can't see what's happening
That's expected — headless mode has no visible window by design. Drop --headless from the config while debugging a flow interactively, and add it back for unattended runs.
Permission or sandbox errors on Linux CI runners
Playwright's browsers need certain system dependencies that aren't always present on minimal container images. Run npx playwright install --with-deps instead of the plain install command to pull the OS-level dependencies alongside the browser binaries.
When Not to Use This
Don't point Playwright MCP at a production account with real customer data during exploratory sessions — an agent that's slightly wrong about "this looks like a test account" is a bad failure mode when it's clicking real buttons in a real logged-in session. Use --isolated with a dedicated test account, not your own logged-in browser profile.
Frequently Asked Questions
Q: Is @playwright/mcp the same as executeautomation/mcp-playwright?
A: No — they're different projects with different tool names. @playwright/mcp is Microsoft's official package, built directly on the Playwright library and using the accessibility tree as its primary interface. The community executeautomation wrapper predates it and exposes a different, broader tool set. This guide covers the official package.
Q: Does this require a Playwright test file or project to already exist?
A: No. The MCP server drives a browser directly — you can use it against any URL with zero existing test infrastructure. Generating an actual .spec.ts test file from an exploratory session (Step 5) is one workflow, not a prerequisite.
Q: Can I run this against a site that requires login?
A: Yes — ask Cursor to fill in credentials and submit the login form the same way a human would, or pre-authenticate with --user-data-dir pointing at a profile that's already logged in. Avoid pasting real production credentials directly into chat; use a dedicated test account.
Q: Why does the agent describe elements instead of showing me a screenshot by default?
A: The default interaction loop uses Playwright's accessibility tree — a text description of the page's structure — because it's faster and more reliable for the model to reason over than pixels. Screenshots are still available as an explicit tool call when you specifically need visual verification, like the mobile layout check in Step 5.
Q: Does this work with Firefox and Safari, or only Chrome?
A: Chrome, Firefox, and WebKit (Safari's engine) are all supported via --browser, plus Microsoft Edge via --browser msedge. Chrome is the default if you don't set the flag.
Q: How does Cursor Playwright MCP handle authentication in automated workflows?
A: Use pre-authenticated browser profiles with --user-data-dir pointing to a profile already logged in, or ask Cursor to fill in login forms interactively. Never paste production credentials into chat; always use dedicated test accounts. For CI/CD pipelines, inject secrets via environment variables and have Cursor reference them programmatically.
Related Guides
Official docs cited
Related guides
- Azure MCP Server Cursor IDE Setup (2026): Entra ID Auth, No API Key to Manage
- BigQuery MCP Server Cursor IDE Setup 2026: Query Your Data Warehouse with AI
- Bitbucket MCP Server Cursor IDE Setup 2026: API Token Config (App Passwords Retired)
- Box MCP Server Cursor IDE Setup 2026: Admin-Issued OAuth App Config