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
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | The name or ID of the PocketBase collection. | |
| id | Yes | The ID of the record to fetch. |
Implementation Reference
- src/tools/record-tools.ts:89-97 (handler)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) }], }; }
- src/types/tool-types.ts:29-32 (schema)TypeScript interface defining the expected input arguments for the fetch_record tool: collection (string) and id (string).export interface FetchRecordArgs { collection: string; id: string; }
- src/tools/record-tools.ts:10-21 (registration)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'], }, },
- src/tools/index.ts:14-25 (registration)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 }; }
- src/tools/index.ts:45-47 (registration)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') {