PocketBase MCP server

Interact with a PocketBase instance. Allows you to fetch, list, create, update, and manage records and files in your PocketBase collections.
Back to servers
Provider
Mabel Data
Release date
Apr 08, 2025
Language
TypeScript
Stats
8 stars

PocketBase MCP Server is a tool that allows you to interact with a PocketBase database using the Model Context Protocol. It provides functionality for managing records, collections, files, logs, cron jobs, and database migrations in your PocketBase instance through a standardized interface.

Installation

Via Smithery

The easiest way to install PocketBase MCP Server for Claude Desktop is via Smithery:

npx -y @smithery/cli install @mabeldata/pocketbase-mcp --client claude

Manual Installation

If you prefer to install manually:

git clone <repository_url>
cd pocketbase-mcp
npm install
npm run build

Configuration

The server needs two environment variables:

  • POCKETBASE_API_URL: Your PocketBase instance URL (defaults to http://127.0.0.1:8090)
  • POCKETBASE_ADMIN_TOKEN: An admin authentication token (required)

You can generate an admin token from your PocketBase admin UI under API Keys section.

Setting Up with Claude

To use this server with Claude, add it to your MCP settings file:

  1. Locate your Claude MCP settings file (typically at ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json or ~/Library/Application Support/Claude/claude_desktop_config.json)

  2. Add the following configuration:

{
  "mcpServers": {
    "pocketbase-mcp": {
      "command": "node",
      "args": ["/path/to/pocketbase-mcp/build/index.js"],
      "env": {
        "POCKETBASE_API_URL": "http://127.0.0.1:8090",
        "POCKETBASE_ADMIN_TOKEN": "your-admin-token"
      },
      "disabled": false,
      "autoApprove": [
        "fetch_record",
        "list_collections",
        "get_collection_schema",
        "list_logs",
        "get_log",
        "get_logs_stats",
        "list_cron_jobs",
        "run_cron_job"
      ]
    }
  }
}

Using the PocketBase MCP Server

Record Management

Fetching Records

To fetch a record by ID:

const record = await fetch_record({
  collection: "users",
  id: "RECORD_ID_HERE"
});

Listing Records

To list records with filtering, pagination, and sorting:

const records = await list_records({
  collection: "users",
  page: 1,
  perPage: 20,
  filter: "created >= '2023-01-01 00:00:00'",
  sort: "-created,name",
  expand: "relation_field"
});

Creating Records

To create a new record:

const newRecord = await create_record({
  collection: "users",
  data: {
    name: "John Doe",
    email: "[email protected]",
    age: 30
  }
});

Updating Records

To update an existing record:

const updatedRecord = await update_record({
  collection: "users",
  id: "RECORD_ID_HERE",
  data: {
    name: "Jane Doe",
    age: 31
  }
});

File Management

Uploading Files

To upload a file to a record:

const result = await upload_file({
  collection: "documents",
  recordId: "RECORD_ID_HERE",
  fileField: "attachment",
  fileContent: "BASE64_ENCODED_CONTENT_OR_FILE_DATA",
  fileName: "document.pdf"
});

Downloading Files

To get a file download URL:

const fileUrl = await download_file({
  collection: "documents",
  recordId: "RECORD_ID_HERE",
  fileField: "attachment",
  downloadPath: "/local/path/to/save.pdf"
});

Collection Management

Listing Collections

To get all collections:

const collections = await list_collections({});

Getting Collection Schema

To get the schema of a collection:

const schema = await get_collection_schema({
  collection: "users"
});

Migration Management

The server includes a comprehensive migration system for managing database schema changes.

Setting Migration Directory

await set_migrations_directory({
  customPath: "./my_migrations"
});

Creating Migrations

Basic migration:

await create_migration({
  description: "add_user_email_index"
});

Collection migration:

await create_collection_migration({
  description: "create_users_collection",
  collectionDefinition: {
    id: "users",
    name: "users",
    fields: [
      { name: "email", type: "email", required: true }
    ]
  }
});

Add field migration:

await add_field_migration({
  collectionNameOrId: "users",
  fieldDefinition: {
    name: "address",
    type: "text"
  }
});

Applying Migrations

// Apply specific migration
await apply_migration({ migrationFile: "1744005374_update_transactions_add_debt_link.js" });

// Apply all pending migrations
await apply_all_migrations({});

Reverting Migrations

// Revert specific migration
await revert_migration({ migrationFile: "1744005374_update_transactions_add_debt_link.js" });

// Revert to specific point
await revert_to_migration({ targetMigration: "1743958155_update_transactions.js" });

// Revert all migrations
await revert_to_migration({ targetMigration: "" });

Log Management

// List logs
const logs = await list_logs({
  page: 1,
  perPage: 30,
  filter: "method='GET'"
});

// Get specific log
const log = await get_log({
  id: "LOG_ID_HERE"
});

// Get logs statistics
const stats = await get_logs_stats({
  filter: "method='GET'"
});

Cron Job Management

// List cron jobs
const jobs = await list_cron_jobs({});

// Run a cron job
await run_cron_job({
  jobId: "CRON_JOB_ID_HERE"
});

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later