Skip to main content
Glama

BulkCreateRecords

Create multiple database records in one operation to efficiently handle batch data insertion and maintain data consistency.

Instructions

Create multiple records in a single operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesArray of record data to insert
labelYesLabel for all records
transactionIdNoOptional transaction ID for atomic bulk creation

Implementation Reference

  • The core handler function implementing the BulkCreateRecords tool logic, using db.records.createMany for batch insertion.
    export async function BulkCreateRecords({ label, data, transactionId }: BulkCreateRecordsArgs): Promise<BulkCreateRecordsResult> { const result = await db.records.createMany({ label, data }, transactionId) const ids = result.data.map((record: any) => record.id()) return { message: `Successfully created ${ids.length} records with label '${label}'`, ids } }
  • tools.ts:257-269 (registration)
    Registration of the BulkCreateRecords tool in the exported tools array used by MCP ListTools, including input schema.
    { name: 'BulkCreateRecords', description: 'Create multiple records in a single operation', inputSchema: { type: 'object', properties: { label: { type: 'string', description: 'Label for all records' }, data: { type: 'array', items: { type: 'object' }, description: 'Array of record data to insert' }, transactionId: { type: 'string', description: 'Optional transaction ID for atomic bulk creation' } }, required: ['label', 'data'] } },
  • TypeScript type definitions for input arguments and output result of the BulkCreateRecords handler.
    type BulkCreateRecordsArgs = { label: string data: Record<string, any>[] transactionId?: string } type BulkCreateRecordsResult = { message: string ids: string[] }
  • MCP server dispatcher case that invokes the BulkCreateRecords handler and formats the response for the MCP protocol.
    case 'BulkCreateRecords': const bulkCreateResult = await BulkCreateRecords({ label: args.label as string, data: args.data as Record<string, any>[], transactionId: args.transactionId as string | undefined }) return { content: [ { type: 'text', text: `${bulkCreateResult.message}\nIDs: ${bulkCreateResult.ids.join(', ')}` } ] }
  • index.ts:35-35 (registration)
    Import of the BulkCreateRecords handler into the main index for use in the tool dispatcher.
    import { BulkCreateRecords } from './tools/BulkCreateRecords.js'

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/1pxone/RushDB'

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