Skip to main content
Glama
mabeldata

PocketBase MCP Server

by mabeldata

PocketBase MCP サーバー

鍛冶屋のバッジ メンテナンス:Mabel Data

これはPocketBaseインスタンスと連携するMCPサーバーです。PocketBaseコレクション内のレコードやファイルの取得、一覧表示、作成、更新、管理が可能です。

インストール

Smithery経由でインストール

Smithery経由で Claude Desktop 用の PocketBase MCP Server を自動的にインストールするには:

npx -y @smithery/cli install @mabeldata/pocketbase-mcp --client claude
  1. リポジトリのクローンを作成します (まだ作成していない場合)。

    git clone <repository_url>
    cd pocketbase-mcp
  2. 依存関係をインストールします:

    npm install
  3. サーバーを構築します。

    npm run build

    これにより、TypeScript コードがbuild/ディレクトリ内の JavaScript にコンパイルされ、エントリ ポイントが実行可能になります。

Related MCP server: PocketBase MCP Server

構成

このサーバーでは、次の環境変数を設定する必要があります。

  • POCKETBASE_API_URL : PocketBaseインスタンスのURL(例:http: http://127.0.0.1:8090 8090)。設定されていない場合は、デフォルトでhttp://127.0.0.1:8090になります。

  • POCKETBASE_ADMIN_TOKEN : PocketBaseインスタンスの管理者認証トークン。必須です。PocketBase管理UIから生成できます。APIキーをご覧ください。

これらの変数は、サーバーを Cline に追加するときに設定する必要があります (Cline のインストール セクションを参照)。

利用可能なツール

サーバーは、カテゴリ別に整理された次のツールを提供します。

記録管理

  • fetch_record : ID によって PocketBase コレクションから 1 つのレコードを取得します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          },
          "id": {
            "type": "string",
            "description": "The ID of the record to fetch."
          }
        },
        "required": [
          "collection",
          "id"
        ]
      }
  • list_records : PocketBaseコレクションからレコードを一覧表示します。ページ区切り、フィルタリング、並べ替え、リレーションの拡張をサポートします。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          },
          "page": {
            "type": "number",
            "description": "Page number (defaults to 1).",
            "minimum": 1
          },
          "perPage": {
            "type": "number",
            "description": "Items per page (defaults to 25).",
            "minimum": 1,
            "maximum": 100
          },
          "filter": {
            "type": "string",
            "description": "Filter string for the PocketBase query."
          },
          "sort": {
            "type": "string",
            "description": "Sort string for the PocketBase query (e.g., \\"fieldName,-otherFieldName\\")."
          },
          "expand": {
            "type": "string",
            "description": "Expand string for the PocketBase query (e.g., \\"relation1,relation2.subRelation\\")."
          }
        },
        "required": [
          "collection"
        ]
      }
  • create_record : PocketBase コレクションに新しいレコードを作成します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          },
          "data": {
            "type": "object",
            "description": "The data for the new record.",
            "additionalProperties": true
          }
        },
        "required": [
          "collection",
          "data"
        ]
      }
  • update_record : PocketBase コレクション内の既存のレコードを更新します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          },
          "id": {
            "type": "string",
            "description": "The ID of the record to update."
          },
          "data": {
            "type": "object",
            "description": "The data to update.",
            "additionalProperties": true
          }
        },
        "required": [
          "collection",
          "id",
          "data"
        ]
      }
  • get_collection_schema : PocketBase コレクションのスキーマを取得します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          }
        },
        "required": [
          "collection"
        ]
      }
  • upload_file : PocketBase コレクション レコード内の特定のフィールドにファイルをアップロードします。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          },
          "recordId": {
            "type": "string",
            "description": "The ID of the record to upload the file to."
          },
          "fileField": {
            "type": "string",
            "description": "The name of the file field in the PocketBase collection."
          },
          "fileContent": {
            "type": "string",
            "description": "The content of the file to upload."
          },
          "fileName": {
            "type": "string",
            "description": "The name of the file."
          }
        },
        "required": [
          "collection",
          "recordId",
          "fileField",
          "fileContent",
          "fileName"
        ]
      }
  • list_collections : PocketBase インスタンス内のすべてのコレクションを一覧表示します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
  • download_file : PocketBase コレクション レコードに保存されているファイルのダウンロード URL を取得します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          },
          "recordId": {
            "type": "string",
            "description": "The ID of the record to download the file from."
          },
          "fileField": {
            "type": "string",
            "description": "The name of the file field in the PocketBase collection."
          },
          "downloadPath": {
            "type": "string",
            "description": "The path where the downloaded file should be saved (Note: This tool currently returns the URL, download must be handled separately)."
          }
        },
        "required": [
          "collection",
          "recordId",
          "fileField",
          "downloadPath"
        ]
      }

      注: このツールはファイルのURLを返します。実際のダウンロードは、クライアントがこのURLを使用して実行する必要があります。

