Skip to main content
Glama

cosmosdb_container_delete

Delete a Cosmos DB container to remove unnecessary data storage and manage database resources effectively. Specify the container name and optional database name to execute the deletion.

Instructions

Delete a Cosmos DB container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
container_nameYesName of the Cosmos DB container
database_nameNoName of the Cosmos DB database (optional, defaults to 'defaultdb')

Implementation Reference

  • Executes the deletion of the Cosmos DB container by calling database.delete_container with the provided container name.
    elif name == "cosmosdb_container_delete":  # Renamed from table to container
        database.delete_container(arguments["container_name"])
        response = {"container_name": arguments["container_name"], "deleted": True}
  • Defines the Tool schema including name, description, and inputSchema for validating arguments (container_name required, database_name optional).
    Tool(
        name="cosmosdb_container_delete",  # Renamed from table to container
        description="Delete a Cosmos DB container",  # Updated description
        inputSchema={
            "type": "object",
            "properties": {
                "container_name": {  # Renamed from table_name
                    "type": "string",
                    "description": "Name of the Cosmos DB container",  # Updated description
                },
                "database_name": {
                    "type": "string",
                    "description": "Name of the Cosmos DB database (optional, defaults to 'defaultdb')",
                },
            },
            "required": ["container_name"],
        },
    ),
  • Registers the cosmosdb_container_delete tool (among others) by returning get_azure_tools() in the list_tools handler.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
        """List available Azure tools"""
        logger.debug("Handling list_tools request")
        return get_azure_tools()  # Use get_azure_tools
  • Dispatches cosmosdb_container_delete calls to the specific handle_cosmosdb_operations function based on name prefix.
    elif name.startswith("cosmosdb_"):  # Updated prefix to cosmosdb_
        return await handle_cosmosdb_operations(
            azure_rm, name, arguments
        )  # Use cosmosdb handler
  • Comprehensive handler function for all cosmosdb tools, including setup of cosmos_client and database, dispatch via if-elif chain, logging, and response formatting. The specific delete logic is included.
    async def handle_cosmosdb_operations(
        azure_rm: AzureResourceManager, name: str, arguments: dict
    ) -> list[TextContent]:
        """Handle Azure Cosmos DB operations (NoSQL API)"""
        cosmos_client = azure_rm.get_cosmos_client()
        logger.log(cosmos_client)
        database = cosmos_client.get_database_client(
            arguments.get("database_name", "SampleDB")
        )  # Assuming a default db
        response = None
    
        if name == "cosmosdb_container_create":  # Renamed from table to container
            container = database.create_container(
                id=arguments["container_name"], partition_key=arguments["partition_key"]
            )
            response = {"container_id": container.id, "created": True}
        elif name == "cosmosdb_container_describe":  # Renamed from table to container
            container = database.get_container_client(arguments["container_name"])
            container_properties = container.read()
            response = container_properties
        elif name == "cosmosdb_container_list":  # Renamed from table to container
            containers = list(database.list_containers())
            container_names = [c["id"] for c in containers]
            response = {"container_names": container_names}
        elif name == "cosmosdb_container_delete":  # Renamed from table to container
            database.delete_container(arguments["container_name"])
            response = {"container_name": arguments["container_name"], "deleted": True}
        elif (
            name == "cosmosdb_item_create"
        ):  # Renamed from put to create, and table to container
            container_client = database.get_container_client(
                arguments["container_name"]
            )
            item = container_client.create_item(body=arguments["item"])
            response = {"item_id": item["id"], "created": True}
        elif (
            name == "cosmosdb_item_read"
        ):  # Renamed from get to read, and table to container
            container_client = database.get_container_client(
                arguments["container_name"]
            )
            item = container_client.read_item(
                item=arguments["item_id"], partition_key=arguments["partition_key"]
            )
            response = item
        elif (
            name == "cosmosdb_item_replace"
        ):  # Renamed from update to replace, and table to container, using replace_item for full replace
            container_client = database.get_container_client(
                arguments["container_name"]
            )
            item = container_client.replace_item(
                item=arguments["item_id"], body=arguments["item"]
            )
            response = {"item_id": item["id"], "replaced": True}
        elif name == "cosmosdb_item_delete":  # Renamed table to container
            container_client = database.get_container_client(
                arguments["container_name"]
            )
            container_client.delete_item(
                item=arguments["item_id"], partition_key=arguments["partition_key"]
            )
            response = {"item_id": arguments["item_id"], "deleted": True}
        elif (
            name == "cosmosdb_item_query"
        ):  # Renamed table to container, simplified query
            container_client = database.get_container_client(
                arguments["container_name"]
            )
            items = list(
                container_client.query_items(
                    query=arguments["query"],
                    parameters=arguments.get("parameters", []),  # Optional parameters
                )
            )
            response = {"items": items}
        else:
            raise ValueError(f"Unknown Cosmos DB operation: {name}")
    
        azure_rm.log_operation(
            "cosmosdb", name.replace("cosmosdb_", ""), arguments
        )  # Update service name in log
        return [
            TextContent(
                type="text",
                text=f"Operation Result:\n{json.dumps(response, indent=2, default=custom_json_serializer)}",
            )
        ]
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Delete' implies a destructive mutation, it doesn't specify whether this action is irreversible, requires specific permissions, has side effects (e.g., data loss), or returns confirmation details. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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, direct sentence with no wasted words, making it highly concise and front-loaded. Every word ('Delete a Cosmos DB container') earns its place by clearly conveying the core action and target.

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 the tool's complexity (destructive operation with 2 parameters) and lack of annotations or output schema, the description is incomplete. It doesn't address critical aspects like return values, error conditions, or safety warnings, which are essential for an agent to use this tool correctly in context with its siblings.

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%, with clear descriptions for both parameters in the input schema. The description doesn't add any additional meaning beyond what the schema provides (e.g., it doesn't explain parameter interactions or constraints), so it meets the baseline score of 3 where the 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 ('Delete') and resource ('a Cosmos DB container'), making the purpose immediately understandable. However, it doesn't distinguish this tool from other delete operations like 'blob_container_delete' or 'cosmosdb_item_delete', which would require mentioning it specifically removes containers (not items or blobs) to achieve a perfect score.

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. Given sibling tools like 'cosmosdb_container_describe' (for inspection) and 'cosmosdb_item_delete' (for deleting items within containers), the description lacks context about prerequisites (e.g., ensure container is empty) or warnings about irreversible deletion, which are critical for a destructive operation.

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/mashriram/azure_mcp_server'

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