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
| Name | Required | Description | Default |
|---|---|---|---|
| collectionIdOrName | Yes | ID or name of the collection to view | |
| fields | No | Comma separated string of the fields to return in the JSON response |
Implementation Reference
- src/index.ts:936-959 (handler)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'], }, },
- src/index.ts:580-593 (schema)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);