create_record
Add new records to PocketBase collections by specifying collection name and data fields for structured database entries.
Instructions
Create a new record in a collection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | Collection name | |
| data | Yes | Record data |
Implementation Reference
- src/index.ts:786-803 (handler)The main handler function that executes the create_record tool by calling PocketBase's create method on the specified collection with the provided data, returning the result as JSON text content.private async createRecord(args: any) { try { const result = await this.pb.collection(args.collection).create(args.data); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error: unknown) { throw new McpError( ErrorCode.InternalError, `Failed to create record: ${pocketbaseErrorMessage(error)}` ); } }
- src/index.ts:205-218 (schema)Defines the input schema for the create_record tool, requiring 'collection' (string) and 'data' (object).inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'Collection name', }, data: { type: 'object', description: 'Record data', }, }, required: ['collection', 'data'], },
- src/index.ts:202-219 (registration)Registers the create_record tool in the ListTools response, including name, description, and input schema.{ name: 'create_record', description: 'Create a new record in a collection', inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'Collection name', }, data: { type: 'object', description: 'Record data', }, }, required: ['collection', 'data'], }, },
- src/index.ts:675-676 (registration)Registers the handler for create_record in the CallToolRequestSchema switch statement.case 'create_record': return await this.createRecord(request.params.arguments);