Skip to main content
Glama
mrwyndham

PocketBase MCP Server

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
NameRequiredDescriptionDefault
filterNoFilter query for collections
sortNoSort order for collections

Implementation Reference

  • 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)}` ); } }
  • 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);

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