PocketBase MCP Server

平台与服务

by mabeldata

轻松管理 PocketBase collections,支持记录的查询、新增、更新与删除,以及文件上传下载,简化数据库操作与应用开发。

什么是 PocketBase MCP Server

轻松管理 PocketBase collections,支持记录的查询、新增、更新与删除,以及文件上传下载,简化数据库操作与应用开发。

核心功能 (22 个工具)

fetch_record

Fetch a single record from a PocketBase collection by ID.

list_records

List records from a PocketBase collection. Supports filtering, sorting, pagination, and expansion.

create_record

Create a new record in a PocketBase collection.

update_record

Update an existing record in a PocketBase collection by ID.

get_collection_schema

Get the schema (fields, rules, etc.) of a PocketBase collection.

list_collections

List all collections in the PocketBase instance.

upload_file

Upload a file (provided as content string) to a PocketBase collection record field.

download_file

Get the URL to download a file from a PocketBase collection record field.

set_migrations_directory

Set the directory where migration files will be created and read from.

create_migration

Create a new, empty PocketBase migration file with a timestamped name.

create_collection_migration

Create a migration file specifically for creating a new PocketBase collection.

add_field_migration

Create a migration file for adding a field to an existing collection.

list_migrations

List all migration files found in the PocketBase migrations directory.

apply_migration

Apply a specific migration file.

revert_migration

Revert a specific migration file.

apply_all_migrations

Apply all pending migrations.

revert_to_migration

Revert migrations up to a specific target.

list_logs

List API request logs from PocketBase with filtering, sorting, and pagination.

get_log

Get a single API request log by ID.

get_logs_stats

Get API request logs statistics with optional filtering.

list_cron_jobs

Returns list with all registered app level cron jobs.

run_cron_job

Triggers a single cron job by its id.

README

PocketBase MCP Server

smithery badge Maintained_By Mabel Data

This is an MCP server that interacts with a PocketBase instance. It allows you to fetch, list, create, update, and manage records and files in your PocketBase collections.

Installation

Installing via Smithery

