Skip to main content
Glama
datastax

Astra DB MCP Server

Official

BulkCreateRecords

Insert multiple records into a specified collection in Astra DB databases using this tool. Streamline data management with a single API call, supporting efficient bulk operations.

Instructions

Create multiple records in a collection at once

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionNameYesName of the collection to create the records in
recordsYesArray of records to insert

Implementation Reference

  • The main handler function that executes the bulk record creation logic, preferring insertMany for performance and falling back to individual insertOne calls if necessary.
    export async function BulkCreateRecords({
      collectionName,
      records,
    }: BulkCreateRecordsArgs): Promise<BulkCreateRecordsResult> {
      const collection: Collection = db.collection(collectionName);
      
      let ids: string[] = [];
      
      try {
        // Try to use insertMany for better performance
        if (typeof collection.insertMany === 'function') {
          const result = await collection.insertMany(records);
          
          // Extract the inserted IDs from the result
          ids = Object.values(result.insertedIds || {})
            .map((id) => id?.toString() || "")
            .filter((id) => id !== "");
        } else {
          // Fallback to individual insertOne operations
          for (const record of records) {
            const result = await collection.insertOne(record);
            if (result.insertedId) {
              ids.push(result.insertedId.toString());
            }
          }
        }
      } catch (error) {
        console.error("Error in bulk create:", error);
        throw error;
      }
      
      return {
        message: `Successfully created ${ids.length} records`,
        ids,
      };
    }
  • TypeScript type definitions for the input arguments and output result of the BulkCreateRecords tool.
    type BulkCreateRecordsArgs = {
      collectionName: string;
      records: Record<string, any>[];
    };
    
    type BulkCreateRecordsResult = {
      message: string;
      ids: string[];
    };
  • tools.ts:262-282 (registration)
    Registration of the BulkCreateRecords tool in the tools array exported for MCP listTools, including description and input JSON schema.
    {
      name: "BulkCreateRecords",
      description: "Create multiple records in a collection at once",
      inputSchema: {
        type: "object",
        properties: {
          collectionName: {
            type: "string",
            description: "Name of the collection to create the records in",
          },
          records: {
            type: "array",
            description: "Array of records to insert",
            items: {
              type: "object",
            },
          },
        },
        required: ["collectionName", "records"],
      },
    },
  • index.ts:301-315 (registration)
    Dispatch logic in the main CallToolRequest handler that invokes the BulkCreateRecords function and formats the response.
    case "BulkCreateRecords":
      const bulkCreateResult = await BulkCreateRecords({
        collectionName: args.collectionName as string,
        records: args.records as Record<string, any>[],
      });
      return {
        content: [
          {
            type: "text",
            text: `${
              bulkCreateResult.message
            }\nIDs: ${bulkCreateResult.ids.join(", ")}`,
          },
        ],
      };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Create' implies a write/mutation operation, it doesn't specify permissions required, whether the operation is atomic/all-or-nothing, how duplicates or conflicts are handled, or what happens on partial failure. For a bulk mutation tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a tool with clear parameters documented elsewhere.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a bulk mutation tool with no annotations and no output schema, the description is insufficient. It doesn't address critical context like transaction behavior, error handling, performance implications, or return values. Given the complexity of bulk operations and lack of structured metadata, more guidance is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters (collectionName and records). The description adds no additional semantic context about parameter usage, constraints, or examples beyond what's in the schema. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create multiple records') and target ('in a collection at once'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from its sibling 'CreateRecord' which handles single record creation, leaving some ambiguity about when to choose one over the other.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'CreateRecord' (for single records) or other bulk operations ('BulkDeleteRecords', 'BulkUpdateRecords'). There's no mention of prerequisites, performance considerations, or error handling for batch operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/datastax/astra-db-mcp'

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