Skip to main content
Glama
mrwyndham

PocketBase MCP Server

update_collection

Modify an existing collection's structure, rules, or authentication settings in PocketBase databases to adapt to changing application requirements.

Instructions

Update an existing collection in PocketBase (admin only)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionIdOrNameYesID or name of the collection to update
nameNoNew unique collection name
typeNoType of the collection
fieldsNoList with the new collection fields. If not empty, the old schema will be replaced with the new one.
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 main handler function that executes the update_collection tool. It authenticates as an admin using environment variables, destructures the arguments, updates the collection using PocketBase SDK, and returns the result as MCP content.
    private async updateCollection(args: any) {
      try {
        // Authenticate with PocketBase as admin
        await this.pb.collection("_superusers").authWithPassword(process.env.POCKETBASE_ADMIN_EMAIL ?? '', process.env.POCKETBASE_ADMIN_PASSWORD ?? '');
    
        const { collectionIdOrName, ...updateData } = args;
        const result = await this.pb.collections.update(collectionIdOrName, updateData as any);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error: unknown) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to update collection: ${pocketbaseErrorMessage(error)}`
        );
      }
    }
  • The input schema defining the parameters for the update_collection tool, including collectionIdOrName (required), optional fields, rules, and auth options.
    inputSchema: {
      type: 'object',
      properties: {
        collectionIdOrName: {
          type: 'string',
          description: 'ID or name of the collection to update',
        },
        name: {
          type: 'string',
          description: 'New unique collection name',
        },
        type: {
          type: 'string',
          description: 'Type of the collection',
          enum: ['base', 'view', 'auth'],
        },
        fields: {
          type: 'array',
          description: 'List with the new collection fields. If not empty, the old schema will be replaced with the new one.',
          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: ['collectionIdOrName'],
    },
  • src/index.ts:673-674 (registration)
    The switch case in the CallToolRequestSchema handler that dispatches calls to the update_collection tool to its handler function.
    case 'update_collection':
      return await this.updateCollection(request.params.arguments);
  • src/index.ts:125-201 (registration)
    The tool specification registered in the ListToolsRequestSchema response, including name, description, and inputSchema.
    {
      name: 'update_collection',
      description: 'Update an existing collection in PocketBase (admin only)',
      inputSchema: {
        type: 'object',
        properties: {
          collectionIdOrName: {
            type: 'string',
            description: 'ID or name of the collection to update',
          },
          name: {
            type: 'string',
            description: 'New unique collection name',
          },
          type: {
            type: 'string',
            description: 'Type of the collection',
            enum: ['base', 'view', 'auth'],
          },
          fields: {
            type: 'array',
            description: 'List with the new collection fields. If not empty, the old schema will be replaced with the new one.',
            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: ['collectionIdOrName'],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'admin only' (permissions) but fails to describe critical traits: whether this is a destructive operation (e.g., replacing fields schema), what happens to existing data, error conditions, or response format. For a complex mutation tool with 11 parameters, this is inadequate.

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

Conciseness5/5

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

The description is extremely concise (one sentence) and front-loaded with essential information ('Update an existing collection'). Every word earns its place, with no redundant or verbose phrasing. It efficiently communicates core purpose and a key constraint ('admin only').

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?

Given the tool's complexity (11 parameters, mutation operation, no output schema, no annotations), the description is insufficient. It lacks information about behavioral consequences (e.g., schema replacement with 'fields'), error handling, return values, and detailed usage context. The 'admin only' hint is helpful but doesn't compensate for other gaps.

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?

Schema description coverage is 100%, so the schema fully documents all 11 parameters. The description adds no parameter-specific information beyond what's in the schema (e.g., it doesn't clarify relationships between parameters like 'fields' replacement behavior). Baseline score of 3 is appropriate since the schema does the heavy lifting.

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 verb ('Update') and resource ('an existing collection in PocketBase'), making the purpose unambiguous. It distinguishes from siblings like 'create_collection' (new vs existing) and 'delete_collection' (update vs remove). However, it doesn't specify what aspects can be updated (name, type, fields, rules, etc.), which prevents a perfect score.

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 minimal guidance: 'admin only' indicates a permission requirement, but it doesn't explain when to use this tool versus alternatives like 'create_collection' or 'update_record'. No explicit when-not-to-use scenarios or prerequisites beyond admin status are mentioned, leaving significant gaps in usage context.

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