Skip to main content
Glama
PocketBase MCP Server

PocketBase MCP Server

by paullippert

PocketBase MCP Server

A comprehensive Model Context Protocol (MCP) server for PocketBase, providing both user and superuser functionality through a rich set of tools.

Features

πŸ” User Authentication

  • User login/logout with email and password

  • User registration with validation

  • Password reset workflows

  • Token refresh functionality

  • Current user information retrieval

πŸ‘¨β€πŸ’Ό Administrative Functions

  • Superuser authentication

  • User management (create, read, update, delete)

  • User impersonation for testing

  • Application settings management

πŸ“Š Collection & Record Management

  • Full CRUD operations for collections

  • Collection schema management

  • Record creation, reading, updating, and deletion

  • Advanced filtering and pagination

  • Bulk record operations

πŸ“ File Management

  • File upload to records

  • File URL generation with thumbnail support

  • File deletion and management

  • Private file access tokens

πŸ”§ System Operations

  • Health checks

  • System logs retrieval and analysis

  • Backup creation and management

  • Email testing functionality

  • Server information retrieval

Related MCP server: PocketBase MCP Server

Installation

  1. Clone and setup the project:

    cd pb_mcp
    npm install
  2. Configure environment variables: The .env file should contain:

    POCKETBASE_URL=http://10.69.100.111:8090
    SUPER_USER_LOGIN=your-admin@email.com
    SUPER_USER_PASSWORD=your-admin-password
    NODE_ENV=development
    LOG_LEVEL=info
  3. Build the project:

    npm run build

Usage

Development Mode

npm run dev

Production Mode

npm run start

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

Code Quality

# Run linting
npm run lint

# Fix linting issues
npm run lint:fix

# Type checking
npm run typecheck

MCP Tools Overview

Authentication Tools

pb_auth_login

Authenticate a user with email and password.

Parameters:

  • email (string, required): User email address

  • password (string, required): User password

  • options (object, optional): Additional auth options

Example:

{
  "email": "user@example.com",
  "password": "securepassword",
  "options": {
    "expand": "profile",
    "fields": "id,email,username"
  }
}

pb_auth_register

Register a new user account.

Parameters:

  • email (string, required): User email address

  • password (string, required): Password (minimum 8 characters)

  • passwordConfirm (string, required): Password confirmation

  • username (string, optional): Username

  • name (string, optional): Display name

pb_auth_refresh

Refresh the current authentication token.

pb_auth_logout

Logout the current user and clear authentication.

pb_auth_get_user

Get information about the currently authenticated user.

pb_auth_request_password_reset

Request a password reset email.

Parameters:

  • email (string, required): Email address for password reset

pb_auth_confirm_password_reset

Confirm password reset with token.

Parameters:

  • token (string, required): Reset token from email

  • password (string, required): New password

  • passwordConfirm (string, required): Password confirmation

Admin Tools

pb_admin_login

Authenticate as superuser/admin.

pb_admin_list_users

List all users (admin only).

Parameters:

  • page (number, optional): Page number (default: 1)

  • perPage (number, optional): Items per page (default: 30)

  • sort (string, optional): Sort criteria

  • filter (string, optional): Filter criteria

pb_admin_create_user

Create a new user (admin only).

pb_admin_update_user

Update an existing user (admin only).

pb_admin_delete_user

Delete a user (admin only).

pb_admin_impersonate_user

Impersonate a user for testing (admin only).

Parameters:

  • recordId (string, required): User ID to impersonate

  • duration (number, optional): Token duration in seconds

pb_admin_get_settings

Get application settings (admin only).

pb_admin_update_settings

Update application settings (admin only).

Collection Tools

pb_collections_list

List all collections (admin only).

pb_collections_get

Get a specific collection by ID or name (admin only).

pb_collections_create

Create a new collection (admin only).

Parameters:

  • name (string, required): Collection name

  • type (string, required): Collection type ("base", "auth", "view")

  • schema (array, optional): Field definitions

  • listRule (string, optional): List access rule

  • createRule (string, optional): Create access rule

  • etc.

pb_collections_update

Update an existing collection (admin only).

pb_collections_delete

Delete a collection (admin only).

Record Tools

pb_records_list

List records from a collection with filtering and pagination.

Parameters:

  • collection (string, required): Collection name or ID

  • page (number, optional): Page number

  • perPage (number, optional): Items per page

  • sort (string, optional): Sort criteria

  • filter (string, optional): Filter criteria

  • expand (string, optional): Relations to expand

  • fields (string, optional): Fields to return

pb_records_get

Get a specific record by ID.

pb_records_create

Create a new record.

pb_records_update

Update an existing record.

pb_records_delete

Delete a record.

pb_records_bulk_create

Create multiple records at once.

File Tools

pb_files_get_url

Get the URL for a file attached to a record.

Parameters:

  • collection (string, required): Collection name

  • recordId (string, required): Record ID

  • filename (string, required): File name

  • thumb (string, optional): Thumbnail size

pb_files_upload

Upload a file to a record field.

