Skip to main content
Glama
datastax

Astra DB MCP Server

Official

DeleteRecord

Remove a specific record from a collection in Astra DB by specifying the collection name and record ID using the MCP Server's tool for efficient data management.

Instructions

Delete a record from a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionNameYesName of the collection containing the record
recordIdYesID of the record to delete

Implementation Reference

  • The main handler function that executes the deletion of a specific record from the given collection by ID using the database client.
    export async function DeleteRecord(params: {
      collectionName: string;
      recordId: string;
    }) {
      const { collectionName, recordId } = params;
    
      const collection = db.collection(collectionName);
      const result = await collection.deleteOne({ _id: recordId });
    
      if (result.deletedCount === 0) {
        throw new Error(
          `Record with ID '${recordId}' not found in collection '${collectionName}'`
        );
      }
    
      return {
        success: true,
        message: `Record '${recordId}' deleted successfully from collection '${collectionName}'`,
      };
    }
  • The JSON schema defining the input parameters for the DeleteRecord tool: collectionName and recordId.
    {
      name: "DeleteRecord",
      description: "Delete a record from a collection",
      inputSchema: {
        type: "object",
        properties: {
          collectionName: {
            type: "string",
            description: "Name of the collection containing the record",
          },
          recordId: {
            type: "string",
            description: "ID of the record to delete",
          },
        },
        required: ["collectionName", "recordId"],
      },
    },
  • index.ts:201-213 (registration)
    The switch case in the CallToolRequestSchema handler that registers and invokes the DeleteRecord tool during runtime.
    case "DeleteRecord":
      const deleteRecordResult = await DeleteRecord({
        collectionName: args.collectionName as string,
        recordId: args.recordId as string,
      });
      return {
        content: [
          {
            type: "text",
            text: deleteRecordResult.message,
          },
        ],
      };

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