list_records
Retrieve records from a PocketBase collection with customizable filters, sorting, pagination, and expansion for precise data access.
Instructions
List records from a PocketBase collection. Supports filtering, sorting, pagination, and expansion.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | The name or ID of the PocketBase collection. | |
| expand | No | PocketBase expand string (e.g., "user,tags.name"). | |
| filter | No | PocketBase filter string (e.g., "status='active'"). | |
| page | No | Page number (defaults to 1). | |
| perPage | No | Items per page (defaults to 30, max 500). | |
| sort | No | PocketBase sort string (e.g., "-created,name"). |
Implementation Reference
- src/tools/record-tools.ts:99-112 (handler)The main handler function for the 'list_records' tool, which fetches a list of records from a PocketBase collection using getList with optional pagination, filtering, sorting, and expansion.async function listRecords(args: ListRecordsArgs, pb: PocketBase): Promise<ToolResult> { if (!args.collection) { throw invalidParamsError("Missing required argument: collection"); } const { collection, page = 1, perPage = 30, filter, sort, expand } = args; const result = await pb.collection(collection).getList(page, perPage, { filter, sort, expand }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/tools/record-tools.ts:22-37 (schema)The ToolInfo object defining the schema, description, and input parameters for the 'list_records' tool.{ name: 'list_records', description: 'List records from a PocketBase collection. Supports filtering, sorting, pagination, and expansion.', inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'The name or ID of the PocketBase collection.' }, page: { type: 'number', description: 'Page number (defaults to 1).', minimum: 1 }, perPage: { type: 'number', description: 'Items per page (defaults to 30, max 500).', minimum: 1, maximum: 500 }, filter: { type: 'string', description: 'PocketBase filter string (e.g., "status=\'active\'").' }, sort: { type: 'string', description: 'PocketBase sort string (e.g., "-created,name").' }, expand: { type: 'string', description: 'PocketBase expand string (e.g., "user,tags.name").' } }, required: ['collection'], }, },
- src/types/tool-types.ts:34-41 (schema)TypeScript interface defining the input arguments for the 'list_records' tool.export interface ListRecordsArgs { collection: string; page?: number; perPage?: number; filter?: string; sort?: string; expand?: string; }
- src/tools/index.ts:44-47 (registration)Dispatch logic in handleToolCall that routes 'list_records' 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') {
- src/tools/index.ts:16-23 (registration)Registration of record tools (including list_records) in the main registerTools function via spread of listRecordTools().const tools: ToolInfo[] = [ // Use ToolInfo[] ...listRecordTools(), ...listCollectionTools(), ...listFileTools(), ...listMigrationTools(), // Uncommented ...listLogTools(), // Add log tools ...listCronTools(), // Add cron tools ];