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; }

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

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