此包由 MCPFlow 打包并发布到npm仓库。
pocketbase-mcp-server
直接使用npx运行:
npx @mcpflow.io/mcp-advanced-pocketbase-mcp-server
或者先安装后使用:
# 安装
npm install @mcpflow.io/mcp-advanced-pocketbase-mcp-server
# 使用
npx @mcpflow.io/mcp-advanced-pocketbase-mcp-server
Create a new collection in PocketBase with a custom schema
参数:
-
name
: The name of the collection to create -
schema
: An array of schema fields for the collection
Create a new record in a specified collection
参数:
-
data
: The data for the new record -
collection
: The name of the collection to create the record in
List records from a collection with optional filters and pagination
参数:
-
page
: The page number for the records -
sort
: The sort field and direction for the records -
filter
: A filter query to apply to the records -
perPage
: The number of items per page -
collection
: The name of the collection to list records from
Update an existing record in a collection
参数:
-
id
: The ID of the record to update -
data
: The updated data for the record -
collection
: The name of the collection to update the record in
Delete a record from a collection
参数:
-
id
: The ID of the record to delete -
collection
: The name of the collection to delete the record from
List all available authentication methods for a collection
参数:
-
collection
: The name of the collection to list authentication methods for (default: 'users')
Authenticate a user with email and password
参数:
-
email
: The email of the user -
isAdmin
: Whether to authenticate as an admin (uses '_superusers' collection) -
password
: The password of the user -
collection
: The name of the collection to authenticate the user in (default: 'users')
Authenticate a user with OAuth2
参数:
-
code
: The authorization code returned from the OAuth2 provider -
provider
: The OAuth2 provider name (e.g., 'google', 'facebook', 'github') -
collection
: The name of the collection to authenticate the user in (default: 'users') -
redirectUrl
: The redirect URL used in the OAuth2 flow -
codeVerifier
: PKCE code verifier
Authenticate a user with one-time password
参数:
-
email
: The email of the user -
collection
: The name of the collection to authenticate the user in (default: 'users')
Refresh authentication token
参数:
-
collection
: The name of the collection to refresh the token for (default: 'users')
Request email verification
参数:
-
email
: The email of the user -
collection
: The name of the collection to request verification for (default: 'users')
Confirm email verification with token
参数:
-
token
: The verification token -
collection
: The name of the collection to confirm verification for (default: 'users')
Request password reset
参数:
-
email
: The email of the user -
collection
: The name of the collection to request password reset for (default: 'users')
Confirm password reset with token
参数:
-
token
: The reset token -
password
: The new password -
collection
: The name of the collection to confirm password reset for (default: 'users') -
passwordConfirm
: The confirmation of the new password
Request email change
参数:
-
newEmail
: The new email address -
collection
: The name of the collection to request email change for (default: 'users')
Confirm email change with token
参数:
-
token
: The email change token -
password
: The current password for confirmation -
collection
: The name of the collection to confirm email change for (default: 'users')
Impersonate another user (admin only)
参数:
-
userId
: The ID of the user to impersonate -
collection
: The name of the collection to impersonate the user in (default: 'users')
Create a new user account
参数:
-
name
: The name of the user -
email
: The email of the user -
password
: The password of the user -
collection
: The name of the collection to create the user in (default: 'users') -
passwordConfirm
: The confirmation of the password
Get schema details for a collection
参数:
-
collection
: The name of the collection to get the schema for
Create a backup of the PocketBase database
参数:
-
format
: The export format (default: 'json')
Import data into a collection
参数:
-
data
: An array of records to import -
mode
: The import mode (default: 'create') -
collection
: The name of the collection to import data into
Migrate collection schema with data preservation
参数:
-
newSchema
: The new collection schema -
collection
: The name of the collection to migrate -
dataTransforms
: Field transformation mappings
Advanced query with filtering, sorting, and aggregation
参数:
-
sort
: The sort expression -
expand
: The relations to expand -
filter
: The filter expression -
aggregate
: The aggregation settings -
collection
: The name of the collection to query
Manage collection indexes
参数:
-
index
: The index configuration for create action -
action
: The action to perform (create, delete, list) -
collection
: The name of the collection to manage indexes for
- 开发者: DynamicEndpoints
- 版本: 1.0.0
- 许可证: MIT License
- 原始仓库: DynamicEndpoints/pocketbase-mcp-server
A comprehensive MCP server that provides sophisticated tools for interacting with PocketBase databases. This server enables advanced database operations, schema management, and data manipulation through the Model Context Protocol (MCP).
- Create and manage collections with custom schemas
- Migrate collection schemas with data preservation
- Advanced index management (create, delete, list)
- Schema validation and type safety
- Retrieve collection schemas and metadata
- CRUD operations for records
- Advanced querying with filtering, sorting, and aggregation
- Batch import/export capabilities
- Relationship expansion support
- Pagination and cursor-based navigation
- User authentication and token management
- User account creation and management
- Password management
- Role-based access control
- Session handling
- Database backup and restore
- Multiple export formats (JSON/CSV)
- Data migration tools
- Index optimization
- Batch operations
-
create_collection
: Create a new collection with custom schema -
get_collection_schema
: Get schema details for a collection -
migrate_collection
: Migrate collection schema with data preservation -
manage_indexes
: Create, delete, or list collection indexes
-
create_record
: Create a new record in a collection -
list_records
: List records with optional filters and pagination -
update_record
: Update an existing record -
delete_record
: Delete a record -
query_collection
: Advanced query with filtering, sorting, and aggregation -
import_data
: Import data into a collection with create/update/upsert modes
-
authenticate_user
: Authenticate a user and get auth token -
create_user
: Create a new user account -
list_auth_methods
: List all available authentication methods -
authenticate_with_oauth2
: Authenticate a user with OAuth2 -
authenticate_with_otp
: Authenticate a user with one-time password -
auth_refresh
: Refresh authentication token -
request_verification
: Request email verification -
confirm_verification
: Confirm email verification with token -
request_password_reset
: Request password reset -
confirm_password_reset
: Confirm password reset with token -
request_email_change
: Request email change -
confirm_email_change
: Confirm email change with token -
impersonate_user
: Impersonate another user (admin only)
-
backup_database
: Create a backup of the PocketBase database with format options -
import_data
: Import data with various modes (create/update/upsert)
The server requires the following environment variables:
-
POCKETBASE_URL
: URL of your PocketBase instance (e.g., "http://127.0.0.1:8090")
Optional environment variables:
-
POCKETBASE_ADMIN_EMAIL
: Admin email for certain operations -
POCKETBASE_ADMIN_PASSWORD
: Admin password -
POCKETBASE_DATA_DIR
: Custom data directory path
// 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
}
]
});
// Manage indexes
await mcp.use_tool("pocketbase", "manage_indexes", {
collection: "posts",
action: "create",
index: {
name: "title_idx",
fields: ["title"],
unique: true
}
});
// Query with filtering, sorting, and aggregation
await mcp.use_tool("pocketbase", "query_collection", {
collection: "posts",
filter: "created >= '2024-01-01'",
sort: "-created",
aggregate: {
totalLikes: "sum(likes)",
avgRating: "avg(rating)"
},
expand: "author,categories"
});
// 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"
});
// Backup database
await mcp.use_tool("pocketbase", "backup_database", {
format: "json" // or "csv"
});
// 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)"
}
});
// List available authentication methods
await mcp.use_tool("pocketbase", "list_auth_methods", {
collection: "users"
});
// Authenticate with password
await mcp.use_tool("pocketbase", "authenticate_user", {
email: "user@example.com",
password: "securepassword",
collection: "users"
});
// Authenticate with OAuth2
await mcp.use_tool("pocketbase", "authenticate_with_oauth2", {
provider: "google",
code: "auth_code_from_provider",
codeVerifier: "code_verifier_from_pkce",
redirectUrl: "https://your-app.com/auth/callback",
collection: "users"
});
// Request password reset
await mcp.use_tool("pocketbase", "request_password_reset", {
email: "user@example.com",
collection: "users"
});
// Confirm password reset
await mcp.use_tool("pocketbase", "confirm_password_reset", {
token: "verification_token",
password: "new_password",
passwordConfirm: "new_password",
collection: "users"
});
// Refresh authentication token
await mcp.use_tool("pocketbase", "auth_refresh", {
collection: "users"
});
All tools include comprehensive error handling with detailed error messages. Errors are properly typed and include:
- Invalid request errors
- Authentication errors
- Database operation errors
- Schema validation errors
- Network errors
The server includes TypeScript definitions for all operations, ensuring type safety when using the tools. Each tool's input schema is strictly typed and validated.
- Always use proper error handling with try/catch blocks
- Validate data before performing operations
- Use appropriate indexes for better query performance
- Regularly backup your database
- Use migrations for schema changes
- Follow security best practices for user management
- Monitor and optimize database performance
- Clone the repository
- Install dependencies:
npm install
- Copy
.env.example
to.env
and configure - Build:
npm run build
- Start your PocketBase instance
- The MCP server will automatically connect to your PocketBase instance
To install PocketBase Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install pocketbase-server --client claude
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request