Skip to main content
Glama

fetch_record

Retrieve a single record from a PocketBase collection using its unique ID. Specify the collection name and record ID to access data directly.

Instructions

Fetch a single record from a PocketBase collection by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesThe name or ID of the PocketBase collection.
idYesThe ID of the record to fetch.

Implementation Reference

  • The core handler function that executes the fetch_record tool. It validates input, fetches the record from PocketBase using getOne, and returns the record as JSON string.
    async function fetchRecord(args: FetchRecordArgs, pb: PocketBase): Promise<ToolResult> { if (!args.collection || !args.id) { throw invalidParamsError("Missing required arguments: collection, id"); } const record = await pb.collection(args.collection).getOne(args.id); return { content: [{ type: 'text', text: JSON.stringify(record, null, 2) }], }; }
  • TypeScript interface defining the expected input arguments for the fetch_record tool: collection (string) and id (string).
    export interface FetchRecordArgs { collection: string; id: string; }
  • ToolInfo registration entry for 'fetch_record', including name, description, and JSON schema for input validation. Part of recordToolInfo array exported via listRecordTools().
    { name: 'fetch_record', description: 'Fetch a single record from a PocketBase collection by ID.', inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'The name or ID of the PocketBase collection.' }, id: { type: 'string', description: 'The ID of the record to fetch.' }, }, required: ['collection', 'id'], }, },
  • Central registration function that aggregates tool infos from all modules, including record tools containing fetch_record.
    // Combine all tool definitions export function registerTools(): { tools: ToolInfo[] } { // Use ToolInfo[] const tools: ToolInfo[] = [ // Use ToolInfo[] ...listRecordTools(), ...listCollectionTools(), ...listFileTools(), ...listMigrationTools(), // Uncommented ...listLogTools(), // Add log tools ...listCronTools(), // Add cron tools ]; return { tools }; }
  • Routing logic in handleToolCall that directs 'fetch_record' calls to the record tools handler.
    if (name === 'fetch_record' || name === 'list_records' || name === 'create_record' || name === 'update_record') { return handleRecordToolCall(name, toolArgs, pb); } else if (name === 'get_collection_schema' || name === 'list_collections') {

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/mabeldata/pocketbase-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server