Skip to main content
Glama
mrwyndham

PocketBase MCP Server

list_records

Retrieve records from a PocketBase collection using filters, sorting, and pagination to query and manage database data.

Instructions

List records from a collection with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
filterNoFilter query
sortNoSort field and direction
pageNoPage number
perPageNoItems per page

Implementation Reference

  • The handler function that implements the core logic of the 'list_records' tool. It constructs query options from input arguments and uses PocketBase's getList method to fetch records from the specified collection.
    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)}`
        );
      }
    }
  • Input schema definition for the 'list_records' tool, specifying parameters like collection (required), filter, sort, page, and 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)
    Registration of the 'list_records' tool in the MCP server's 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 the CallToolRequestHandler that routes 'list_records' calls to the listRecords handler method.
    case 'list_records':
      return await this.listRecords(request.params.arguments);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states it's a list operation with optional filters, implying read-only behavior, but doesn't disclose critical details like pagination handling (implied by 'page' and 'perPage' parameters), rate limits, authentication requirements, or error conditions. For a tool with 5 parameters and no annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('List records from a collection') and adds key functionality ('with optional filters'). There is no wasted verbiage, and it's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and 5 parameters with full schema coverage, the description is minimally adequate. It covers the basic purpose but lacks details on usage context, behavioral traits, and output format. For a list operation with filtering and pagination, more guidance on results and limitations would improve completeness, but it's not entirely inadequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 5 parameters. The description adds minimal value beyond the schema by mentioning 'optional filters' (hinting at the 'filter' parameter) but doesn't provide additional context like filter syntax examples or default behaviors. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('records from a collection'), making the purpose understandable. It distinguishes from siblings like 'get_collection' or 'create_record' by focusing on listing records rather than single retrieval or creation. However, it doesn't explicitly differentiate from other list operations like 'list_collections' beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'optional filters' but doesn't specify scenarios where filtering is needed or when to choose this over other tools like 'get_collection' for metadata or 'search' operations if available. No prerequisites or exclusions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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