list_collections
Retrieve all collections from PocketBase databases with optional filtering and sorting to manage database schema and organize data structures.
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 lists PocketBase collections using filter or sort options if provided, returning JSON-formatted list.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 (registration)Registration of the 'list_collections' tool in the ListTools response, including description and input schema.{ 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)Dispatcher in CallToolRequest handler that routes 'list_collections' calls to the listCollections method.case 'list_collections': return await this.listCollections(request.params.arguments);