CreateRecord
Add new records to your RushDB graph database with structured data and optional transaction support for atomic operations.
Instructions
Create a new record in the database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | The record data to insert | |
| label | Yes | Label for the record | |
| transactionId | No | Optional transaction ID for atomic creation |
Implementation Reference
- tools/CreateRecord.ts:17-31 (handler)The main execution logic for the CreateRecord tool, which inserts a new record into the database.export async function CreateRecord(params: { label: string data: Record<string, any> transactionId?: string }) { const { label, data, transactionId } = params const result = await db.records.create({ label, data }, transactionId) return { success: true, id: result.id(), message: `Record created successfully with label '${label}'` } }
- tools.ts:76-88 (schema)The tool definition including name, description, and input schema (JSON Schema) for validation.{ name: 'CreateRecord', description: 'Create a new record in the database', inputSchema: { type: 'object', properties: { label: { type: 'string', description: 'Label for the record' }, data: { type: 'object', description: 'The record data to insert' }, transactionId: { type: 'string', description: 'Optional transaction ID for atomic creation' } }, required: ['label', 'data'] } },
- index.ts:137-150 (registration)Registration and dispatch logic in the MCP CallToolRequest handler switch statement.case 'CreateRecord': const createResult = await CreateRecord({ label: args.label as string, data: args.data as Record<string, any>, transactionId: args.transactionId as string | undefined }) return { content: [ { type: 'text', text: `${createResult.message}\nID: ${createResult.id}` } ] }
- index.ts:72-76 (registration)Handler for ListToolsRequestSchema that returns the tools array including CreateRecord.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools } })