list_records
Retrieve and manage records from a specified collection with customizable filters, sorting, and pagination options for efficient database queries.
Instructions
List records from a collection with optional filters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | Collection name | |
| filter | No | Filter query | |
| page | No | Page number | |
| perPage | No | Items per page | |
| sort | No | Sort field and direction |
Implementation Reference
- src/index.ts:805-836 (handler)The function that executes the list_records tool logic: fetches records from the specified PocketBase collection using getList with optional filter, sort, pagination.private async listRecords(args: any) { try { const options: any = {}; if (args.filter) options.filter = args.filter; if (args.sort) options.sort = args.sort; if (args.page) options.page = args.page; if (args.perPage) options.perPage = args.perPage; const result = await this.pb.collection(args.collection).getList( options.page || 1, options.perPage || 50, { filter: options.filter, sort: options.sort, } ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error: unknown) { throw new McpError( ErrorCode.InternalError, `Failed to list records: ${pocketbaseErrorMessage(error)}` ); } }
- src/index.ts:223-248 (schema)Input schema defining parameters for list_records: required collection name, optional filter, sort, page, perPage.inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'Collection name', }, filter: { type: 'string', description: 'Filter query', }, sort: { type: 'string', description: 'Sort field and direction', }, page: { type: 'number', description: 'Page number', }, perPage: { type: 'number', description: 'Items per page', }, }, required: ['collection'], },
- src/index.ts:220-249 (registration)Tool registration in the ListTools response, including name, description, and input schema.{ name: 'list_records', description: 'List records from a collection with optional filters', inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'Collection name', }, filter: { type: 'string', description: 'Filter query', }, sort: { type: 'string', description: 'Sort field and direction', }, page: { type: 'number', description: 'Page number', }, perPage: { type: 'number', description: 'Items per page', }, }, required: ['collection'], }, },
- src/index.ts:677-678 (registration)Dispatcher case in CallToolRequestSchema handler that routes list_records calls to the listRecords method.case 'list_records': return await this.listRecords(request.params.arguments);