コレクション管理

  • list_collections : PocketBase インスタンス内のすべてのコレクションを一覧表示します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
  • get_collection_schema : PocketBase コレクションのスキーマを取得します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          }
        },
        "required": [
          "collection"
        ]
      }

ログ管理

注: Logs API は管理者認証を必要とし、PocketBase インスタンスまたは構成によっては利用できない場合があります。これらのツールは、 https://pocketbase.io/docs/api-logs/に記載されているように、PocketBase Logs API と連携します。

  • list_logs : フィルタリング、並べ替え、ページ区切りを使用して、PocketBase からの API リクエスト ログを一覧表示します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "page": {
            "type": "number",
            "description": "Page number (defaults to 1).",
            "minimum": 1
          },
          "perPage": {
            "type": "number",
            "description": "Items per page (defaults to 30, max 500).",
            "minimum": 1,
            "maximum": 500
          },
          "filter": {
            "type": "string",
            "description": "PocketBase filter string (e.g., \"method='GET'\")."
          }
        },
        "required": []
      }
  • get_log : ID で単一の API リクエスト ログを取得します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The ID of the log to fetch."
          }
        },
        "required": [
          "id"
        ]
      }
  • get_logs_stats : オプションのフィルタリングを使用して API リクエスト ログの統計を取得します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "filter": {
            "type": "string",
            "description": "PocketBase filter string (e.g., \"method='GET'\")."
          }
        },
        "required": []
      }

Cronジョブ管理

注: CronジョブAPIは管理者認証が必要であり、PocketBaseインスタンスまたは設定によっては利用できない場合があります。これらのツールはPocketBase CronジョブAPIと連携します。

  • list_cron_jobs : 登録されているすべてのアプリ レベルの cron ジョブのリストを返します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "fields": {
            "type": "string",
            "description": "Comma separated string of the fields to return in the JSON response (by default returns all fields). Ex.:?fields=*,expand.relField.name"
          }
        }
      }
  • run_cron_job : ID によって単一の cron ジョブをトリガーします。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "jobId": {
            "type": "string",
            "description": "The identifier of the cron job to run."
          }
        },
        "required": [
          "jobId"
        ]
      }

移行管理

  • set_migrations_directory : 移行ファイルが作成され、読み取られるディレクトリを設定します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "customPath": { 
            "type": "string", 
            "description": "Custom path for migrations. If not provided, defaults to 'pb_migrations' in the current working directory." 
          }
        }
      }
  • create_migration : タイムスタンプ付きの名前を付けて、新しい空の PocketBase 移行ファイルを作成します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "description": { 
            "type": "string", 
            "description": "A brief description for the migration filename (e.g., 'add_user_email_index')." 
          }
        },
        "required": ["description"]
      }
  • create_collection_migration : 新しい PocketBase コレクションを作成するための移行ファイルを作成します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "description": { 
            "type": "string", 
            "description": "Optional description override for the filename." 
          },
          "collectionDefinition": {
            "type": "object",
            "description": "The full schema definition for the new collection (including name, id, fields, rules, etc.).",
            "additionalProperties": true
          }
        },
        "required": ["collectionDefinition"]
      }
  • add_field_migration : 既存のコレクションにフィールドを追加するための移行ファイルを作成します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "collectionNameOrId": { 
            "type": "string", 
            "description": "The name or ID of the collection to update." 
          },
          "fieldDefinition": {
            "type": "object",
            "description": "The schema definition for the new field.",
            "additionalProperties": true
          },
          "description": { 
            "type": "string", 
            "description": "Optional description override for the filename." 
          }
        },
        "required": ["collectionNameOrId", "fieldDefinition"]
      }
  • list_migrations : PocketBase の移行ディレクトリにあるすべての移行ファイルを一覧表示します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
  • apply_migration : 特定の移行ファイルを適用します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "migrationFile": { 
            "type": "string", 
            "description": "Name of the migration file to apply." 
          }
        },
        "required": ["migrationFile"]
      }
  • revert_migration : 特定の移行ファイルを元に戻します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "migrationFile": { 
            "type": "string", 
            "description": "Name of the migration file to revert." 
          }
        },
        "required": ["migrationFile"]
      }
  • apply_all_migrations : 保留中のすべての移行を適用します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "appliedMigrations": { 
            "type": "array", 
            "items": { "type": "string" },
            "description": "Array of already applied migration filenames." 
          }
        }
      }
  • revert_to_migration : 特定のターゲットまでの移行を元に戻します。

    • 入力スキーマ:

      {
        "type": "object",
        "properties": {
          "targetMigration": { 
            "type": "string", 
            "description": "Name of the migration to revert to (exclusive). Use empty string to revert all." 
          },
          "appliedMigrations": { 
            "type": "array", 
            "items": { "type": "string" },
            "description": "Array of already applied migration filenames." 
          }
        },
        "required": ["targetMigration"]
      }

