Skip to main content
Glama
mrwyndham

PocketBase MCP Server

update_collection

Modify and manage existing collections in PocketBase by updating names, types, fields, access rules, and authentication settings. Admin-only tool for schema customization and database optimization.

Instructions

Update an existing collection in PocketBase (admin only)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionIdOrNameYesID or name of the collection to update
createRuleNoAPI rule for creating records
deleteRuleNoAPI rule for deleting records
fieldsNoList with the new collection fields. If not empty, the old schema will be replaced with the new one.
listRuleNoAPI rule for listing and viewing records
nameNoNew unique collection name
passwordAuthNoPassword authentication options
typeNoType of the collection
updateRuleNoAPI rule for updating records
viewQueryNoSQL query for view collections
viewRuleNoAPI rule for viewing a single record

Implementation Reference

  • The handler function that authenticates as PocketBase admin and updates the specified collection using the PocketBase SDK.
    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)}` ); } }
  • Defines the input schema for the update_collection tool, including parameters like collectionIdOrName, fields, rules, etc.
    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:126-201 (registration)
    Registers the tool in the ListToolsRequestSchema handler by including it in the tools array with name, description, and schema.
    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'], }, },
  • src/index.ts:673-674 (registration)
    Registers the handler mapping in the CallToolRequestSchema switch statement.
    case 'update_collection': return await this.updateCollection(request.params.arguments);

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