Parameters:

  • collection (string, required): Collection name

  • recordId (string, required): Record ID

  • fieldName (string, required): Field name

  • fileData (string, required): Base64 encoded file data

  • fileName (string, required): Original file name

  • mimeType (string, optional): File MIME type

pb_files_delete

Delete a file from a record field.

pb_files_get_token

Get a file access token for private files.

pb_files_list_record_files

List all files attached to a record.

System Tools

pb_health_check

Check the health status of the PocketBase server.

pb_server_info

Get PocketBase server information and configuration.

pb_logs_list

Get system logs (admin only).

pb_logs_stats

Get log statistics (admin only).

pb_backups_create

Create a new backup (admin only).

pb_backups_list

List all available backups (admin only).

pb_system_test_email

Send a test email (admin only).

Architecture

Project Structure

pb_mcp/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ server.ts              # Main MCP server
β”‚   β”œβ”€β”€ pocketbase-service.ts  # PocketBase client wrapper
β”‚   β”œβ”€β”€ tools/                 # Individual MCP tools
β”‚   β”‚   β”œβ”€β”€ auth.ts           # User authentication tools
β”‚   β”‚   β”œβ”€β”€ admin.ts          # Superuser/admin tools
β”‚   β”‚   β”œβ”€β”€ collections.ts    # Collection management
β”‚   β”‚   β”œβ”€β”€ records.ts        # Record CRUD operations
β”‚   β”‚   β”œβ”€β”€ files.ts          # File management
β”‚   β”‚   └── system.ts         # Health, logs, backups
β”‚   β”œβ”€β”€ types/                # TypeScript definitions
β”‚   β”‚   β”œβ”€β”€ pocketbase.ts     # PocketBase types
β”‚   β”‚   └── mcp.ts            # MCP tool types
β”‚   └── utils/                # Utility functions
β”‚       β”œβ”€β”€ config.ts         # Environment configuration
β”‚       └── logger.ts         # Logging utility
β”œβ”€β”€ tests/                    # Test files
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ .eslintrc.js
└── jest.config.js

Design Principles

  1. Type Safety: Full TypeScript implementation with strict type checking

  2. Error Handling: Comprehensive error handling with proper error types

  3. Authentication: Dual client support for user and admin operations

  4. Validation: Parameter validation using Zod schemas

  5. Logging: Structured logging for debugging and monitoring

  6. Testing: Comprehensive test coverage for all functionality

Development

Adding New Tools

  1. Define the tool schema in the appropriate file under src/tools/

  2. Implement the handler function with proper error handling

  3. Add parameter validation using Zod schemas

  4. Export the tool and handler from the module

  5. Register the tool in src/server.ts

  6. Write tests for the new functionality

Configuration

The server uses environment variables for configuration:

  • POCKETBASE_URL: PocketBase server URL

  • SUPER_USER_LOGIN: Superuser email

  • SUPER_USER_PASSWORD: Superuser password

  • NODE_ENV: Environment (development/production/test)

  • LOG_LEVEL: Logging level (debug/info/warn/error)

Error Handling

The server implements comprehensive error handling:

  • PocketBaseError: Custom error class for PocketBase-specific errors

  • Parameter validation: Zod schema validation with detailed error messages

  • Graceful degradation: Proper error responses for all failure cases

  • Logging: All errors are logged with context information

Testing

The project includes comprehensive test coverage:

  • Unit tests: Individual component testing

  • Integration tests: Full workflow testing

  • Mock tests: External dependency mocking

  • Coverage reports: Code coverage analysis

Run tests with:

npm test                    # Run all tests
npm run test:watch         # Watch mode
npm run test:coverage      # With coverage

Security Considerations

  • Environment variables: Sensitive credentials stored in environment variables

  • Authentication tokens: Proper token management and refresh

  • Parameter validation: All inputs validated before processing

  • Error messages: No sensitive information leaked in error responses

  • Admin operations: Proper authentication checks for admin-only functions

Troubleshooting

Common Issues

  1. Connection errors: Verify PocketBase URL and server availability

  2. Authentication failures: Check superuser credentials in .env

  3. Permission errors: Ensure proper collection access rules

  4. Type errors: Run npm run typecheck to identify type issues

Debug Logging

Set LOG_LEVEL=debug in your .env file for detailed logging.

Health Check

Use the pb_health_check tool to verify server connectivity and status.

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Implement your changes with tests

  4. Run linting and type checking

  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

For issues and questions:

  • Check the troubleshooting section

  • Review the test files for usage examples

  • Create an issue in the repository

Available Tools

38 tools
pb_admin_create_userB

Create a new user (admin only)

Inputs: email (required), password (required), passwordConfirm (required), emailVisibility, +3 more.

pb_admin_delete_userC

Delete a user (admin only)

Inputs: id (required).

pb_admin_get_settingsB

Get application settings (admin only)

Inputs: no named parameters.

pb_admin_impersonate_userC

Impersonate a user (admin only)

Inputs: recordId (required), duration.

pb_admin_list_usersC

List all users (admin only)

Inputs: filter, page, perPage, sort.

pb_admin_loginB

Authenticate as superuser/admin

Inputs: email (required), password (required).

pb_admin_update_settingsB

