create_record
Add a new record to any collection in a PocketBase database by specifying the collection name and data, enabling efficient data management and organization.
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 primary handler function that implements the 'create_record' tool logic. It uses PocketBase SDK to create a record in the specified collection with the given data and returns the result as JSON-formatted text.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:202-219 (schema)The input schema definition for the 'create_record' tool, specifying required properties: collection (string) and data (object). This is part of the tool registration in the tools list.{ 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)The switch case in the MCP request handler that registers and dispatches calls to the 'create_record' handler method.case 'create_record': return await this.createRecord(request.params.arguments);