Skip to main content
Glama
mabeldata

PocketBase MCP Server

by mabeldata

get_collection_schema

Retrieve the structure, fields, and rules of a specific collection in PocketBase databases for efficient data management and schema analysis.

Instructions

Get the schema (fields, rules, etc.) of a PocketBase collection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesThe name or ID of the PocketBase collection.

Implementation Reference

  • Core implementation of the 'get_collection_schema' tool. Validates input, fetches the collection schema using PocketBase's collections.getOne(), and returns it as prettified JSON in a ToolResult.
    async function getCollectionSchema(args: GetCollectionSchemaArgs, pb: PocketBase): Promise<ToolResult> {
        if (!args.collection) {
            throw invalidParamsError("Missing required argument: collection");
        }
        const schema = await pb.collections.getOne(args.collection);
        return {
            content: [{ type: 'text', text: JSON.stringify(schema, null, 2) }],
        };
    }
  • ToolInfo registration for 'get_collection_schema', including name, description, and JSON input schema. Part of collectionToolInfo array returned by listCollectionTools().
    {
        name: 'get_collection_schema',
        description: 'Get the schema (fields, rules, etc.) of a PocketBase collection.',
        inputSchema: {
            type: 'object',
            properties: {
                collection: { type: 'string', description: 'The name or ID of the PocketBase collection.' },
            },
            required: ['collection'],
        },
    },
  • TypeScript type definition for the tool's input arguments (GetCollectionSchemaArgs). Imported and used in the handler.
    export interface GetCollectionSchemaArgs {
      collection: string;
    }
  • Top-level tool dispatcher in handleToolCall() that routes 'get_collection_schema' calls to the collection tools handler.
    } else if (name === 'get_collection_schema' || name === 'list_collections') {
        return handleCollectionToolCall(name, toolArgs, pb);
  • Local dispatch in handleCollectionToolCall() that invokes the getCollectionSchema handler function.
    case 'get_collection_schema':
        return getCollectionSchema(args as GetCollectionSchemaArgs, pb);

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

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