Skip to main content
Glama
mabeldata

PocketBase MCP Server

by mabeldata

list_records

Retrieve records from a PocketBase collection with filtering, sorting, pagination, and expand related data to customize your queries.

Instructions

List records from a PocketBase collection. Supports filtering, sorting, pagination, and expansion.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesThe name or ID of the PocketBase collection.
pageNoPage number (defaults to 1).
perPageNoItems per page (defaults to 30, max 500).
filterNoPocketBase filter string (e.g., "status='active'").
sortNoPocketBase sort string (e.g., "-created,name").
expandNoPocketBase expand string (e.g., "user,tags.name").

Implementation Reference

  • The handler function that executes the 'list_records' tool logic. Queries a PocketBase collection with 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) }],
        };
    }
  • TypeScript interface defining the input schema for the 'list_records' tool, with required 'collection' and optional 'page', 'perPage', 'filter', 'sort', 'expand'.
    export interface ListRecordsArgs {
      collection: string;
      page?: number;
      perPage?: number;
      filter?: string;
      sort?: string;
      expand?: string;
    }
  • JSON Schema definition for the 'list_records' tool registration, describing the expected input parameters for the MCP client.
    {
        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'],
        },
  • Registration routing in the main handleToolCall function that dispatches 'list_records' calls to handleRecordToolCall.
    // Route tool calls to the appropriate handler
    export async function handleToolCall(params: CallToolRequest['params'], pb: PocketBase): Promise<ToolResult> {
        const { name, arguments: args } = params;
    
        // Basic validation
        if (!name || typeof name !== 'string') {
            throw invalidParamsError("Tool name is missing or invalid.");
        }
        // Allow null/undefined args for tools that don't require them (like list_collections)
        // Validation should happen within specific tool handlers if args are required.
        // if (args === undefined || args === null) {
        //     throw invalidParamsError("Tool arguments are missing.");
        // }
    
        // Route based on tool name prefix or category (adjust logic as needed)
        // Ensure args is treated as 'any' or validated properly before passing
        const toolArgs = args as any;
    
        if (name === 'fetch_record' || name === 'list_records' || name === 'create_record' || name === 'update_record') {
  • Registration function that provides the 'list_records' tool metadata (name, description, inputSchema) for MCP tool registration.
    export function listRecordTools(): ToolInfo[] {
        return recordToolInfo;
    }
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses support for filtering, sorting, pagination, and expansion, which are behavioral aspects, but does not mention read-only nature, authentication requirements, or rate limits. The description is adequate but not comprehensive.

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?

Two sentences with no wasted words. The most critical information (action and resource) is front-loaded, and the supporting features are listed concisely. This is an example of effective brevity.

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

Completeness4/5

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

For a simple read operation, the description covers the main features. However, it lacks information about the return format (e.g., list of records with pagination metadata) since there is no output schema. Minor gap given the tool's straightforward nature.

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 already documents all parameters. The description adds high-level context by grouping features (e.g., 'filtering' corresponds to 'filter' parameter), but does not provide additional meaning beyond what the schema provides. Baseline of 3 is appropriate.

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

Purpose5/5

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

The description 'List records from a PocketBase collection' clearly states the action (list) and resource (PocketBase collection), and mentions supported features (filtering, sorting, pagination, expansion) that distinguish it from sibling tools like create_record or fetch_record.

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

Usage Guidelines3/5

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

The description does not explicitly state when to use this tool versus alternatives (e.g., fetch_record for a single record). The purpose is implied but no direct guidance on exclusions or context is provided.

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

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