Playwright Browser Automation MCP server

Enables LLM-powered browser automation for web tasks including navigation, interaction, and content extraction through Playwright's comprehensive browser control capabilities.
Back to servers
Setup instructions
Provider
Shannon Sands
Release date
Mar 13, 2025
Language
Python
Package
Stats
2.8K downloads

This MCP server provides a Playwright wrapper that enables LLM-powered clients to control a browser for automation tasks. It allows AI assistants to interact with web pages, take screenshots, extract content, and perform various browser actions.

Installation

Prerequisites

Before using the playwright-mcp server, you need to install the required dependencies:

uv add playwright
playwright install chromium

Adding to Claude Desktop

The server needs to be configured in Claude Desktop's configuration file.

macOS location:

~/Library/Application Support/Claude/claude_desktop_config.json

Windows location:

%APPDATA%/Claude/claude_desktop_config.json

Configuration

Using Published Version

Add the following to your Claude Desktop configuration file:

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

Using Development Version

If you're working with an unpublished version:

"mcpServers": {
  "playwright-mcp": {
    "command": "uv",
    "args": [
      "--directory",
      "/path/to/playwright-mcp",
      "run",
      "playwright-mcp"
    ]
  }
}

Available Features

Resources

The server provides access to browser screenshots:

  • Screenshot resource URI: screenshot://{page_id}
  • Screenshots are automatically available for all open pages

Prompts

The server includes an interpret-page prompt with these parameters:

  • Optional page_id to select which page to interpret
  • Optional focus to target specific aspects (full, forms, navigation, text)
  • Returns both text analysis and a screenshot

Tools

Browser Navigation

  • navigate: Go to a specific URL
  • new_page: Create a new browser page with a specific ID
  • switch_page: Switch to a different browser page
  • get_pages: List all available browser pages

Page Interaction

  • click: Click on an element using CSS selector
  • type: Type text into an input element
  • wait_for_selector: Wait for an element to appear on the page

Content Extraction

  • get_text: Get text content from an element
  • get_page_content: Get the entire page HTML
  • take_screenshot: Capture visual state of the page or element

Troubleshooting

For debugging issues with the MCP server, you can use the MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /path/to/playwright-mcp run playwright-mcp

The Inspector will provide a URL you can open in your browser to debug communication between Claude and the MCP server.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "playwright-mcp" '{"command":"uvx","args":["playwright-mcp"]}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "playwright-mcp": {
            "command": "uvx",
            "args": [
                "playwright-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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

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