get_collection
Retrieve detailed information about a specific collection in a PocketBase database, including fields and metadata, using its 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 primary handler function that implements the logic for the 'get_collection' tool. It authenticates as an admin, fetches the specified collection's details using PocketBase SDK, and returns the result as JSON text 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:580-593 (schema)Input schema definition for the 'get_collection' tool, specifying the required 'collectionIdOrName' parameter and optional 'fields' for selecting specific fields in the response.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:577-594 (registration)Tool registration entry in the ListTools response, defining the name, description, and input schema for 'get_collection'.{ 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:687-688 (registration)Dispatcher case in the CallToolRequestHandler that registers and routes calls to the 'get_collection' tool handler method.case 'get_collection': return await this.getCollection(request.params.arguments);