Skip to main content

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
  1. 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.

Metadata

Release files for iflow-mcp_mcp-server-puppeteer-py 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iflow-mcp_mcp-server-puppeteer-py 0.1.0
File Size Uploaded
iflow_mcp_mcp_server_puppeteer_py-0.1.0.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for iflow-mcp_mcp-server-puppeteer-py 0.1.0
File Interpreter ABI Platform
iflow_mcp_mcp_server_puppeteer_py-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / iflow_mcp_mcp_server_puppeteer_py-0.1.0.tar.gz

Download URL iflow_mcp_mcp_server_puppeteer_py-0.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dda1dc62cf3607b5a1bd355336726038a1f745fbd46202592d76319bc6793c55
BLAKE2b-256 checksum
How to use checksums
11aa026b3204e3f6fbb7f4fe7d43f8bc556cffe4a0f2561380bd1213bb1bc2fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.9

Release files / iflow_mcp_mcp_server_puppeteer_py-0.1.0-py3-none-any.whl

Download URL iflow_mcp_mcp_server_puppeteer_py-0.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a765e02d14c7d68103d211e5c16f63253c7c904de8b62285332949acc11f6fff
BLAKE2b-256 checksum
How to use checksums
5b8e84fcc694484be2261ef2ec25d449b9e084eb829fb0e311231c7987087232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page