list_collections
Retrieve all collections from a PocketBase database with customizable sorting options to organize and manage your data structure.
Instructions
List all collections with optional sorting
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sort | No | Sort order for collections (e.g., '-created', 'name') | -created |
Implementation Reference
- src/tools/handlers/collection.ts:56-67 (handler)The handler function that creates and returns the ToolHandler for listing collections. It uses PocketBase's collections.getFullList() with optional sorting.export function createListCollectionsHandler(pb: PocketBase): ToolHandler { return async (args: { sort?: string }) => { try { const result = await pb.collections.getFullList({ sort: args.sort || "-created" }); return createJsonResponse(result); } catch (error: unknown) { throw handlePocketBaseError("list collections", error); } }; }
- Zod-like input schema definition for the list_collections tool, defining an optional 'sort' property.export const listCollectionsSchema = { type: "object", properties: { sort: { type: "string", description: "Sort order for collections (e.g., '-created', 'name')", default: "-created", }, }, required: [], };
- src/server.ts:111-116 (registration)The tool registration object in the MCP server array, linking the name, description, schema, and handler for list_collections.{ name: "list_collections", description: "List all collections with optional sorting", inputSchema: listCollectionsSchema, handler: createListCollectionsHandler(pb), },