Cover image
Try Now
2024-12-21

Espejo dehttps: //github.com/twolven/mcp-server-puppeteer-py

3 years

Works with Finder

0

Github Watches

1

Github Forks

1

Github Stars

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.

相关推荐

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

  • Andris Teikmanis
  • Latvian GPT assistant for developing GPT applications

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

  • Navid RezaeiSarchoghaei
  • Professional Flask/SQLAlchemy code guide. Follow: https://x.com/navid_re

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

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

  • Jan Meindl
  • Builds new GPTs

  • XLwebDev.com
  • PR Professional: Guiding You to Get Media Placements and Publicity Quickly and Effectively

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • OffchainLabs
  • Implementación de la prueba de estaca Ethereum

  • huahuayu
  • Una puerta de enlace de API unificada para integrar múltiples API de explorador de blockchain similar a Esterscan con soporte de protocolo de contexto modelo (MCP) para asistentes de IA.

  • deemkeen
  • Controle su MBOT2 con un combo de potencia: MQTT+MCP+LLM

  • zhaoyunxing92
  • 本项目是一个钉钉 MCP (Protocolo del conector de mensajes )服务 , 提供了与钉钉企业应用交互的 API 接口。项目基于 Go 语言开发 支持员工信息查询和消息发送等功能。 支持员工信息查询和消息发送等功能。

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

    Reviews

    5 (1)
    Avatar
    user_O0zEBkRo
    2025-04-16

    As a dedicated user of the twolven_mcp-server-puppeteer-py by MCP-Mirror, I am thoroughly impressed with its performance and capabilities. This server solution has significantly streamlined our automation processes, making it an invaluable tool in our tech stack. The seamless integration and robust functionality ensure efficient handling of tasks. Highly recommend it to anyone looking for a reliable server puppet tool! For more details, visit: https://github.com/MCP-Mirror/twolven_mcp-server-puppeteer-py