Skip to main content
Glama
datastax

Astra DB MCP Server

Official

CreateRecord

Insert new data records into specified collections within Astra DB, enabling structured storage and management through natural language commands on the MCP Server.

Instructions

Create a new record in a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionNameYesName of the collection to create the record in
recordYesThe record data to insert

Implementation Reference

  • The main handler function for the CreateRecord tool, which inserts a new record into the specified collection and returns the result with ID and success message.
    export async function CreateRecord(params: {
      collectionName: string;
      record: Record<string, any>;
    }): Promise<CreateRecordResult> {
      const { collectionName, record } = params;
    
      const collection = db.collection(collectionName);
      const result = await collection.insertOne(record);
    
      // Create a response that satisfies both the tests and the index.ts usage
      const id = record._id || result.insertedId;
      
      // Create the response object with all required properties
      const response: CreateRecordResult = {
        ...record,
        _id: id,
        id: id,
        message: `Record created successfully in collection '${collectionName}'`,
        success: true
      };
    
      return response;
    }
  • The input schema definition for the CreateRecord tool, used for validation in the MCP tool list.
    {
      name: "CreateRecord",
      description: "Create a new record in a collection",
      inputSchema: {
        type: "object",
        properties: {
          collectionName: {
            type: "string",
            description: "Name of the collection to create the record in",
          },
          record: {
            type: "object",
            description: "The record data to insert",
          },
        },
        required: ["collectionName", "record"],
      },
    },
  • index.ts:61-65 (registration)
    The request handler for listing tools, which registers and exposes the CreateRecord tool via the exported tools array from tools.ts.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools,
      };
    });
  • index.ts:172-184 (registration)
    The dispatch case in the main CallToolRequest handler that invokes the CreateRecord tool function.
    case "CreateRecord":
      const createRecordResult = await CreateRecord({
        collectionName: args.collectionName as string,
        record: args.record as Record<string, any>,
      });
      return {
        content: [
          {
            type: "text",
            text: `${createRecordResult.message}\nID: ${createRecordResult.id}`,
          },
        ],
      };
  • TypeScript type definition for the CreateRecord result, defining the expected output structure.
    type CreateRecordResult = Record<string, any> & {
      _id: string;
      id: string;
      message: string;
      success: boolean;
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates a record but doesn't mention potential side effects (e.g., if it overwrites existing records), authentication needs, error conditions, or what happens on success (e.g., returns an ID). This leaves significant gaps for a mutation tool.

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, clear sentence with zero wasted words. It's front-loaded with the core action and resource, making it highly efficient and easy to parse without unnecessary elaboration.

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?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., the created record's ID), error handling, or behavioral nuances, which are critical for safe and effective use in an AI agent context.

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 input schema already documents both parameters ('collectionName' and 'record') adequately. The description adds no additional semantic context beyond implying the tool uses these parameters, which aligns with the baseline score when schema does the heavy lifting.

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') and resource ('new record in a collection'), making the purpose immediately understandable. It distinguishes from siblings like 'BulkCreateRecords' by specifying singular creation, though it doesn't explicitly contrast with 'CreateCollection' which creates collections rather than records.

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?

No guidance is provided on when to use this tool versus alternatives like 'BulkCreateRecords' for multiple records or 'CreateCollection' for creating collections. The description lacks context about prerequisites, such as whether the collection must exist first, or when to choose this over bulk 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