fetch_record
Retrieve a single record from a PocketBase collection by providing the collection name or ID and the record ID.
Instructions
Fetch a single record from a PocketBase collection by ID.
Input 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 actual handler function for the 'fetch_record' tool. It validates arguments (collection, id), calls PocketBase's getOne to fetch the record, and returns the result as formatted JSON.
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 for FetchRecordArgs, defining the input schema with 'collection' (string) and 'id' (string) fields.
export interface FetchRecordArgs { collection: string; id: string; } - src/tools/record-tools.ts:9-21 (registration)Registers the 'fetch_record' tool with its name, description, and input schema (collection and id as required strings).
const recordToolInfo: ToolInfo[] = [ { 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:45-46 (registration)Main routing logic that dispatches 'fetch_record' to handleRecordToolCall in record-tools.ts.
if (name === 'fetch_record' || name === 'list_records' || name === 'create_record' || name === 'update_record') { return handleRecordToolCall(name, toolArgs, pb); - src/tools/record-tools.ts:73-74 (registration)Dispatch within record-tools.ts that routes the 'fetch_record' case to the fetchRecord function.
case 'fetch_record': return fetchRecord(args as FetchRecordArgs, pb);