Crawlab MCP Server

Official

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • The MCP server provides integration with Docker, allowing users to run the server in a containerized environment and integrate it with existing Crawlab Docker Compose setups.

  • The MCP server documentation uses Mermaid for architecture diagrams, illustrating the communication flow between components.

  • The MCP server integrates with OpenAI as an LLM provider, allowing AI applications to interact with Crawlab through the MCP protocol. The architecture shows OpenAI as one of the supported LLM providers for processing natural language queries.

Crawlab MCP サーバー

これは Crawlab のモデル コンテキスト プロトコル (MCP) サーバーであり、AI アプリケーションが Crawlab の機能と対話できるようにします。

概要

MCP サーバーは、AI アプリケーションが Crawlab の機能にアクセスするための標準化された方法を提供します。これには以下が含まれます。

  • スパイダー管理(作成、読み取り、更新、削除)
  • タスク管理(実行、キャンセル、再開)
  • ファイル管理(読み取り、書き込み)
  • リソース アクセス (スパイダー、タスク)

建築

MCP サーバー/クライアント アーキテクチャは、AI アプリケーションと Crawlab 間の通信を容易にします。

コミュニケーションフロー

  1. ユーザークエリ: ユーザーはMCPクライアントに自然言語クエリを送信します。
  2. LLM処理: クライアントはクエリをLLMプロバイダー(例:Claude、OpenAI)に転送します。
  3. ツール選択: LLMは必要なツールを識別し、ツール呼び出しを生成します
  4. ツール実行: クライアントはツール呼び出しをMCPサーバーに送信します。
  5. APIインタラクション: サーバーは対応するCrawlab APIリクエストを実行します。
  6. レスポンス生成: 結果はサーバーを経由してクライアントへ、そしてLLMへ返されます。
  7. ユーザーの応答: クライアントは最終的な人間が読める応答をユーザーに配信します。

インストールと使用方法

オプション1: Pythonパッケージとしてインストールする

便利な CLI を提供する Python パッケージとして MCP サーバーをインストールできます。

# Install from source pip install -e . # Or install from GitHub (when available) # pip install git+https://github.com/crawlab-team/crawlab-mcp-server.git

インストール後、CLI を使用できます。

# Start the MCP server crawlab_mcp-mcp server [--spec PATH_TO_SPEC] [--host HOST] [--port PORT] # Start the MCP client crawlab_mcp-mcp client SERVER_URL

オプション2: ローカルで実行

前提条件

  • Python 3.8以上
  • Crawlab インスタンスが実行中でありアクセス可能
  • CrawlabからのAPIトークン

構成

  1. .env.exampleファイルを.envにコピーします。
    cp .env.example .env
  2. Crawlab API の詳細を使用して.envファイルを編集します。
    CRAWLAB_API_BASE_URL=http://your-crawlab-instance:8080/api CRAWLAB_API_TOKEN=your_api_token_here

ローカルで実行

  1. 依存関係をインストールします:
    pip install -r requirements.txt
  2. サーバーを実行します。
    python server.py

Dockerで実行する

  1. Docker イメージをビルドします。
    docker build -t crawlab-mcp-server .
  2. コンテナを実行します。
    docker run -p 8000:8000 --env-file .env crawlab-mcp-server

Docker Composeとの統合

既存の Crawlab Docker Compose セットアップに MCP サーバーを追加するには、次のサービスをdocker-compose.ymlに追加します。

services: # ... existing Crawlab services mcp-server: build: ./backend/mcp-server ports: - "8000:8000" environment: - CRAWLAB_API_BASE_URL=http://backend:8000/api - CRAWLAB_API_TOKEN=your_api_token_here depends_on: - backend

AIアプリケーションでの使用

MCPサーバーは、AIアプリケーションが自然言語を介してCrawlabと対話することを可能にします。上記のアーキテクチャ図に従って、MCPシステムの使用方法は以下のとおりです。

接続の設定

  1. MCPサーバーを起動します。MCPサーバーが実行中でアクセス可能であることを確認します。
  2. AIクライアントを構成する: AIアプリケーションをMCPサーバーに接続する

例: Claude Desktop での使用

  1. クロードデスクトップを開く
  2. 設定 > MCPサーバーへ移動
  3. MCP サーバーの URL (例: http://localhost:8000 ) を使用して新しいサーバーを追加します。
  4. クロードとの会話では、自然言語でやりたいことを説明することで、Crawlabの機能を使用できるようになりました。

やり取りの例

私たちのアーキテクチャに基づいた、システムとのやり取りの例を以下に示します。

スパイダーを作成する:

User: "Create a new spider named 'Product Scraper' for the e-commerce project" ↓ LLM identifies intent and calls the create_spider tool ↓ MCP Server executes the API call to Crawlab ↓ Spider is created and details are returned to the user

タスクを実行する:

User: "Run the 'Product Scraper' spider on all available nodes" ↓ LLM calls the run_spider tool with appropriate parameters ↓ MCP Server sends the command to Crawlab API ↓ Task is started and confirmation is returned to the user

利用可能なコマンド

次のような自然言語コマンドを使用してシステムと対話できます。

  • 「私のクモをすべてリストする」
  • 「これらの仕様で新しいスパイダーを作成します...」
  • 「Xという名のクモのコードを見せてください」
  • 「このコードを使用して、Spider X の main.py ファイルを更新します...」
  • 「スパイダーXを実行し、完了したら通知してください」
  • 「スパイダーXの最後の実行結果を見せてください」

利用可能なリソースとツール

これらは、自然言語によるやりとりを可能にする基礎となるツールです。

リソース

  • spiders : すべてのクモを一覧表示
  • tasks : すべてのタスクを一覧表示する

ツール

クモ管理

  • get_spider : 特定のスパイダーの詳細を取得する
  • create_spider : 新しいスパイダーを作成する
  • update_spider : 既存のスパイダーを更新する
  • delete_spider : スパイダーを削除する

タスク管理

  • get_task : 特定のタスクの詳細を取得する
  • run_spider : スパイダーを実行する
  • cancel_task : 実行中のタスクをキャンセルする
  • restart_task : タスクを再開する
  • get_task_logs : タスクのログを取得する

ファイル管理

  • get_spider_files : スパイダーのファイルを一覧表示する
  • get_spider_file : 特定のファイルの内容を取得する
  • save_spider_file : コンテンツをファイルに保存する
-
security - not tested
F
license - not found
-
quality - not tested

AI アプリケーションが自然言語を通じて Crawlab の機能と対話し、スパイダー管理、タスク実行、ファイル操作を実行できるようにするモデル コンテキスト プロトコル サーバー。

  1. Overview
    1. Architecture
      1. Communication Flow
    2. Installation and Usage
      1. Option 1: Install as a Python package
      2. Option 2: Running Locally
      3. Prerequisites
      4. Configuration
      5. Running Locally
      6. Running with Docker
    3. Integration with Docker Compose
      1. Using with AI Applications
        1. Setting Up the Connection
        2. Example: Using with Claude Desktop
        3. Example Interactions
        4. Available Commands
      2. Available Resources and Tools
        1. Resources
        2. Tools
      ID: kou3odk02c