Puppeteer MCP Server (Python Implementation)

by twolven

17 stars
406 downloads
Not rated
GitHub

About

MCP server providing browser automation via Playwright (Python), enabling LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser.

Details

Author
twolven
GitHub stars
17
Downloads
406
Categories
Automation

- Full browser automation capabilities
- Page navigation to any URL
- Screenshot capture of entire page or specific elements
- Form interaction (clicking and filling fields)
- JavaScript execution in the browser console
- Configurable timeouts and detailed error handling
- Comprehensive logging (INFO, ERROR, DEBUG levels)

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 Puppeteer MCP Server (Python Implementation)
    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

Install the required packages with pip install -r requirements.txt, then install Playwright browsers using playwright install. Start the server by running python puppeteer_server.py, or configure it in Claude Desktop by adding a JSON entry with command "python" and args pointing to the server script.

Claude Desktop / Cursor

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

{
    "mcpServers": {
        "puppeteer mcp server (python implementation)": {
            "mcp-server-puppeteer-py": {
                "command": "python",
                "args": [
                    "puppeteer_server.py"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-server-puppeteer-py": {
        "command": "python",
        "args": [
            "puppeteer_server.py"
        ]
    }
}

Puppeteer MCP Server (Python Implementation)

A Model Context Protocol server that provides browser automation capabilities using Playwright (Python's equivalent to Puppeteer). This server enables LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment.

Overview

This Python implementation provides a stable alternative to the TypeScript version, offering the same capabilities with improved error handling and logging. It uses Playwright, which is the Python equivalent to Puppeteer, providing robust browser automation capabilities.

Key Features

Full browser automation Page navigation Screenshot capture (full page or elements) Form interaction (clicking and filling) JavaScript execution Console log monitoring Configurable timeouts Detailed error handling Comprehensive logging

Prerequisites

Python 3.8+ pip (Python package installer)

Installation

1. Install the required packages:
pip install -r requirements.txt

2. Install Playwright browsers:

playwright install

Usage

Starting the Server

Run the server directly:
python puppeteer_server.py

Claude Desktop Configuration

Add this to your Claude configuration file:
{
  "mcpServers": {
    "puppeteer": {
      "command": "python",
      "args": ["path/to/puppeteer.py"]
    }
  }
}

Available Tools

puppeteer_navigate

Navigate to any URL in the browser.
{
  "name": "puppeteer_navigate",
  "arguments": {
    "url": "https://example.com",
    "timeout": 60000  // optional, defaults to 60000ms
  }
}

puppeteer_screenshot

Capture screenshots of the entire page or specific elements.
{
  "name": "puppeteer_screenshot",
  "arguments": {
    "name": "my_screenshot",
    "selector": "#specific-element",  // optional
    "width": 1280,  // optional, default: 1280
    "height": 720,  // optional, default: 720
    "timeout": 30000  // optional, defaults to 30000ms
  }
}

puppeteer_click

Click elements on the page.
{
  "name": "puppeteer_click",
  "arguments": {
    "selector": ".button-class",
    "timeout": 30000  // optional, defaults to 30000ms
  }
}

puppeteer_fill

Fill out input fields.
{
  "name": "puppeteer_fill",
  "arguments": {
    "selector": "#input-id",
    "value": "text to fill",
    "timeout": 30000  // optional, defaults to 30000ms
  }
}

puppeteer_evaluate

Execute JavaScript in the browser console.
{
  "name": "puppeteer_evaluate",
  "arguments": {
    "script": "document.title",
    "timeout": 30000  // optional, defaults to 30000ms
  }
}

Error Handling

The server provides detailed error messages for common scenarios:
Navigation failures Element not found Timeout errors JavaScript execution errors Screenshot failures

Logging

Comprehensive logging is implemented with different levels: INFO: Standard operations ERROR: Operation failures DEBUG: Detailed execution information

Notes

Browser launches in non-headless mode for better debugging Default viewport size is 1280x720 All timeouts are configurable Console logs are captured and stored Screenshots are stored in memory with base64 encoding

Contributing

Contributions are welcome! Please read the repository's contributing guidelines before submitting pull requests.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
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.