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
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | The name or ID of the PocketBase collection. |
Implementation Reference
- src/tools/collection-tools.ts:51-59 (handler)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) }], }; }
- src/tools/collection-tools.ts:10-20 (registration)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'], }, },
- src/types/tool-types.ts:54-56 (schema)TypeScript type definition for the tool's input arguments (GetCollectionSchemaArgs). Imported and used in the handler.export interface GetCollectionSchemaArgs { collection: string; }
- src/tools/index.ts:47-48 (helper)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);
- src/tools/collection-tools.ts:39-40 (helper)Local dispatch in handleCollectionToolCall() that invokes the getCollectionSchema handler function.case 'get_collection_schema': return getCollectionSchema(args as GetCollectionSchemaArgs, pb);