Integration of PocketBase with Cursor AI through the Model Context Protocol (MCP). This server allows Cursor AI to directly interact with PocketBase databases, supporting collection management, record operations, and many other functionalities.
- Create and manage collections with custom schemas
- Migrate collection schemas with data preservation capabilities
- Advanced index management (create, delete, list)
- CRUD operations (Create, Read, Update, Delete) for records
- Advanced querying with filtering, sorting, and aggregation
- Bulk import/export capabilities
- Generate PocketBase schemas from TypeScript interfaces
- Generate TypeScript interfaces from PocketBase collections
- Analyze collection data and provide insights
npm install -g pocketbase-cursor-mcp
or
pnpm add -g pocketbase-cursor-mcp
You can configure the PocketBase MCP Server using environment variables or command line arguments:
Create a .env
file in the root directory of your project:
POCKETBASE_URL=http://127.0.0.1:8090
[email protected] # Optional
POCKETBASE_ADMIN_PASSWORD=your-password # Optional
pocketbase-cursor-mcp --url=http://127.0.0.1:8090 [email protected] --admin-password=your-password
Command line arg | Environment variable | Description |
---|---|---|
--url, -u |
POCKETBASE_URL |
PocketBase server URL (required) |
--admin-email, -e |
POCKETBASE_ADMIN_EMAIL |
Admin email (optional) |
--admin-password, -p |
POCKETBASE_ADMIN_PASSWORD |
Admin password (optional) |
--data-dir, -d |
POCKETBASE_DATA_DIR |
Custom data directory path (optional) |
--port |
PORT |
HTTP server port (optional) |
--host |
HOST |
HTTP server host (optional) |
Use pocketbase-cursor-mcp --help
to view all options.
- Open Cursor AI
- Open Settings (or press
Cmd+,
on macOS,Ctrl+,
on Windows/Linux) - Select the "AI" tab
- Scroll down to "Model Context Protocol Servers"
- Add a new configuration with the following information:
Name: pocketbase
Command: npx
Args: pocketbase-cursor-mcp --url=http://127.0.0.1:8090
Or directly provide the path to the executable:
Command: Path to node executable (e.g., /usr/bin/node
)
Args: Path to the executable file along with parameters (e.g., /usr/local/bin/pocketbase-cursor-mcp --url=http://127.0.0.1:8090
)
After configuration, you can use PocketBase MCP in Cursor AI by adding commands like the following to the editing interface:
Create a PocketBase collection from the following TypeScript interface:
interface User {
username: string;
email: string;
isActive: boolean;
age?: number;
profile: UserProfile;
}
interface UserProfile {
bio: string;
avatar?: string;
socialLinks: string[];
}
or
Generate TypeScript interfaces from the collections in my PocketBase database.
or
Analyze the data in the "products" collection and provide insights.
create_collection
: Create a new collectioncreate_record
: Create a new recordlist_records
: List records with optional filtersupdate_record
: Update an existing recorddelete_record
: Delete a recordget_collection_schema
: Get detailed schema for a collection- ... and many more tools
generate_pb_schema
: Generate PocketBase schema from TypeScript interfacesgenerate_typescript_interfaces
: Generate TypeScript interfaces from PocketBase collectionsanalyze_collection_data
: Analyze data in a collection
const schema = await mcp.use_tool("pocketbase", "generate_pb_schema", {
sourceCode: `
interface Product {
name: string;
price: number;
description: string;
isAvailable: boolean;
tags: string[];
}
`,
options: {
includeTimestamps: true
}
});
const collection = await mcp.use_tool("pocketbase", "create_collection", {
name: "products",
schema: schema[0].schema
});
const interfaces = await mcp.use_tool("pocketbase", "generate_typescript_interfaces", {
options: {
includeRelations: true
}
});
// Interfaces can be used in your TypeScript project
const analysis = await mcp.use_tool("pocketbase", "analyze_collection_data", {
collection: "products",
options: {
sampleSize: 500
}
});
// View insights about your data
console.log(analysis.insights);
Contributions are always welcome! Please create an issue or pull request.
MIT