Skip to main content
Glama
twolven

Puppeteer MCP Server

by twolven

Puppeteer MCP サーバー (Python 実装)

Playwright(Python版Puppeteer)を用いたブラウザ自動化機能を提供するモデルコンテキストプロトコル(LLM)サーバー。このサーバーにより、LLMはWebページとのインタラクション、スクリーンショットの取得、そして実際のブラウザ環境でのJavaScript実行が可能になります。

概要

このPython実装は、TypeScript版の安定した代替手段であり、エラー処理とログ出力が改善された上でTypeScript版と同等の機能を提供します。PuppeteerのPython版であるPlaywrightを使用し、堅牢なブラウザ自動化機能を提供します。

Related MCP server: Puppeteer MCP Server

主な特徴

  • 完全なブラウザ自動化

  • ページナビゲーション

  • スクリーンショットキャプチャ(ページ全体または要素)

  • フォームインタラクション(クリックと入力)

  • JavaScript実行

  • コンソールログ監視

  • 設定可能なタイムアウト

  • 詳細なエラー処理

  • 包括的なログ記録

前提条件

  • Python 3.8以上

  • pip (Python パッケージインストーラー)

インストール

  1. 必要なパッケージをインストールします。

pip install -r requirements.txt
  1. Playwright ブラウザをインストールします。

playwright install

使用法

サーバーの起動

サーバーを直接実行します。

python puppeteer_server.py

クロードデスクトップ構成

Claude 構成ファイルに以下を追加します。

{
  "mcpServers": {
    "puppeteer": {
      "command": "python",
      "args": ["path/to/puppeteer.py"]
    }
  }
}

利用可能なツール

操り人形師ナビゲート

ブラウザで任意の URL に移動します。

{
  "name": "puppeteer_navigate",
  "arguments": {
    "url": "https://example.com",
    "timeout": 60000  // optional, defaults to 60000ms
  }
}

操り人形師のスクリーンショット

ページ全体または特定の要素のスクリーンショットをキャプチャします。

{
  "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
  }
}

操り人形師クリック

ページ上の要素をクリックします。

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

操り人形師の塗りつぶし

入力フィールドに入力します。

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

操り人形師の評価

ブラウザコンソールで JavaScript を実行します。

{
  "name": "puppeteer_evaluate",
  "arguments": {
    "script": "document.title",
    "timeout": 30000  // optional, defaults to 30000ms
  }
}

エラー処理

サーバーは、一般的なシナリオに対して詳細なエラー メッセージを提供します。

  • ナビゲーションの失敗

  • 要素が見つかりません

  • タイムアウトエラー

  • JavaScript実行エラー

  • スクリーンショットの失敗

ログ記録

包括的なログ記録はさまざまなレベルで実装されています。

  • 情報: 標準操作

  • エラー: 操作失敗

  • DEBUG: 詳細な実行情報

注記

  • デバッグを向上させるために、ブラウザは非ヘッドレスモードで起動します

  • デフォルトのビューポートサイズは1280x720です

  • すべてのタイムアウトは設定可能

  • コンソールログがキャプチャされ保存されます

  • スクリーンショットはbase64エンコードでメモリに保存されます

貢献

貢献を歓迎します。プルリクエストを送信する前に、リポジトリの貢献ガイドラインをお読みください。

ライセンス

このプロジェクトは、Apache 2.0 ライセンスに基づいてライセンスされています。詳細については、LICENSE ファイルを参照してください。

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    F
    maintenance
    A Model Context Protocol server that provides browser automation capabilities using Playwright. This server enables LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment.
    32
    11,440 npm
    5,661
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that provides browser automation capabilities using Puppeteer, enabling LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment.
    7
    35,614 npm
    1
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that provides browser automation capabilities using Playwright, enabling LLMs to interact with web pages, take screenshots, generate test code, scrape web content, and execute JavaScript in real browser environments.
    31
    11,440 npm
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables AI assistants to interact with web pages through browser automation, supporting web scraping, form filling, navigation, and other browser-based tasks using Playwright.
    1
    MIT