Skip to main content
Glama
DynamicEndpoints

Advanced PocketBase MCP Server

list_collections

Retrieve all available collections from a PocketBase database to manage data structure and access records.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Inline handler function for the 'list_collections' MCP tool. Fetches all PocketBase collections using pb.collections.getFullList() and returns them as JSON text content.
    this.server.tool(
      "list_collections",
      "List all collections in the PocketBase database",
      {},
      async () => {
        if (!this.pb) {
          throw new Error('PocketBase not initialized. Please configure POCKETBASE_URL.');
        }
    
        const collections = await this.pb.collections.getFullList();
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(collections, null, 2)
          }]
        };
      }
    );
  • Inline handler function for the 'list_collections' MCP tool in agent-simple. Ensures initialization, fetches PocketBase collections, and returns JSON.
    this.server.tool(
      'list_collections',
      {
        description: 'List all collections in the PocketBase database'
      },
      async () => {
        await this.ensureInitialized();
        if (!this.pb) {
          throw new Error('PocketBase not initialized');
        }
    
        try {
          const collections = await this.pb.collections.getFullList();
          return {
            content: [{
              type: 'text',
              text: JSON.stringify(collections, null, 2)
            }]
          };
        } catch (error: any) {
          throw new Error(`Failed to list collections: ${error.message}`);
        }
      }
    );
  • Private handler method listCollections() called by the 'list_collections' tool switch case. Fetches and returns all PocketBase collections as JSON text.
    private async listCollections() {
      if (!this.pb) {
        throw new Error('PocketBase not configured');
      }
    
      try {
        const collections = await this.pb.collections.getFullList();
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(collections, null, 2)
            }
          ]
        };
      } catch (error: any) {
        throw new Error(`Failed to list collections: ${error.message}`);
      }
    }
  • Input schema definition for the 'list_collections' tool (empty object, no parameters required).
      name: "list_collections",
      description: "List all PocketBase collections",
      inputSchema: {
        type: "object",
        properties: {},
        required: []
      }
    },
  • Tool dispatch registration in switch statement for CallToolRequestSchema handler, delegating to listCollections() method.
    case "list_collections":
      return await this.listCollections();

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/DynamicEndpoints/advanced-pocketbase-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server