The Advanced PocketBase MCP Server provides a comprehensive interface for interacting with PocketBase databases through the Model Context Protocol (MCP). It enables sophisticated database operations, schema management, and data manipulation with strong typing and error handling.
Before using the server, configure the following environment variables:
# Required
POCKETBASE_URL=http://127.0.0.1:8090
# Optional
[email protected]
POCKETBASE_ADMIN_PASSWORD=your_secure_password
POCKETBASE_DATA_DIR=/path/to/data
The easiest way to install the PocketBase MCP Server is through Smithery:
npx -y @smithery/cli install pocketbase-server --client claude
Create and manage collections with custom schemas:
// Create a new collection
await mcp.use_tool("pocketbase", "create_collection", {
name: "posts",
schema: [
{
name: "title",
type: "text",
required: true
},
{
name: "content",
type: "text",
required: true
}
]
});
// Get collection schema
await mcp.use_tool("pocketbase", "get_collection_schema", {
collection: "posts"
});
// Migrate collection schema
await mcp.use_tool("pocketbase", "migrate_collection", {
collection: "posts",
newSchema: [
{
name: "title",
type: "text",
required: true
},
{
name: "content",
type: "text",
required: true
},
{
name: "tags",
type: "json",
required: false
}
],
dataTransforms: {
// Optional field transformations during migration
tags: "JSON.parse(oldTags)"
}
});
Create and manage collection indexes:
// Create an index
await mcp.use_tool("pocketbase", "manage_indexes", {
collection: "posts",
action: "create",
index: {
name: "title_idx",
fields: ["title"],
unique: true
}
});
// List all indexes
await mcp.use_tool("pocketbase", "manage_indexes", {
collection: "posts",
action: "list"
});
// Delete an index
await mcp.use_tool("pocketbase", "manage_indexes", {
collection: "posts",
action: "delete",
name: "title_idx"
});
Perform CRUD operations on records:
// Create a record
await mcp.use_tool("pocketbase", "create_record", {
collection: "posts",
data: {
title: "My First Post",
content: "Hello world!"
}
});
// List records with filtering
await mcp.use_tool("pocketbase", "list_records", {
collection: "posts",
filter: "created >= '2024-01-01'",
sort: "-created",
page: 1,
perPage: 20
});
// Update a record
await mcp.use_tool("pocketbase", "update_record", {
collection: "posts",
id: "record_id_here",
data: {
title: "Updated Title",
content: "Updated content"
}
});
// Delete a record
await mcp.use_tool("pocketbase", "delete_record", {
collection: "posts",
id: "record_id_here"
});
Perform complex queries with filtering, sorting, and aggregation:
// Advanced query
await mcp.use_tool("pocketbase", "query_collection", {
collection: "posts",
filter: "created >= '2024-01-01' && author.name ~ 'John'",
sort: "-created,title",
aggregate: {
totalLikes: "sum(likes)",
avgRating: "avg(rating)"
},
expand: "author,categories"
});
Import data in bulk and create database backups:
// Import data with upsert mode
await mcp.use_tool("pocketbase", "import_data", {
collection: "posts",
data: [
{
title: "First Post",
content: "Hello World"
},
{
title: "Second Post",
content: "More content"
}
],
mode: "upsert" // Alternatives: "create" or "update"
});
// Backup database
await mcp.use_tool("pocketbase", "backup_database", {
format: "json" // or "csv"
});
Handle user authentication and account management:
// Authenticate user
await mcp.use_tool("pocketbase", "authenticate_user", {
email: "[email protected]",
password: "securepassword",
collection: "users"
});
// Create user account
await mcp.use_tool("pocketbase", "create_user", {
email: "[email protected]",
password: "securepassword",
passwordConfirm: "securepassword",
collection: "users"
});
// List authentication methods
await mcp.use_tool("pocketbase", "list_auth_methods", {
collection: "users"
});
// Refresh authentication token
await mcp.use_tool("pocketbase", "auth_refresh", {
collection: "users"
});
Handle password resets and email verification:
// Request password reset
await mcp.use_tool("pocketbase", "request_password_reset", {
email: "[email protected]",
collection: "users"
});
// Confirm password reset
await mcp.use_tool("pocketbase", "confirm_password_reset", {
token: "verification_token",
password: "new_password",
passwordConfirm: "new_password",
collection: "users"
});
// Request email verification
await mcp.use_tool("pocketbase", "request_verification", {
email: "[email protected]",
collection: "users"
});
// Confirm email verification
await mcp.use_tool("pocketbase", "confirm_verification", {
token: "verification_token",
collection: "users"
});
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "pocketbase" '{"command":"npx","args":["-y","@smithery/cli","install","pocketbase-server","--client","claude"]}'
See the official Claude Code MCP documentation for more details.
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.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"pocketbase": {
"command": "npx",
"args": [
"-y",
"@smithery/cli",
"install",
"pocketbase-server",
"--client",
"claude"
]
}
}
}
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.
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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"pocketbase": {
"command": "npx",
"args": [
"-y",
"@smithery/cli",
"install",
"pocketbase-server",
"--client",
"claude"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect