Skip to main content
Glama

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

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

Input Schema (JSON Schema)

{ "properties": { "collectionName": { "description": "Name of the collection to create the record in", "type": "string" }, "record": { "description": "The record data to insert", "type": "object" } }, "required": [ "collectionName", "record" ], "type": "object" }

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; };

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