Skip to main content
Glama
mrwyndham

PocketBase MCP Server

get_collection

Retrieve collection details including schema and fields from a PocketBase database using the collection ID or name.

Instructions

Get details for a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionIdOrNameYesID or name of the collection to view
fieldsNoComma separated string of the fields to return in the JSON response

Implementation Reference

  • The core handler function for the 'get_collection' tool. It authenticates as admin using PocketBase superuser credentials, retrieves the specified collection details (optionally selecting fields), and returns the JSON-stringified collection data as MCP content.
    private async getCollection(args: any) {
      try {
        // Authenticate with PocketBase
        await this.pb.collection("_superusers").authWithPassword(process.env.POCKETBASE_ADMIN_EMAIL ?? '', process.env.POCKETBASE_ADMIN_PASSWORD ?? '');
        
        // Get collection details
        const collection = await this.pb.collections.getOne(args.collectionIdOrName, {
          fields: args.fields
        });
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(collection, null, 2),
            },
          ],
        };
      } catch (error: unknown) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to get collection: ${pocketbaseErrorMessage(error)}`
        );
      }
  • src/index.ts:577-594 (registration)
    Tool registration in the list passed to server.setTools(). Defines the tool name, description, and input schema.
    {
      name: 'get_collection',
      description: 'Get details for a collection',
      inputSchema: {
        type: 'object',
        properties: {
          collectionIdOrName: {
            type: 'string',
            description: 'ID or name of the collection to view',
          },
          fields: {
            type: 'string',
            description: 'Comma separated string of the fields to return in the JSON response',
          },
        },
        required: ['collectionIdOrName'],
      },
    },
  • Input schema definition for the 'get_collection' tool, specifying parameters like collectionIdOrName (required) and optional fields.
    inputSchema: {
      type: 'object',
      properties: {
        collectionIdOrName: {
          type: 'string',
          description: 'ID or name of the collection to view',
        },
        fields: {
          type: 'string',
          description: 'Comma separated string of the fields to return in the JSON response',
        },
      },
      required: ['collectionIdOrName'],
    },
  • src/index.ts:687-688 (registration)
    Dispatch case in the CallToolRequest handler that routes 'get_collection' calls to the specific getCollection method.
    case 'get_collection':
      return await this.getCollection(request.params.arguments);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states it 'gets details' without disclosing behavioral traits like permissions needed, rate limits, error handling, or what happens if the collection doesn't exist. It's minimal and lacks critical operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—'Get details for a collection' is front-loaded and appropriately sized for its purpose, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a read operation with 2 parameters), no annotations, and no output schema, the description is incomplete. It doesn't explain return values, error cases, or usage nuances, leaving significant gaps for an AI agent to understand the tool fully.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('collectionIdOrName' and 'fields'). The description adds no meaning beyond this, such as examples of field names or how to format the comma-separated string, resulting in a baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get details for a collection' clearly states the verb ('Get') and resource ('collection'), but it's vague about what 'details' entails and doesn't differentiate from sibling tools like 'list_collections' or 'update_collection'. It's functional but lacks specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as 'list_collections' for browsing or 'update_collection' for modifications. The description implies usage for viewing a specific collection but offers no explicit context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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