list_collections
Retrieve and organize collections in PocketBase databases using filters and sorting options. Facilitates advanced schema management and data handling for efficient database operations.
Instructions
List all collections in PocketBase
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Filter query for collections | |
| sort | No | Sort order for collections |
Implementation Reference
- src/index.ts:986-1015 (handler)The handler function that authenticates as admin and fetches the list of collections from PocketBase using getList, getFirstListItem, or getFullList based on arguments, then returns the JSON as text content.private async listCollections(args: any) { try { // Authenticate with PocketBase await this.pb.collection("_superusers").authWithPassword(process.env.POCKETBASE_ADMIN_EMAIL ?? '', process.env.POCKETBASE_ADMIN_PASSWORD ?? ''); // Fetch collections based on provided arguments let collections; if (args.filter) { collections = await this.pb.collections.getFirstListItem(args.filter); } else if (args.sort) { collections = await this.pb.collections.getFullList({ sort: args.sort }); } else { collections = await this.pb.collections.getList(1, 100); } return { content: [ { type: 'text', text: JSON.stringify(collections, null, 2), }, ], }; } catch (error: unknown) { throw new McpError( ErrorCode.InternalError, `Failed to list collections: ${pocketbaseErrorMessage(error)}` ); } }
- src/index.ts:634-650 (schema)The input schema definition and tool metadata registration in the listTools response.{ name: 'list_collections', description: 'List all collections in PocketBase', inputSchema: { type: 'object', properties: { filter: { type: 'string', description: 'Filter query for collections', }, sort: { type: 'string', description: 'Sort order for collections', }, }, }, },
- src/index.ts:691-692 (registration)The dispatch case in the CallToolRequestSchema handler that routes to the listCollections method.case 'list_collections': return await this.listCollections(request.params.arguments);