Skip to main content
Glama
mrwyndham

PocketBase MCP Server

create_collection

Define a new data structure in PocketBase by specifying collection name, type, fields, and access rules to organize and manage database records.

Instructions

Create a new collection in PocketBase note never use created and updated because these are already created

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesUnique collection name (used as a table name for the records table)
typeNoType of the collectionbase
fieldsYesList with the collection fields
createRuleNoAPI rule for creating records
updateRuleNoAPI rule for updating records
deleteRuleNoAPI rule for deleting records
listRuleNoAPI rule for listing and viewing records
viewRuleNoAPI rule for viewing a single record
viewQueryNoSQL query for view collections
passwordAuthNoPassword authentication options

Implementation Reference

  • The handler function that implements the core logic for the 'create_collection' tool: authenticates as admin, appends default 'created' and 'updated' autodate fields, creates the collection using PocketBase API, and returns the result.
    private async createCollection(args: any) {
      try {
        // Authenticate with PocketBase
        await this.pb.collection("_superusers").authWithPassword(process.env.POCKETBASE_ADMIN_EMAIL ?? '', process.env.POCKETBASE_ADMIN_PASSWORD ?? '');
    
        const defaultFields = [
          {
            hidden: false,
            id: "autodate_created",
            name: "created",
            onCreate: true,
            onUpdate: false,
            presentable: false,
            system: false,
            type: "autodate"
          },
          {
            hidden: false,
            id: "autodate_updated",
            name: "updated",
            onCreate: true,
            onUpdate: true,
            presentable: false,
            system: false,
            type: "autodate"
          }
        ];
    
        const collectionData = {
          ...args,
          fields: [...(args.fields || []), ...defaultFields]
        };
    
        const result = await this.pb.collections.create(collectionData as any);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error: unknown) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to create collection: ${pocketbaseErrorMessage(error)}`
        );
      }
  • Input schema/JSON Schema definition for the 'create_collection' tool parameters, including collection name, type, fields, rules, and auth options.
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Unique collection name (used as a table name for the records table)',
        },
        type: {
          type: 'string',
          description: 'Type of the collection',
          enum: ['base', 'view', 'auth'],
          default: 'base',
        },
        fields: {
          type: 'array',
          description: 'List with the collection fields',
          items: {
            type: 'object',
            properties: {
              name: { type: 'string', description: 'Field name' },
              type: { type: 'string', description: 'Field type', enum: ['bool', 'date', 'number', 'text', 'email', 'url', 'editor', 'autodate', 'select', 'file', 'relation', 'json'] },
              required: { type: 'boolean', description: 'Is field required?' },
              values: {
                type: 'array',
                items: { type: 'string' },
                description: 'Allowed values for select type fields',
              },
              collectionId: { type: 'string', description: 'Collection ID for relation type fields' }
            },
          },
        },
        createRule: {
          type: 'string',
          description: 'API rule for creating records',
        },
        updateRule: {
          type: 'string',
          description: 'API rule for updating records',
        },
        deleteRule: {
          type: 'string',
          description: 'API rule for deleting records',
        },
        listRule: {
          type: 'string',
          description: 'API rule for listing and viewing records',
        },
        viewRule: {
          type: 'string',
          description: 'API rule for viewing a single record',
        },
        viewQuery: {
          type: 'string',
          description: 'SQL query for view collections',
        },
        passwordAuth: {
          type: 'object',
          description: 'Password authentication options',
          properties: {
            enabled: { type: 'boolean', description: 'Is password authentication enabled?' },
            identityFields: {
              type: 'array',
              items: { type: 'string' },
              description: 'Fields used for identity in password authentication',
            },
          },
        },
      },
      required: ['name', 'fields'],
  • src/index.ts:51-123 (registration)
    Tool registration in the ListTools handler: defines name, description, and inputSchema for 'create_collection'.
    {
      name: 'create_collection',
      description: 'Create a new collection in PocketBase note never use created and updated because these are already created',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Unique collection name (used as a table name for the records table)',
          },
          type: {
            type: 'string',
            description: 'Type of the collection',
            enum: ['base', 'view', 'auth'],
            default: 'base',
          },
          fields: {
            type: 'array',
            description: 'List with the collection fields',
            items: {
              type: 'object',
              properties: {
                name: { type: 'string', description: 'Field name' },
                type: { type: 'string', description: 'Field type', enum: ['bool', 'date', 'number', 'text', 'email', 'url', 'editor', 'autodate', 'select', 'file', 'relation', 'json'] },
                required: { type: 'boolean', description: 'Is field required?' },
                values: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Allowed values for select type fields',
                },
                collectionId: { type: 'string', description: 'Collection ID for relation type fields' }
              },
            },
          },
          createRule: {
            type: 'string',
            description: 'API rule for creating records',
          },
          updateRule: {
            type: 'string',
            description: 'API rule for updating records',
          },
          deleteRule: {
            type: 'string',
            description: 'API rule for deleting records',
          },
          listRule: {
            type: 'string',
            description: 'API rule for listing and viewing records',
          },
          viewRule: {
            type: 'string',
            description: 'API rule for viewing a single record',
          },
          viewQuery: {
            type: 'string',
            description: 'SQL query for view collections',
          },
          passwordAuth: {
            type: 'object',
            description: 'Password authentication options',
            properties: {
              enabled: { type: 'boolean', description: 'Is password authentication enabled?' },
              identityFields: {
                type: 'array',
                items: { type: 'string' },
                description: 'Fields used for identity in password authentication',
              },
            },
          },
        },
        required: ['name', 'fields'],
      },
  • src/index.ts:671-672 (registration)
    Dispatch case in the central CallToolRequestHandler that routes 'create_collection' calls to the handler function.
    case 'create_collection':
      return await this.createCollection(request.params.arguments);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Create a new collection' implies a write/mutation operation, the description doesn't disclose any behavioral traits: no information about permissions required, whether this is idempotent, what happens on conflicts, rate limits, or what the response looks like. The confusing note about 'created and updated' adds noise rather than useful behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is technically concise but poorly structured. The first part 'Create a new collection in PocketBase' is clear, but the second part 'note never use created and updated because these are already created' is confusing, appears to be a developer note that doesn't help the AI agent, and doesn't earn its place in the description. The two parts don't form a coherent whole.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex mutation tool with 10 parameters (including nested objects), no annotations, and no output schema, the description is inadequate. It doesn't explain what a 'collection' represents in PocketBase context, doesn't describe the outcome or response format, and the confusing note about 'created and updated' creates more questions than answers. The agent would struggle to use this tool effectively based solely on this description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents all 10 parameters thoroughly with descriptions, enums, and required fields. The description adds no parameter semantics beyond what's in the schema - it doesn't explain relationships between parameters, provide examples, or clarify the confusing 'never use created and updated' note in relation to the schema parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new collection') and the target system ('in PocketBase'), which provides a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'update_collection' or 'delete_collection' beyond the basic action, and the second part about 'never use created and updated' is confusing rather than clarifying.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'update_collection' or 'get_collection'. The confusing note about 'never use created and updated' appears to be a usage warning but is unclear and doesn't help the agent understand appropriate contexts or prerequisites for this creation operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mrwyndham/pocketbase-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server