Skip to main content
Glama
mrwyndham

PocketBase MCP Server

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
NameRequiredDescriptionDefault
collectionIdOrNameYesID or name of the collection to view
fieldsNoComma separated string of the fields to return in the JSON response

Implementation Reference

  • 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)}` ); }
  • 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);

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