Playwright Recorder MCP server

Playwright MCP enables browser automation and interaction recording by capturing DOM interactions, screenshots, and page navigation events to generate reproducible test scripts through a visual, context-driven workflow.
Back to servers
Provider
Ashish Bansal
Release date
Mar 17, 2025
Language
TypeScript
Package
Stats
4.6K downloads
13 stars

Playwright-MCP is a tool that bridges the gap between AI assistants and web browsers, allowing AI tools to understand and interact with web pages in real-time. This enables the creation of accurate, non-flaky Playwright tests by giving AI assistants direct access to page DOM, elements, and interactions, rather than forcing them to make educated guesses.

Installation

Prerequisites

Before installing playwright-mcp, ensure you have:

  • Node.js installed on your system
  • Playwright and its Chromium browser installed
  • An IDE that supports MCP, like Cursor

Setting Up with Cursor IDE

  1. Open Cursor IDE
  2. Navigate to Settings (⚙️)
  3. Select Cursor Settings → Go to the MCP tab
  4. Click "Add new MCP server"
  5. Fill in the following details:
    • Name → playwright-mcp
    • Command → npx -y playwright-mcp
  6. Click "Add" to complete the connection

If clicking on "Add new MCP server" opens a file (.cursor/mcp.json), paste the following code and save:

{
  "mcpServers": {
    "playwright-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "playwright-mcp"
      ]
    }
  }
}

Setting Up with Claude Desktop

  1. Install playwright-mcp globally:

    npm install -g playwright-mcp
    
  2. Locate and update the Claude configuration file:

    • On Windows: %APPDATA%\Claude\claude_desktop_config.json
    • On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  3. Add the following configuration:

    {
      "mcpServers": {
        "playwright": {
          "command": "npx",
          "args": ["-y", "playwright-mcp"]
        }
      }
    }
    
  4. Restart Claude Desktop to apply the changes

  5. Verify the installation by asking Claude to "List all available MCP tools." If properly installed, it should list tools like:

    • get-context
    • get-full-dom
    • get-screenshot
    • execute-code
    • init-browser
    • validate-selectors

Usage

After installation, your AI assistant will have access to several powerful capabilities:

Starting a Browser Session

Ask your AI assistant to initialize a browser using the init-browser command. A browser window will open after your approval.

Available Tools

Playwright-MCP provides several tools for interacting with web pages:

  • Recording interactions: Capture clicks, typing, and scrolling to generate Playwright test cases
  • Taking screenshots: Capture elements or full pages for visual context
  • Extracting the DOM: Get the entire HTML structure for generating accurate selectors
  • Executing JavaScript: Run custom JS inside the browser for debugging or automation

Creating Tests

Once connected, you can ask your AI assistant to:

  1. Navigate to a specific website
  2. Interact with elements on the page
  3. Generate Playwright test code based on these interactions
  4. Validate selectors to ensure they're robust

For detailed tutorials on using playwright-mcp with Claude or Cursor, visit the Claude tutorial or Cursor tutorial.

Additional Resources

For comprehensive documentation, visit the official playwright-mcp documentation.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later