Skip to main content
Glama
fadlee

PocketBase MCP Server

by fadlee

list_records

Retrieve records from a PocketBase collection with filtering, sorting, pagination, and field selection options to manage database data.

Instructions

List records from a collection with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
expandNoComma-separated list of relation fields to expand (e.g. 'author,comments.user')
fieldsNoComma-separated fields to return in the response (e.g. 'id,title,author')
filterNoFilter query using PocketBase filter syntax (e.g. 'status = true && created > "2022-08-01 10:00:00"')
pageNoPage number for pagination (default: 1)
perPageNoItems per page (default: 50, max: 500)
skipTotalNoIf set to true, the total count query will be skipped to improve performance
sortNoSort field and direction (e.g. '-created,title' for descending created date followed by ascending title)

Implementation Reference

  • Implements the core logic for the list_records tool: constructs query options from args, calls PocketBase collection.getList(), and returns JSON response or handles errors.
    export function createListRecordsHandler(pb: PocketBase): ToolHandler {
      return async (args: ListRecordsArgs) => {
        try {
          const options: any = {};
          
          // Add optional parameters
          if (args.filter) options.filter = args.filter;
          if (args.sort) options.sort = args.sort;
          if (args.expand) options.expand = args.expand;
          if (args.fields) options.fields = args.fields;
          if (args.skipTotal !== undefined) options.skipTotal = args.skipTotal;
          
          // Set pagination
          const page = args.page || 1;
          const perPage = args.perPage || 50;
          
          const result = await pb
            .collection(args.collection)
            .getList(page, perPage, options);
          
          return createJsonResponse(result);
        } catch (error: unknown) {
          throw handlePocketBaseError("list records", error);
        }
      };
    }
  • Input schema (JSON Schema) for validating arguments to the list_records tool, defining properties like collection, filter, sort, pagination, etc.
    export const listRecordsSchema = {
      type: "object",
      properties: {
        collection: {
          type: "string",
          description: "Collection name",
        },
        filter: {
          type: "string",
          description: "Filter query using PocketBase filter syntax (e.g. 'status = true && created > \"2022-08-01 10:00:00\"')",
        },
        sort: {
          type: "string",
          description: "Sort field and direction (e.g. '-created,title' for descending created date followed by ascending title)",
        },
        page: {
          type: "number",
          description: "Page number for pagination (default: 1)",
        },
        perPage: {
          type: "number",
          description: "Items per page (default: 50, max: 500)",
        },
        expand: {
          type: "string",
          description: "Comma-separated list of relation fields to expand (e.g. 'author,comments.user')",
        },
        fields: {
          type: "string",
          description: "Comma-separated fields to return in the response (e.g. 'id,title,author')",
        },
        skipTotal: {
          type: "boolean",
          description: "If set to true, the total count query will be skipped to improve performance",
        },
      },
      required: ["collection"],
    };
  • src/server.ts:131-136 (registration)
    Registers the list_records tool in the MCP server array, linking the name, description, input schema, and instantiated handler.
    {
      name: "list_records",
      description: "List records from a collection with optional filters",
      inputSchema: listRecordsSchema,
      handler: createListRecordsHandler(pb),
    },
  • TypeScript interface defining the structure of input arguments for the list_records handler, used for type safety.
    export interface ListRecordsArgs {
      collection: string;
      filter?: string;
      sort?: string;
      page?: number;
      perPage?: number;
      expand?: string;
      fields?: string;
      skipTotal?: boolean;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('List records') but doesn't describe pagination behavior, rate limits, authentication needs, or what happens with invalid inputs. The mention of 'optional filters' hints at flexibility but lacks operational details, leaving significant gaps for a tool with 8 parameters.

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 the key feature ('with optional filters'). There is zero waste, 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.

Completeness2/5

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

Given 8 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain return values, error handling, or behavioral traits like pagination defaults. For a list operation with rich filtering options, more context is needed to guide effective use, especially with siblings like 'query_collection' present.

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 8 parameters. The description adds no specific parameter semantics beyond implying filtering capability. It meets the baseline of 3 since the schema does the heavy lifting, but doesn't compensate with additional context like examples or constraints not in the schema.

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') with the specific capability of optional filtering. It distinguishes from siblings like 'query_collection' by focusing on listing rather than querying, though the distinction could be more explicit. The purpose is specific and actionable.

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 like 'query_collection' or 'get_collection_schema'. It mentions optional filters but doesn't specify scenarios, prerequisites, or exclusions. Usage is implied through the name and parameters, but explicit context is missing.

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

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