Playwright Universal MCP

by xkiranj

461 downloads Not rated yet MIT
GitHub

About

A universal Playwright MCP server for browser automation in containerized environments

Details

License
MIT

Explore

- 🌐 Multi-browser support: Choose between Chromium, Chrome, Microsoft Edge, Firefox, or WebKit
- 🐳 Container-friendly: Works in environments with limited privileges (like Docker containers)
- πŸ‘οΈ Headless/Headful modes: Run in headless mode for server environments or headful mode for debugging
- πŸ› οΈ Extensive browser control: Navigate, click, type, take screenshots, and more
- πŸ“„ Multiple page support: Create and manage multiple browser pages/tabs

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Playwright Universal MCP
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository


pip install git+https://github.com/microsoft/mcp-python-sdk.git

pipx install playwright-universal-mcp

playwright install chromium

playwright install firefox webkit msedge chrome


python -m venv playwright-mcp-venv
source playwright-mcp-venv/bin/activate

pip install playwright-universal-mcp

playwright install chromium


To use this MCP server with Claude Desktop or other MCP-enabled applications, add the following configuration:

Add the following to your ~/.config/Claude/claude_desktop_config.json file:

json
{
"mcpServers": {
"browser": {
"command": "playwright-universal-mcp",
"args": ["--browser", "msedge", "--headless"]
}
}
}

To run the MCP server as a persistent service with PM2:

1. Create a PM2 configuration file:

bash
cat > ~/playwright-universal-mcp.config.js << 'EOF'
module.exports = {
apps: [{
name: "playwright-universal-mcp",
script: "playwright-universal-mcp",
args: "--browser msedge --headless",
watch: false,
autorestart: true,
restart_delay: 3000
}]
}
EOF

2. Start the service:

bash
pm2 start ~/playwright-universal-mcp.config.js

3. Save the PM2 process list:

bash
pm2 save

This MCP server works well in containerized environments. Here's a simple Dockerfile example:

dockerfile
FROM python:3.10-slim

RUN apt-get update && apt-get install -y \
wget \
gnupg \
&& rm -rf /var/lib/apt/lists/*

RUN playwright install chromium

navigate

Navigate to a URL

click

Click on an element by selector or text

type

Type text into an input element

get_text

Get text content from an element

get_page_content

Get the current page HTML content

take_screenshot

Take a screenshot of the current page

new_page

Create a new browser page

switch_page

Switch to a different browser page

get_pages

List all available browser pages

wait_for_selector

Wait for an element to be visible on the page

get_browser_info

Get information about the current browser session

The MCP server provides the following tools:

- navigate: Navigate to a URL
- click: Click on an element by selector or text
- type: Type text into an input element
- get_text: Get text content from an element
- get_page_content: Get the current page HTML content
- take_screenshot: Take a screenshot of the current page
- new_page: Create a new browser page
- switch_page: Switch to a different browser page
- get_pages: List all available browser pages
- wait_for_selector: Wait for an element to be visible on the page
- get_browser_info: Get information about the current browser session

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "playwright universal mcp": {
            "playwright-universal-mcp": {
                "command": "python",
                "args": [
                    "-m",
                    "venv",
                    "playwright-mcp-venv"
                ]
            }
        }
    }
}

McpServers

{
    "playwright-universal-mcp": {
        "command": "python",
        "args": [
            "-m",
            "venv",
            "playwright-mcp-venv"
        ]
    }
}

A universal Model Context Protocol (MCP) server for browser automation that works reliably in containerized environments with limited privileges. It provides browser control capabilities to AI assistants like Claude, GPT-4, etc.

Features

- 🌐 Multi-browser support: Choose between Chromium, Chrome, Microsoft Edge, Firefox, or WebKit
- 🐳 Container-friendly: Works in environments with limited privileges (like Docker containers)
- πŸ‘οΈ Headless/Headful modes: Run in headless mode for server environments or headful mode for debugging
- πŸ› οΈ Extensive browser control: Navigate, click, type, take screenshots, and more
- πŸ“„ Multiple page support: Create and manage multiple browser pages/tabs

Installation

Option 1: Install with pipx (recommended)

```bash

No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.