create_record
Create a new record in a PocketBase collection by providing the collection name and data fields.
Instructions
Create a new record in a PocketBase collection.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | The name or ID of the PocketBase collection. | |
| data | Yes | The data for the new record (key-value pairs). |
Implementation Reference
- src/tools/record-tools.ts:114-122 (handler)The core handler function for the 'create_record' tool. It validates that collection and data args are present, then calls pb.collection(collection).create(data) to create a new record in PocketBase, returning the result as JSON text.
async function createRecord(args: CreateRecordArgs, pb: PocketBase): Promise<ToolResult> { if (!args.collection || !args.data) { throw invalidParamsError("Missing required arguments: collection, data"); } const record = await pb.collection(args.collection).create(args.data); return { content: [{ type: 'text', text: JSON.stringify(record, null, 2) }], }; } - src/types/tool-types.ts:43-46 (schema)The TypeScript interface for CreateRecordArgs, defining the input shape: collection (string) and data (any).
export interface CreateRecordArgs { collection: string; data: any; } - src/tools/record-tools.ts:38-49 (schema)The tool definition (name, description, inputSchema) for 'create_record' registered in the recordToolInfo array.
{ name: 'create_record', description: 'Create a new record in a PocketBase collection.', inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'The name or ID of the PocketBase collection.' }, data: { type: 'object', description: 'The data for the new record (key-value pairs).', additionalProperties: true }, }, required: ['collection', 'data'], }, }, - src/tools/index.ts:45-46 (registration)The routing logic in handleToolCall that dispatches 'create_record' calls to handleRecordToolCall (which in turn calls createRecord).
if (name === 'fetch_record' || name === 'list_records' || name === 'create_record' || name === 'update_record') { return handleRecordToolCall(name, toolArgs, pb); - src/tools/index.ts:15-25 (registration)The registerTools function that combines all tool definitions (including create_record from listRecordTools) into the full tool list exposed to the MCP client.
export function registerTools(): { tools: ToolInfo[] } { // Use ToolInfo[] const tools: ToolInfo[] = [ // Use ToolInfo[] ...listRecordTools(), ...listCollectionTools(), ...listFileTools(), ...listMigrationTools(), // Uncommented ...listLogTools(), // Add log tools ...listCronTools(), // Add cron tools ]; return { tools }; }