Skip to main content
Glama
fadlee

PocketBase MCP Server

by fadlee

create_record

Add new records to PocketBase collections by specifying collection name and field data, with options to control returned fields and expand related records.

Instructions

Create a new record in a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
dataYesRecord data with field values matching the collection schema
expandNoComma-separated list of relation fields to expand in the response (e.g. 'author,comments.user')
fieldsNoComma-separated fields to return in the response (e.g. 'id,title,author')

Implementation Reference

  • The main handler function that executes the create_record tool logic by creating a new record in the specified PocketBase collection using the provided data and optional parameters.
    export function createCreateRecordHandler(pb: PocketBase): ToolHandler {
      return async (args: CreateRecordArgs) => {
        try {
          const options: any = {};
          
          // Add optional parameters
          if (args.expand) options.expand = args.expand;
          if (args.fields) options.fields = args.fields;
          
          const result = await pb
            .collection(args.collection)
            .create(args.data, options);
          
          return createJsonResponse(result);
        } catch (error: unknown) {
          throw handlePocketBaseError("create record", error);
        }
      };
    }
  • JSON Schema defining the input structure and validation for the create_record tool.
    export const createRecordSchema = {
      type: "object",
      properties: {
        collection: {
          type: "string",
          description: "Collection name",
        },
        data: {
          type: "object",
          description: "Record data with field values matching the collection schema",
        },
        expand: {
          type: "string",
          description: "Comma-separated list of relation fields to expand in the response (e.g. 'author,comments.user')",
        },
        fields: {
          type: "string",
          description: "Comma-separated fields to return in the response (e.g. 'id,title,author')",
        },
      },
      required: ["collection", "data"],
    };
  • src/server.ts:126-130 (registration)
    Registration of the create_record tool in the MCP server, associating its name, description, input schema, and handler.
      name: "create_record",
      description: "Create a new record in a collection",
      inputSchema: createRecordSchema,
      handler: createCreateRecordHandler(pb),
    },
  • TypeScript interface defining the expected argument types for the create_record handler.
    export interface CreateRecordArgs {
      collection: string;
      data: Record<string, any>;
      expand?: string;
      fields?: string;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it creates a record but doesn't mention permissions needed, whether it's idempotent, error handling, or what the response contains (especially with no output schema). This is inadequate for a mutation tool with zero annotation coverage.

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 with zero wasted words. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

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?

For a mutation tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what happens on success/failure, return values, or behavioral constraints, leaving significant gaps for agent understanding.

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 4 parameters. The description doesn't add any parameter-specific details beyond what's in the schema (e.g., format examples for 'data' or 'expand'), meeting the baseline for high schema coverage.

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 action ('Create') and target ('new record in a collection'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'create_collection' or 'create_user', which also create resources but different types.

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 'create_collection' or 'update_record'. It doesn't mention prerequisites (e.g., collection must exist) or context for choosing this tool over siblings, leaving the agent with minimal usage direction.

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