Labsco
djannot logo

Puppeteer Vision

β˜… 48

from djannot

Scrape webpages and convert them to markdown using Puppeteer. Features AI-driven interaction capabilities.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedPaid serviceAdvanced setup

MseeP.ai Security Assessment Badge

Puppeteer vision MCP Server

This Model Context Protocol (MCP) server provides a tool for scraping webpages and converting them to markdown format using Puppeteer, Readability, and Turndown. It features AI-driven interaction capabilities to handle cookies, captchas, and other interactive elements automatically.

Now easily runnable via npx!

Features

  • Scrapes webpages using Puppeteer with stealth mode
  • Uses AI-powered interaction to automatically handle:
    • Cookie consent banners
    • CAPTCHAs
    • Newsletter or subscription prompts
    • Paywalls and login walls
    • Age verification prompts
    • Interstitial ads
    • Any other interactive elements blocking content
  • Extracts main content with Mozilla's Readability
  • Converts HTML to well-formatted Markdown
  • Special handling for code blocks, tables, and other structured content
  • Accessible via the Model Context Protocol
  • Option to view browser interaction in real-time by disabling headless mode
  • Easily consumable as an npx package.

Using as an MCP Tool with NPX

This server is designed to be integrated as a tool within an MCP-compatible LLM orchestrator. Here's an example configuration snippet:

Copy & paste β€” that's it
{
  "mcpServers": {
    "web-scraper": {
      "command": "npx",
      "args": ["-y", "puppeteer-vision-mcp-server"],
      "env": {
        "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE",
        // Optional:
        // "VISION_MODEL": "gpt-4.1",
        // "API_BASE_URL": "https://api.example.com/v1",
        // "TRANSPORT_TYPE": "stdio", // or "sse" or "http"
        // "DISABLE_HEADLESS": "true" // To see the browser during operations
      }
    }
    // ... other MCP servers
  }
}

When configured this way, the MCP orchestrator will manage the lifecycle of the puppeteer-vision-mcp-server process.

Communication Modes

The server supports three communication modes:

  1. stdio (Default): Communicates via standard input/output.
    • Perfect for direct integration with LLM tools that manage processes.
    • Ideal for command-line usage and scripting.
    • No HTTP server is started. This is the default mode.
  2. SSE mode: Communicates via Server-Sent Events over HTTP.
    • Enable by setting TRANSPORT_TYPE=sse in your environment.
    • Starts an HTTP server on the specified PORT (default: 3001).
    • Use when you need to connect to the tool over a network.
    • Connect to: http://localhost:3001/sse
  3. HTTP mode: Communicates via Streamable HTTP transport with session management.
    • Enable by setting TRANSPORT_TYPE=http in your environment.
    • Starts an HTTP server on the specified PORT (default: 3001).
    • Supports full session management and resumable connections.
    • Connect to: http://localhost:3001/mcp

How It Works

AI-Driven Interaction

The system uses vision-capable AI models (configurable via VISION_MODEL and API_BASE_URL) to analyze screenshots of web pages and decide on actions like clicking, typing, or scrolling to bypass overlays and consent forms. This process repeats up to maxInteractionAttempts.

Content Extraction

After interactions, Mozilla's Readability extracts the main content, which is then sanitized and converted to Markdown using Turndown with custom rules for code blocks and tables.

Customization (for Developers)

You can modify the behavior of the scraper by editing:

  • src/ai/vision-analyzer.ts (analyzePageWithAI function): Customize the AI prompt.
  • src/ai/page-interactions.ts (executeAction function): Add new action types.
  • src/scrapers/webpage-scraper.ts (visitWebPage function): Change Puppeteer options.
  • src/utils/markdown-formatters.ts: Adjust Turndown rules for Markdown conversion.

Dependencies

Key dependencies include:

  • @modelcontextprotocol/sdk
  • puppeteer, puppeteer-extra
  • @mozilla/readability, jsdom
  • turndown, sanitize-html
  • openai (or compatible API for vision models)
  • express (for SSE mode)
  • zod