delete_collection
Remove a specific collection from a PocketBase database by specifying its ID or name. Designed for admin use, this tool simplifies database schema management and cleanup.
Instructions
Delete a collection from PocketBase (admin only)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collectionIdOrName | Yes | ID or name of the collection to delete |
Implementation Reference
- src/index.ts:1017-1039 (handler)The main handler function for the delete_collection tool. Authenticates as PocketBase admin and deletes the specified collection using pb.collections.delete.private async deleteCollection(args: any) { try { // Authenticate with PocketBase as admin (required for collection deletion) await this.pb.collection("_superusers").authWithPassword(process.env.POCKETBASE_ADMIN_EMAIL ?? '', process.env.POCKETBASE_ADMIN_PASSWORD ?? ''); // Delete the collection await this.pb.collections.delete(args.collectionIdOrName); return { content: [ { type: 'text', text: `Successfully deleted collection ${args.collectionIdOrName}`, }, ], }; } catch (error: unknown) { throw new McpError( ErrorCode.InternalError, `Failed to delete collection: ${pocketbaseErrorMessage(error)}` ); } }
- src/index.ts:654-663 (schema)Input schema for delete_collection tool, defining the required 'collectionIdOrName' parameter.inputSchema: { type: 'object', properties: { collectionIdOrName: { type: 'string', description: 'ID or name of the collection to delete', }, }, required: ['collectionIdOrName'], },
- src/index.ts:651-664 (registration)Registration of the delete_collection tool in the ListToolsRequestSchema response, including name, description, and schema.{ name: 'delete_collection', description: 'Delete a collection from PocketBase (admin only)', inputSchema: { type: 'object', properties: { collectionIdOrName: { type: 'string', description: 'ID or name of the collection to delete', }, }, required: ['collectionIdOrName'], }, },
- src/index.ts:693-694 (registration)Dispatch/registration case in the CallToolRequestSchema handler that calls the deleteCollection method.case 'delete_collection': return await this.deleteCollection(request.params.arguments);