How to Set Up Playwright MCP in Claude Code, Cursor, Codex and VS Code Microsoft's Playwright MCP server lets coding agents in Claude Code, Cursor, Codex and VS Code control a browser through the Model Context Protocol, installed in each client via `npx @playwright/mcp@latest`. The server requires Node.js 18 or newer plus Chrome, Firefox, WebKit or Edge on the machine running it, and exposes tools for navigation, clicking, typing and screenshots, returning accessibility snapshots that identify elements by role and accessible name rather than by image. Options include `--headless`, `--browser` and `--isolated`, the last for agents that should not reuse saved cookies or logins. What Playwright MCP is Playwright MCP gives a coding agent browser access through the Microsoft Playwright MCP server https://github.com/microsoft/playwright-mcp . The agent can open a page, inspect it, and interact with elements while you work in Claude Code, Cursor, or another MCP client. The server exposes browser tools for actions such as navigation, clicking, typing, and taking screenshots. For page inspection, it can return an accessibility snapshot that identifies elements by roles and accessible names. An agent can use that structure to find a button or form field without interpreting a screenshot. The browser session helps the agent check what a page currently does, but it does not create a saved Playwright test. Prerequisites Playwright MCP needs Node.js 18 or newer and a supported browser Chrome, Firefox, WebKit or Edge on the machine that runs the server. The project README https://github.com/microsoft/playwright-mcp lists browser installation steps. Check the environment where your coding agent launches MCP servers, not just your usual terminal. A locally installed browser will not help if the server runs in a container or remote development environment that cannot access it. Install and configure by client Each client needs a configuration that starts the Playwright MCP server https://github.com/microsoft/playwright-mcp with npx . Use the configuration format for your coding agent below. Claude Code Add the server with Claude Code’s MCP command. claude mcp add playwright npx @playwright/mcp@latest Cursor In Cursor, open Cursor Settings MCP Add new MCP Server , pick the command type and enter npx @playwright/mcp@latest . To share the config with your team, commit it as .cursor/mcp.json in the project instead: { "mcpServers": { "playwright": { "command": "npx", "args": "@playwright/mcp@latest" } } } Codex Add the server with the Codex CLI: codex mcp add playwright npx "@playwright/mcp@latest" Or add the entry to ~/.codex/config.toml yourself: mcp servers.playwright command = "npx" args = "@playwright/mcp@latest" VS Code and GitHub Copilot Register the server with VS Code so GitHub Copilot can access its browser tools. code --add-mcp '{"name":"playwright","command":"npx","args": "@playwright/mcp@latest" }' Useful options Playwright MCP lets you choose how the browser runs. The server README https://github.com/microsoft/playwright-mcp documents --headless for runs without a visible browser window, --browser for choosing a browser, and --isolated for a profile that stays in memory rather than being saved to disk. npx @playwright/mcp@latest --headless --browser=firefox --isolated Use --isolated when you do not want a session to reuse saved cookies or logins. A persistent profile can only be used by one browser at a time, so if you run several agents at once, start each extra one with --isolated or its own --user-data-dir . Leave it off when you need a persistent profile, such as one you have already signed into. Add the same flags to the server command in your client configuration if you want them to apply whenever your coding agent starts Playwright MCP. Five example prompts Replace the URLs and UI labels with ones from your application. Each prompt asks the coding agent to report what it observed rather than assume an interaction succeeded. 1. Check navigation. “Open http://localhost:3000. Click the Pricing link and report the final URL and page heading.” The agent follows the link and checks whether the destination matches its label. 2. Inspect form validation. “Open http://localhost:3000/signup. Submit the form without entering any values. List the validation messages you can see, and do not create an account.” The agent tests the empty-form state without supplying credentials. 3. Verify a code change. “Open http://localhost:3000/settings. Check whether the Save button becomes enabled after I change a field. Do not click Save.” The agent checks the behavior affected by your change without modifying stored settings. 4. Check a narrow viewport. “Open http://localhost:3000 at a 375-pixel viewport width. Check whether the main navigation is accessible and report any controls you cannot reach.” The agent resizes the browser and tests navigation rather than judging appearance alone. 5. Inspect a failed request. “Open http://localhost:3000/products. If the product list fails to load, report the visible error and any relevant browser console messages.” The agent gathers evidence you can use to investigate the failure. Troubleshooting Browser fails to launch If the agent reports a missing browser executable, check which browser you selected in the Playwright MCP configuration. Install that browser using the instructions in the project README https://github.com/microsoft/playwright-mcp , then restart the MCP server. A successful server startup does not confirm that the selected browser can launch. Permission or port errors If the browser cannot start, check whether the process can write to its configured profile directory. An isolated profile still needs a writable location. If you configured a network port, check whether another process already uses it. A port conflict does not apply to configurations that communicate with the server through standard input and output. Slow or oversized browser output If an accessibility snapshot takes too long or floods the agent’s context, ask the agent to search the page with the browser find tool or pass a depth limit to browser snapshot instead of capturing the whole page again. Close tabs the task no longer needs, and avoid taking another snapshot when the previous one already contains the element the agent needs. What Playwright MCP doesn't do Playwright MCP https://github.com/microsoft/playwright-mcp lets a coding agent drive a browser during a session. The server does not save that session as a test, rerun it after a later commit, or gate a deploy in CI. An agent could write a Playwright test using its other tools, but browser access alone does not create a maintained test suite. If you need the agent to work with tests that run beyond the current session, Momentic’s MCP server https://momentic.ai/docs/coding-agents/mcp-server connects it to a testing system. The comparison of browser and testing MCP servers https://momentic.ai/blog/playwright-mcp-vs-testing-mcp-server explains where each fits.