移民システム

PocketBase MCPサーバーには、データベーススキーマの変更を管理するための包括的な移行システムが搭載されています。このシステムにより、以下のことが可能になります。

  1. タイムスタンプ付きの名前で移行ファイルを作成する

  2. 一般的な操作(コレクションの作成、フィールドの追加)の移行を生成する

  3. 移行を個別または一括で適用および元に戻す

  4. 適用された移行を追跡する

移行ファイル形式

移行ファイルは、タイムスタンプのプレフィックスと説明的な名前を持つ JavaScript ファイルです。

// 1744005374_update_transactions_add_debt_link.js
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
  // Up migration code here
  return app.save();
}, (app) => {
  // Down migration code here
  return app.save();
});

各移行には、変更を適用するための「アップ」機能と、変更を元に戻すための「ダウン」機能があります。

使用例

カスタム移行ディレクトリの設定:

await setMigrationsDirectory("./my_migrations");

基本的な移行の作成:

await createNewMigration("add_user_email_index");

コレクションの移行を作成する:

await createCollectionMigration({
  id: "users",
  name: "users",
  fields: [
    { name: "email", type: "email", required: true }
  ]
});

コレクションにフィールドを追加する:

await createAddFieldMigration("users", {
  name: "address",
  type: "text"
});

移行の適用:

// Apply a specific migration
await applyMigration("1744005374_update_transactions_add_debt_link.js", pocketbaseInstance);

// Apply all pending migrations
await applyAllMigrations(pocketbaseInstance);

移行を元に戻す:

// Revert a specific migration
await revertMigration("1744005374_update_transactions_add_debt_link.js", pocketbaseInstance);

// Revert to a specific point (exclusive)
await revertToMigration("1743958155_update_transactions_add_relation_to_itself.js", pocketbaseInstance);

// Revert all migrations
await revertToMigration("", pocketbaseInstance);

クライン設置

このサーバーを Cline で使用するには、MCP 設定ファイル ( cline_mcp_settings.json ) に追加する必要があります。

  1. Cline MCP 設定ファイルを見つけます。

    • 通常、Linux/macOS では~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.jsonにあります。

    • または、macOS で Claude デスクトップ アプリを使用している場合は~/Library/Application Support/Claude/claude_desktop_config.json

  2. ファイルを編集し、 を、システム上のこのプロジェクトディレクトリへの実際の絶対パスに置き換えてください。また、 /path/to/pocketbase-mcp<YOUR_POCKETBASE_ADMIN_TOKEN>``<YOUR_POCKETBASE_API_URL> 、実際の PocketBase URL と管理者トークンに置き換えてください。

    {
      "mcpServers": {
        // ... other servers might be listed here ...
    
        "pocketbase-mcp": {
          "command": "node",
          "args": ["/path/to/pocketbase-mcp/build/index.js"],
          "env": {
            "POCKETBASE_API_URL": "<YOUR_POCKETBASE_API_URL>", // e.g., "http://127.0.0.1:8090"
            "POCKETBASE_ADMIN_TOKEN": "<YOUR_POCKETBASE_ADMIN_TOKEN>"
          },
          "disabled": false, // Ensure it's enabled
          "autoApprove": [
            "fetch_record",
            "list_collections",
            "get_collection_schema",
            "list_logs",
            "get_log",
            "get_logs_stats",
            "list_cron_jobs",
            "run_cron_job"
          ] // Suggested auto-approve settings
        }
    
        // ... other servers might be listed here ...
      }
    }
  3. 設定ファイルを保存します。Clineは自動的に変更を検出し、サーバーに接続します。その後、上記のツールを使用できるようになります。

依存関係

  • @modelcontextprotocol/sdk

  • pocketbase

  • typescript

  • ts-node (開発依存)

  • @types/node (開発依存)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mabeldata/pocketbase-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server