Skip to main content
Glama
hendrickcastro

MCP CosmosDB

mcp_delete_document

Permanently delete a document from a CosmosDB container by specifying container, document ID, and partition key. Irreversible action, use with caution.

Instructions

Delete a document from a CosmosDB container.

WARNING: This operation is irreversible. The document will be permanently deleted.

Example: mcp_delete_document({ container_id: 'users', document_id: 'user-456', partition_key: 'user-456', connection_id: 'athlete' })

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
container_idYesThe ID/name of the container
document_idYesThe ID of the document to delete
partition_keyYesThe partition key value for the document
connection_idNoID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

Implementation Reference

  • The main handler function for mcp_delete_document. Deletes a document from a CosmosDB container by container_id, document_id, and partition_key. Returns deleted: true on success or an error message on failure (e.g., 404 not found).
    export const mcp_delete_document = async (args: DeleteDocumentArgs & { connection_id?: string }): Promise<ToolResult<DeleteOperationResult>> => {
      const { container_id, document_id, partition_key, connection_id } = args;
      log(`Executing mcp_delete_document with: ${JSON.stringify(args)}`);
    
      try {
        // Validate modifications are allowed
        validateModificationAllowed('delete_document', connection_id);
        
        const container = getContainer(container_id, connection_id);
        
        const { requestCharge } = await container
          .item(document_id, partition_key)
          .delete();
    
        return { 
          success: true, 
          data: {
            deleted: true,
            id: document_id,
            requestCharge: requestCharge || 0
          }
        };
      } catch (error: any) {
        log(`Error in mcp_delete_document for document ${document_id}: ${error.message}`);
        
        // Provide more helpful error messages
        if (error.code === 404) {
          return { success: false, error: `Document with id '${document_id}' not found` };
        }
        
        return { success: false, error: error.message };
      }
    };
  • The DeleteDocumentArgs interface defining input types: container_id, document_id, partition_key.
    export interface DeleteDocumentArgs {
      container_id: string;
      document_id: string;
      partition_key: PartitionKeyValue;
    }
  • src/tools.ts:316-348 (registration)
    Tool registration/definition with name 'mcp_delete_document', description, example usage, and inputSchema (container_id, document_id, partition_key required).
      // 11. Delete Document
      {
        name: "mcp_delete_document",
        description: `Delete a document from a CosmosDB container.
    
    WARNING: This operation is irreversible. The document will be permanently deleted.
    
    Example: mcp_delete_document({
      container_id: 'users',
      document_id: 'user-456',
      partition_key: 'user-456',
      connection_id: 'athlete'
    })`,
        inputSchema: {
          type: "object",
          properties: {
            container_id: {
              type: "string",
              description: "The ID/name of the container"
            },
            document_id: {
              type: "string",
              description: "The ID of the document to delete"
            },
            partition_key: {
              type: ["string", "number", "boolean"],
              description: "The partition key value for the document"
            },
            ...connectionIdProperty
          },
          required: ["container_id", "document_id", "partition_key"]
        }
      },
  • Server routing: the case handler that dispatches mcp_delete_document to the toolHandlers function.
    case 'mcp_delete_document':
        result = await toolHandlers.mcp_delete_document(input as any);
        break;
  • Re-exports mcp_delete_document from dataOperations.ts as part of the tools module.
    mcp_delete_document,
Behavior3/5

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

No annotations provided, so description carries full burden. It warns that the operation is irreversible and permanent, which is crucial behavioral context. However, it omits details like permission requirements, error handling (e.g., document not found), or idempotency.

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?

Extremely concise: one sentence for purpose, one for warning, and one example. No filler; every part earns its place.

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

Completeness3/5

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

Given no output schema and no annotations, the description covers the essential action and provides a usage example. However, it lacks guidance on handling non-existent documents, error responses, or potential side effects beyond irreversibility.

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 has 100% description coverage for all 4 parameters, so description adds limited value. The example illustrates parameter usage but does not explain any nuance beyond what the schema provides.

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

Purpose5/5

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

The description clearly states the action ('Delete a document') and the target resource ('from a CosmosDB container'), distinguishing it from sibling tools like mcp_create_document or mcp_update_document.

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

Usage Guidelines4/5

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

Includes a strong warning about irreversibility, which guides appropriate usage. However, it does not explicitly state when to use vs. alternatives (e.g., soft deletion) nor what to do if the document doesn't exist.

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

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/hendrickcastro/MCPCosmosDB'

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