Cover image
Try Now
2025-03-26

Un serveur MCP dramaturge universel pour l'automatisation du navigateur dans des environnements conteneurisés

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

Playwright Universal MCP

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)

# Install the MCP Python SDK
pip install git+https://github.com/microsoft/mcp-python-sdk.git

# Install the MCP server globally
pipx install playwright-universal-mcp

# Install the required browsers
playwright install chromium
# Optional: install other browsers
playwright install firefox webkit msedge chrome

Option 2: Install in a Python virtual environment

# Create and activate a virtual environment
python -m venv playwright-mcp-venv
source playwright-mcp-venv/bin/activate

# Install the MCP Python SDK
pip install git+https://github.com/microsoft/mcp-python-sdk.git

# Install the package
pip install playwright-universal-mcp

# Install browsers
playwright install chromium

Option 3: Install from source

# Clone the repository
git clone https://github.com/xkiranj/playwright-universal-mcp.git
cd playwright-universal-mcp

# Install the MCP Python SDK
pip install git+https://github.com/microsoft/mcp-python-sdk.git

# Install the package
pip install -e .

# Install browsers
playwright install chromium

Usage

Command Line Options

playwright-universal-mcp --help
usage: playwright-universal-mcp [-h] [--browser {chromium,firefox,webkit,msedge,chrome}] [--headless] [--headful] [--debug] [--browser-arg BROWSER_ARG]

Universal Playwright MCP server with multi-browser support

options:
  -h, --help            show this help message and exit
  --browser {chromium,firefox,webkit,msedge,chrome}, -b {chromium,firefox,webkit,msedge,chrome}
                        Browser to use (default: chromium)
  --headless            Run browser in headless mode (default: true)
  --headful             Run browser in headful mode (with GUI)
  --debug               Enable debug logging
  --browser-arg BROWSER_ARG
                        Additional browser arguments (can be specified multiple times)

Basic Examples

# Start with default options (Chromium in headless mode)
playwright-universal-mcp

# Use Microsoft Edge
playwright-universal-mcp --browser msedge

# Use Firefox in headful mode (visible browser window)
playwright-universal-mcp --browser firefox --headful

# Enable debug logging
playwright-universal-mcp --debug

# Pass additional arguments to the browser
playwright-universal-mcp --browser-arg="--disable-gpu" --browser-arg="--window-size=1920,1080"

MCP Configuration

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

Claude Desktop Configuration

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

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

Running as a PM2 Service

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

  1. Create a PM2 configuration file:
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
  1. Start the service:
pm2 start ~/playwright-universal-mcp.config.js
  1. Save the PM2 process list:
pm2 save

Containerized Usage

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

FROM python:3.10-slim

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

# Install the package
RUN pip install playwright-universal-mcp

# Install browsers (install the ones you need)
RUN playwright install chromium

# Run the MCP server
ENTRYPOINT ["playwright-universal-mcp", "--headless"]

Available Browser Tools

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

License

MIT License

Acknowledgments

This project builds upon:

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • apappascs
  • Découvrez la collection la plus complète et la plus à jour de serveurs MCP sur le marché. Ce référentiel sert de centre centralisé, offrant un vaste catalogue de serveurs MCP open-source et propriétaires, avec des fonctionnalités, des liens de documentation et des contributeurs.

  • ShrimpingIt
  • Manipulation basée sur Micropython I2C de l'exposition GPIO de la série MCP, dérivée d'Adafruit_MCP230XX

  • huahuayu
  • Une passerelle API unifiée pour intégrer plusieurs API d'explorateur de blockchain de type étherscan avec la prise en charge du protocole de contexte modèle (MCP) pour les assistants d'IA.

  • deemkeen
  • Contrôlez votre MBOT2 avec un combo d'alimentation: MQTT + MCP + LLM

  • jae-jae
  • MCP Server pour récupérer le contenu de la page Web à l'aide du navigateur sans tête du dramwright.

    Reviews

    5 (1)
    Avatar
    user_Y2L0tlLE
    2025-04-15

    I've been using the rollup-plugin-mcp by situ2001, and it has significantly streamlined my workflow. The plugin is robust and integrates seamlessly with my existing setup. The documentation is clear, and the support from the author has been outstanding. Highly recommend it for anyone looking to enhance their Rollup build process. Check it out here: https://mcp.so/server/rollup-plugin-mcp/situ2001