Update application settings (admin only)

Inputs: settings (required).

pb_admin_update_userB

Update an existing user (admin only)

Inputs: id (required), email, emailVisibility, name, +4 more.

pb_auth_confirm_password_resetC

Confirm a password reset with the reset token

Inputs: password (required), passwordConfirm (required), token (required).

pb_auth_get_userB

Get information about the currently authenticated user

Inputs: no named parameters.

pb_auth_loginC

Authenticate a user with email and password

Inputs: email (required), password (required), options.

pb_auth_logoutA

Logout the current user and clear authentication

Inputs: no named parameters.

pb_auth_refreshC

Refresh the current user authentication token

Inputs: expand, fields.

pb_auth_registerC

Register a new user account

Inputs: email (required), password (required), passwordConfirm (required), name, +1 more.

pb_auth_request_password_resetC

Request a password reset email for a user

Inputs: email (required).

pb_backups_createC

Create a new backup (admin only)

Inputs: name.

pb_backups_listB

List all available backups (admin only)

Inputs: no named parameters.

pb_collections_createB

Create a new collection (admin only)

Inputs: name (required), type (required), createRule, deleteRule, +5 more.

pb_collections_deleteB

Delete a collection (admin only)

Inputs: idOrName (required).

pb_collections_getA

Get a specific collection by ID or name (admin only)

Inputs: idOrName (required).

pb_collections_listB

List all collections (admin only)

Inputs: filter, page, perPage, sort.

pb_collections_updateB

Update an existing collection (admin only)

Inputs: idOrName (required), createRule, deleteRule, listRule, +5 more.

pb_files_deleteC

Delete a file from a record field

Inputs: collection (required), fieldName (required), filename (required), recordId (required).

pb_files_get_tokenB

Get a file access token for private files

Inputs: no named parameters.

pb_files_get_urlC

Get the URL for a file attached to a record

Inputs: collection (required), filename (required), recordId (required), thumb.

pb_files_list_record_filesC

List all files attached to a record

Inputs: collection (required), recordId (required).

pb_files_uploadC

Upload a file to a record field

Inputs: collection (required), fieldName (required), fileData (required), fileName (required), +2 more.

pb_health_checkB

Check the health status of the PocketBase server

Inputs: no named parameters.

pb_logs_listC

Get system logs (admin only)

Inputs: filter, page, perPage, sort.

pb_logs_statsB

Get log statistics (admin only)

Inputs: filter.

pb_records_bulk_createC

Create multiple records in a collection at once

Inputs: collection (required), records (required).

pb_records_createC

Create a new record in a collection

Inputs: collection (required), data (required), expand, fields.

pb_records_deleteC

Delete a record from a collection

Inputs: collection (required), id (required).

pb_records_getC

Get a specific record by ID from a collection

Inputs: collection (required), id (required), expand, fields.

pb_records_listC

List records from a collection with optional filtering and pagination

Inputs: collection (required), expand, fields, filter, +3 more.

pb_records_updateC

Update an existing record in a collection

Inputs: collection (required), data (required), id (required), expand, +1 more.

pb_server_infoB

Get PocketBase server information and configuration

Inputs: no named parameters.

pb_system_test_emailB

Send a test email (admin only)

Inputs: email (required), template (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 38 tools

    Disambiguation5/5

    Every tool has a clearly distinct purpose with no ambiguity. The tools are organized by resource type (admin, auth, backups, collections, files, health, logs, records, server, system) and action (create, delete, get, list, update, etc.), making it easy to distinguish between them. For example, pb_records_create and pb_records_update are clearly different operations on the same resource.

    Naming Consistency5/5

    The naming follows a highly consistent pattern throughout: all tools use a prefix 'pb_' followed by a resource category (e.g., admin, auth, collections), an underscore, and a verb_noun combination (e.g., create_user, get_settings, list_records). This snake_case convention is applied uniformly across all 38 tools, making them predictable and easy to parse.

    Tool Count3/5

    With 38 tools, the count is borderline high for a typical MCP server, which might feel heavy and overwhelming for agents. However, given PocketBase's comprehensive scope (covering admin, authentication, backups, collections, files, logs, records, and system operations), the number is somewhat justified, but it could benefit from consolidation or better scoping to reduce complexity.

    Completeness5/5

    The tool set provides complete CRUD/lifecycle coverage for the PocketBase domain, with no obvious gaps. It includes operations for user management, authentication, backups, collections, files, health checks, logs, records, server info, and system tests, ensuring agents can handle all core workflows without dead ends. For example, records have create, get, list, update, delete, and bulk create tools.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      D
      quality
      Not graded
      maintenance
      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).
      14
      164 npm
      70
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A comprehensive server that enables advanced database operations with PocketBase, providing tools for collection management, record operations, user management, and database administration through the Model Context Protocol.
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Provides sophisticated tools for interacting with PocketBase databases, enabling advanced database operations, schema management, and data manipulation through the Model Context Protocol (MCP).
      24
      156
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      MCP server that allows interaction with PocketBase databases, enabling record operations (fetch, list, create, update), file management, and schema migrations through natural language.
      22
      43
      MIT