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'], }, },

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