To install PocketBase MCP Server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @mabeldata/pocketbase-mcp --client claude
  1. Clone the repository (if you haven't already):
    bash
    git clone <repository_url>
    cd pocketbase-mcp
    
  2. Install dependencies:
    bash
    npm install
    
  3. Build the server:
    bash
    npm run build
    
    This compiles the TypeScript code to JavaScript in the build/ directory and makes the entry point executable.

Configuration

This server requires the following environment variables to be set:

  • POCKETBASE_API_URL: The URL of your PocketBase instance (e.g., http://127.0.0.1:8090). Defaults to http://127.0.0.1:8090 if not set.
  • POCKETBASE_ADMIN_TOKEN: An admin authentication token for your PocketBase instance. This is required. You can generate this from your PocketBase admin UI, see API KEYS.

These variables need to be configured when adding the server to Cline (see Cline Installation section).

Available Tools

The server provides the following tools, organized by category:

Record Management

  • fetch_record: Fetch a single record from a PocketBase collection by ID.

    • Input Schema:
      json
      {
        "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: List records from a PocketBase collection. Supports pagination, filtering, sorting, and expanding relations.

    • Input Schema:
      json
      {
        "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: Create a new record in a PocketBase collection.

    • Input Schema:
      json
      {
        "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: Update an existing record in a PocketBase collection.

    • Input Schema:
      json
      {
        "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: Get the schema of a PocketBase collection.

    • Input Schema:
      json
      {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string",
            "description": "The name of the PocketBase collection."
          }
        },
        "required": [
          "collection"
        ]
      }
      
  • upload_file: Upload a file to a specific field in a PocketBase collection record.

    • Input Schema:
      json
      {
        "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: List all collections in the PocketBase instance.

    • Input Schema:
      json
      {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
      
  • download_file: Get the download URL for a file stored in a PocketBase collection record.

    • Input Schema:
      json
      {
        "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"
        ]
      }
      
      Note: This tool returns the file URL. The actual download needs to be performed by the client using this URL.

Collection Management

  • list_collections: List all collections in the PocketBase instance.

    • Input Schema:
      json
      {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
      
  • get_collection_schema: Get the schema of a PocketBase collection.

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

Log Management

Note: The Logs API requires admin authentication and may not be available in all PocketBase instances or configurations. These tools interact with the PocketBase Logs API as documented at https://pocketbase.io/docs/api-logs/.

  • list_logs: List API request logs from PocketBase with filtering, sorting, and pagination.

    • Input Schema:
      json
      {
        "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: Get a single API request log by ID.

    • Input Schema:
      json
      {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The ID of the log to fetch."
          }
        },
        "required": [
          "id"
        ]
      }
      
  • get_logs_stats: Get API request logs statistics with optional filtering.

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

Cron Job Management

Note: The Cron Jobs API requires admin authentication and may not be available in all PocketBase instances or configurations. These tools interact with the PocketBase Cron Jobs API.

  • list_cron_jobs: Returns list with all registered app level cron jobs.

    • Input Schema:
      json
      {
        "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: Triggers a single cron job by its id.

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

Migration Management

  • set_migrations_directory: Set the directory where migration files will be created and read from.

    • Input Schema:
      json
      {
        "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: Create a new, empty PocketBase migration file with a timestamped name.

    • Input Schema:
      json
      {
        "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: Create a migration file specifically for creating a new PocketBase collection.

    • Input Schema:
      json
      {
        "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: Create a migration file for adding a field to an existing collection.

    • Input Schema:
      json
      {
        "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: List all migration files found in the PocketBase migrations directory.

    • Input Schema:
      json
      {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      }
      
  • apply_migration: Apply a specific migration file.

    • Input Schema:
      json
      {
        "type": "object",
        "properties": {
          "migrationFile": { 
            "type": "string", 
            "description": "Name of the migration file to apply." 
          }
        },
        "required": ["migrationFile"]
      }
      
  • revert_migration: Revert a specific migration file.

    • Input Schema:
      json
      {
        "type": "object",
        "properties": {
          "migrationFile": { 
            "type": "string", 
            "description": "Name of the migration file to revert." 
          }
        },
        "required": ["migrationFile"]
      }
      
  • apply_all_migrations: Apply all pending migrations.

    • Input Schema:
      json
      {
        "type": "object",
        "properties": {
          "appliedMigrations": { 
            "type": "array", 
            "items": { "type": "string" },
            "description": "Array of already applied migration filenames." 
          }
        }
      }
      
  • revert_to_migration: Revert migrations up to a specific target.

    • Input Schema:
      json
      {
        "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"]
      }
      

Migration System

The PocketBase MCP Server includes a comprehensive migration system for managing database schema changes. This system allows you to:

  1. Create migration files with timestamped names
  2. Generate migrations for common operations (creating collections, adding fields)
  3. Apply and revert migrations individually or in batches
  4. Track which migrations have been applied

Migration File Format

Migration files are JavaScript files with a timestamp prefix and descriptive name:

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();
});

Each migration has an "up" function for applying changes and a "down" function for reverting them.

Usage Examples

Setting a custom migrations directory:

javascript
await setMigrationsDirectory("./my_migrations");

Creating a basic migration:

javascript
await createNewMigration("add_user_email_index");

Creating a collection migration:

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

Adding a field to a collection:

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

Applying migrations:

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

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

Reverting migrations:

javascript
// 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 Installation

To use this server with Cline, you need to add it to your MCP settings file (cline_mcp_settings.json).

  1. Locate your Cline MCP settings file:

    • Typically found at ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json on Linux/macOS.
    • Or ~/Library/Application Support/Claude/claude_desktop_config.json if using the Claude desktop app on macOS.
  2. Edit the file and add the following configuration under the mcpServers key. Replace /path/to/pocketbase-mcp with the actual absolute path to this project directory on your system. Also, replace <YOUR_POCKETBASE_API_URL> and <YOUR_POCKETBASE_ADMIN_TOKEN> with your actual PocketBase URL and admin token.

    json
    {
      "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. Save the settings file. Cline should automatically detect the changes and connect to the server. You can then use the tools listed above.

Dependencies

  • @modelcontextprotocol/sdk
  • pocketbase
  • typescript
  • ts-node (dev dependency)
  • @types/node (dev dependency)

常见问题

PocketBase MCP Server 是什么?

轻松管理 PocketBase collections,支持记录的查询、新增、更新与删除,以及文件上传下载,简化数据库操作与应用开发。

PocketBase MCP Server 提供哪些工具?

提供 22 个工具,包括 fetch_record、list_records、create_record

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描109.6k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描109.6k

接口设计评审

by alirezarezvani

Universal
热门

审查 REST API 设计是否符合行业规范,自动检查命名、HTTP 方法、状态码与文档覆盖,识别破坏性变更并给出设计评分,适合评审接口方案和版本迭代前把关。

做API和架构方案时,它能帮你提前揪出接口设计问题并对齐最佳实践,评审视角系统,团队协作更省心。

平台与服务
未扫描9.0k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
82.9k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.3k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
34.5k

评论