Back to AI for QA
Sreenidhi Rajakrishnan
@sreenidhirajakrishnan

Playwright MCP setup guide

Get an AI to drive a real browser in about ten minutes. No test framework, no coding.

Pick your AI app in step 2 and skip the others.

WHAT YOU NEED
☐ A laptop (Windows, Mac or Linux)
☐ Node.js 20 or newer
☐ One AI app that supports MCP
☐ A test site you are allowed to click around

Step 1. Install Node.js

Playwright MCP runs through Node. If you already use Playwright with TypeScript, you have it.

  1. Go to nodejs.org and download the LTS version.
  2. Install it with the default options.
  3. Open a terminal and check the version:
node -v
v22.11.0 ← any number 20 or higher is fine

Step 2. Add Playwright MCP to your AI app

Every app needs the same one line: npx @playwright/mcp@latest. Only the place you paste it changes.

VS Code with GitHub Copilot

Run this in a terminal, then restart VS Code:

code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'

Open Copilot Chat, switch it to Agent mode, and click the tools icon to see the Playwright tools listed.

Cursor
  1. Open Cursor Settings, MCP, Add new MCP Server.
  2. Name it playwright, choose the command type.
  3. Command: npx @playwright/mcp@latest, then save.
Claude Code

One command in your terminal:

claude mcp add playwright npx @playwright/mcp@latest

Start Claude Code and type /mcp. You should see playwright marked as connected.

Claude Desktop, Windsurf and most other apps

Open the app's MCP settings file and paste this block. The word mcpServers is just the name the file uses for its list of MCPs; leave it as is.

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

In Claude Desktop the file is claude_desktop_config.json (Settings, Developer, Edit Config). Quit the app fully and reopen it after saving.

Step 3. Check it worked

Type this into your AI app:

“Open playwright.dev and tell me the page title.”

A browser window should open on its own, load the site and close the loop with the title. The first run takes longer because it downloads a browser. If it asks permission to use a Playwright tool, say yes.

Step 4. Your first three real prompts

Smoke check. “Open [staging URL], log in with [test user], and confirm the dashboard shows the user’s name.”
Bug repro. “Follow these steps from bug PAY-1182 and tell me exactly where it fails: [paste steps].”
Turn it into a test. “Now write what you just did as a Playwright TypeScript test using getByRole locators.”

Useful options

Add these after @playwright/mcp@latest in your command or in the args list.

OptionWhat it does
--headlessRuns without a visible window. Use once you trust it.
--browser=firefoxUses Firefox or webkit instead of Chrome.
--isolatedFresh browser profile every time, nothing saved between runs.
--storage-state=auth.jsonStarts already logged in, so it skips logins and OTPs.
--caps=visionLets it use screenshots too, for canvas or chart heavy pages.

If something goes wrong

What you seeFix
“npx is not recognised”Node is not installed, or the terminal was open before you installed it. Reopen the terminal.
Playwright tools do not show upFully quit and reopen the app. In VS Code, make sure Copilot is in Agent mode.
Browser never opensThe first run downloads a browser. Wait a minute, or run npx playwright install chromium.
Stuck at the login or OTP pageUse a test account without OTP, or a saved session with --storage-state.
Error in the settings fileA missing comma or bracket. Paste the block exactly as shown above.
Five rules before you trust it
  1. Use staging and a throwaway test account. Never production.
  2. Ask it to list every check it made, then verify two of them yourself.
  3. Expect a slightly different path on each run. That is normal.
  4. Turn anything useful into a proper .spec.ts before it goes in CI.
  5. The agent does the clicking. Deciding if the result is right is your job.

Commands checked against the official Playwright MCP README, October 2026. Apps update their menus often; if a menu name has moved, search the app's settings for “MCP”.

Follow Sreenidhi Rajakrishnan for more SDET and AI content@sreenidhirajakrishnan