Skip to main content
Glama
mrwyndham

PocketBase MCP Server

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

Implementation Reference

  • 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'], }, },
  • 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);

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