Skip to main content
Glama
DynamicEndpoints

pocketbase-mcp-server

get_collection

Retrieve detailed information about a specific collection in a PocketBase database using the Model Context Protocol (MCP). Simplify database schema understanding and management.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that executes the get_collection tool logic by fetching collection details from PocketBase using pb.collections.getOne(name)
    private async getCollection(name: string) {
      if (!this.pb) {
        throw new Error('PocketBase not configured');
      }
    
      try {
        const collection = await this.pb.collections.getOne(name);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(collection, null, 2)
            }
          ]
        };
      } catch (error: any) {
        throw new Error(`Failed to get collection: ${error.message}`);
      }
    }
  • Tool dispatch/registration in the central switch statement for handling get_collection calls
    case "get_collection": {
      if (!args || typeof args !== "object" || typeof (args as any).name !== "string") {
        throw new Error("'name' is required and must be a string for get_collection");
      }
      return await this.getCollection((args as any).name);
    }
  • Direct tool registration and inline handler for get_collection in Cloudflare agent implementation
    this.server.tool(
      "get_collection",
      "Get details of a specific collection",
      { nameOrId: z.string().describe('Collection name or ID') },
      async ({ nameOrId }) => {
        if (!this.pb) {
          throw new Error('PocketBase not initialized');
        }
    
        const collection = await this.pb.collections.getOne(nameOrId);
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(collection, null, 2)
          }]
        };
      }
    );
  • Tool registration and inline handler for get_collection in simple agent implementation
    this.server.tool(
      'get_collection',
      {
        description: 'Get details of a specific collection',
        inputSchema: {
          nameOrId: z.string().describe('Collection name or ID')
        }
      },
      async ({ nameOrId }) => {
        await this.ensureInitialized();
        if (!this.pb) {
          throw new Error('PocketBase not initialized');
        }
    
        try {
          const collection = await this.pb.collections.getOne(nameOrId);
          return {
            content: [{
              type: 'text',
              text: JSON.stringify(collection, null, 2)
            }]
          };
        } catch (error: any) {
          throw new Error(`Failed to get collection: ${error.message}`);
        }
      }
    );
  • Input schema definition for get_collection tool in worker entry point tools list
      name: 'get_collection',
      description: 'Get details of a specific collection',
      inputSchema: {
        type: 'object',
        properties: {
          nameOrId: { type: 'string', description: 'Collection name or ID' }
        },
        required: ['nameOrId']
      }
    },
Install Server

Other Tools

Related Tools

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

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