
PocketBase MCP Server
MCP server that allows interaction with PocketBase databases, enabling record operations (fetch, list, create, update), file management, and schema migrations through natural language.
README
PocketBase MCP Server
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
- Clone the repository (if you haven't already):
git clone <repository_url> cd pocketbase-mcp
- Install dependencies:
npm install
- Build the server:
This compiles the TypeScript code to JavaScript in thenpm run build
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 tohttp://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:
{ "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" ] }
- Input Schema:
-
list_records: List records from a PocketBase collection. Supports pagination, filtering, sorting, and expanding relations.
- Input Schema:
{ "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" ] }
- Input Schema:
-
create_record: Create a new record in a PocketBase collection.
- Input Schema:
{ "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" ] }
- Input Schema:
-
update_record: Update an existing record in a PocketBase collection.
- Input Schema:
{ "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" ] }
- Input Schema:
-
get_collection_schema: Get the schema of a PocketBase collection.
- Input Schema:
{ "type": "object", "properties": { "collection": { "type": "string", "description": "The name of the PocketBase collection." } }, "required": [ "collection" ] }
- Input Schema:
-
upload_file: Upload a file to a specific field in a PocketBase collection record.
- Input Schema:
{ "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" ] }
- Input Schema:
-
list_collections: List all collections in the PocketBase instance.
- Input Schema:
{ "type": "object", "properties": {}, "additionalProperties": false }
- Input Schema:
-
download_file: Get the download URL for a file stored in a PocketBase collection record.
- Input Schema:
Note: This tool returns the file URL. The actual download needs to be performed by the client using this 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" ] }
- Input Schema:
Collection Management
-
list_collections: List all collections in the PocketBase instance.
- Input Schema:
{ "type": "object", "properties": {}, "additionalProperties": false }
- Input Schema:
-
get_collection_schema: Get the schema of a PocketBase collection.
- Input Schema:
{ "type": "object", "properties": { "collection": { "type": "string", "description": "The name of the PocketBase collection." } }, "required": [ "collection" ] }
- Input Schema:
Migration Management
-
set_migrations_directory: Set the directory where migration files will be created and read from.
- Input Schema:
{ "type": "object", "properties": { "customPath": { "type": "string", "description": "Custom path for migrations. If not provided, defaults to 'pb_migrations' in the current working directory." } } }
- Input Schema:
-
create_migration: Create a new, empty PocketBase migration file with a timestamped name.
- Input Schema:
{ "type": "object", "properties": { "description": { "type": "string", "description": "A brief description for the migration filename (e.g., 'add_user_email_index')." } }, "required": ["description"] }
- Input Schema:
-
create_collection_migration: Create a migration file specifically for creating a new PocketBase collection.
- Input Schema:
{ "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"] }
- Input Schema:
-
add_field_migration: Create a migration file for adding a field to an existing collection.
- Input Schema:
{ "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"] }
- Input Schema:
-
list_migrations: List all migration files found in the PocketBase migrations directory.
- Input Schema:
{ "type": "object", "properties": {}, "additionalProperties": false }
- Input Schema:
-
apply_migration: Apply a specific migration file.
- Input Schema:
{ "type": "object", "properties": { "migrationFile": { "type": "string", "description": "Name of the migration file to apply." } }, "required": ["migrationFile"] }
- Input Schema:
-
revert_migration: Revert a specific migration file.
- Input Schema:
{ "type": "object", "properties": { "migrationFile": { "type": "string", "description": "Name of the migration file to revert." } }, "required": ["migrationFile"] }
- Input Schema:
-
apply_all_migrations: Apply all pending migrations.
- Input Schema:
{ "type": "object", "properties": { "appliedMigrations": { "type": "array", "items": { "type": "string" }, "description": "Array of already applied migration filenames." } } }
- Input Schema:
-
revert_to_migration: Revert migrations up to a specific target.
- Input Schema:
{ "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"] }
- Input Schema:
Migration System
The PocketBase MCP Server includes a comprehensive migration system for managing database schema changes. This system allows you to:
- Create migration files with timestamped names
- Generate migrations for common operations (creating collections, adding fields)
- Apply and revert migrations individually or in batches
- Track which migrations have been applied
Migration File Format
Migration files are JavaScript files with a timestamp prefix and descriptive name:
// 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:
await setMigrationsDirectory("./my_migrations");
Creating a basic migration:
await createNewMigration("add_user_email_index");
Creating a collection migration:
await createCollectionMigration({
id: "users",
name: "users",
fields: [
{ name: "email", type: "email", required: true }
]
});
Adding a field to a collection:
await createAddFieldMigration("users", {
name: "address",
type: "text"
});
Applying migrations:
// Apply a specific migration
await applyMigration("1744005374_update_transactions_add_debt_link.js", pocketbaseInstance);
// Apply all pending migrations
await applyAllMigrations(pocketbaseInstance);
Reverting migrations:
// 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
).
-
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.
- Typically found at
-
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.{ "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": [] // Default auto-approve settings } // ... other servers might be listed here ... } }
-
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)
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.