Playwright MCP server

Control browsers to perform sophisticated web interactions and visual tasks.
Back to servers
Provider
Automata Labs
Release date
Dec 02, 2024
Language
TypeScript
Package
Stats
5.6K downloads
178 stars

MCP Server Playwright is a powerful Model Context Protocol server that allows large language models to interact with web browsers through Playwright. It enables LLMs to navigate websites, take screenshots, fill forms, and execute JavaScript in a real browser environment - essentially giving AI models the ability to use the web like a human.

Installation Options

Using Smithery for Claude Desktop

The simplest way to install MCP Server Playwright for Claude Desktop is via Smithery:

npx -y @smithery/cli install @automatalabs/mcp-server-playwright --client claude

Direct Installation

You can also install using npx directly:

npx @automatalabs/mcp-server-playwright install

This automated installation process will:

  • Check your operating system compatibility
  • Create or update the Claude configuration file
  • Set up the Playwright server integration

The configuration file will be placed at:

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

Using mcp-get

Alternative installation using mcp-get:

npx @michaellatman/mcp-get@latest install @automatalabs/mcp-server-playwright

Configuration

During installation, the following configuration is automatically added to your Claude config file:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@automatalabs/mcp-server-playwright"]
    }
  }
}

Available Tools

Navigation

Browser Navigation

Navigate to any URL:

{
  "url": "https://stealthbrowser.cloud"
}

Interaction

Click Elements

Click elements using CSS selectors:

{
  "selector": "#button-id"
}

Click by Text

Click elements by their text content:

{
  "text": "Click me"
}

Hover Over Elements

Hover over elements using CSS selectors:

{
  "selector": "#menu-item"
}

Hover by Text

Hover over elements by their text content:

{
  "text": "Hover me"
}

Fill Form Fields

Fill input fields with text:

{
  "selector": "#input-field",
  "value": "Hello World"
}

Select Dropdown Options

Select an option in a dropdown using CSS selector:

{
  "selector": "#dropdown",
  "value": "option-value"
}

Select by Text

Select an option in a dropdown by its text content:

{
  "text": "Choose me",
  "value": "option-value"
}

Capturing and Executing

Take Screenshots

Capture entire pages or specific elements:

{
  "name": "screenshot-name",     // required
  "selector": "#element-id",     // optional
  "fullPage": true               // optional, default: false
}

Execute JavaScript

Run JavaScript code in the browser context:

{
  "script": "document.title"
}

Available Resources

Console Logs

Access browser console output through console://logs which provides all console messages from the browser in text format.

Screenshots

Access captured screenshots through screenshot://<name> where <name> is the name specified during capture. These are available as PNG images.

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