Skip to main content
Glama

cosmosdb_container_create

Create a new container in Azure Cosmos DB to store and organize data with a specified partition key for scalable performance.

Instructions

Create a new 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')
partition_keyYesPartition key definition for the container (e.g., {'paths': ['/partitionKey'], 'kind': 'Hash'})

Implementation Reference

  • Executes the cosmosdb_container_create tool by calling database.create_container with the provided container_name and partition_key.
    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}
  • Defines the input schema, description, and name for the cosmosdb_container_create tool.
    Tool(
        name="cosmosdb_container_create",  # Renamed from table to container
        description="Create a new 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')",
                },
                "partition_key": {
                    "type": "object",
                    "description": "Partition key definition for the container (e.g., {'paths': ['/partitionKey'], 'kind': 'Hash'})",
                },
            },
            "required": [
                "container_name",
                "partition_key",
            ],  # Partition key is usually required for Cosmos DB
        },
    ),
  • Registers the cosmosdb tools (including cosmosdb_container_create) by dispatching to handle_cosmosdb_operations in the call_tool handler.
    elif name.startswith("cosmosdb_"):  # Updated prefix to cosmosdb_
        return await handle_cosmosdb_operations(
            azure_rm, name, arguments
        )  # Use cosmosdb handler
  • Registers all Azure tools, including cosmosdb_container_create, via server.list_tools().
    @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
  • Helper function to create and cache the CosmosClient used in cosmosdb tool handlers.
    def get_cosmos_client(
        self,
        endpoint: str | None = None,
        key: str | None = None,
        url: str | None = None,
    ) -> CosmosClient:
        """Get an Azure Cosmos DB client."""
        try:
            logger.info(f"Creating CosmosClient for endpoint: {endpoint}")
            url = url or os.getenv("AZURE_COSMOSDB_URL")
            endpoint = endpoint or os.getenv("AZURE_COSMOSDB_ENDPOINT")
            key = key or os.getenv("AZURE_COSMOSDB_KEY")
            url = str(url)
            if not endpoint or not key:
                raise ValueError(
                    "Azure Cosmos DB Endpoint or Key is not specified and not set in the environment."
                )
    
            return CosmosClient(endpoint=endpoint, credential=key, url=url)
        except Exception as e:
            logger.error(f"Failed to create CosmosClient: {e}")
            raise RuntimeError(f"Failed to create CosmosClient: {e}")
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states this creates a new container but doesn't disclose critical traits like required permissions, whether it's idempotent, potential costs, rate limits, or what happens on failure. For a creation tool with zero annotation coverage, this leaves significant gaps in understanding the operation's behavior.

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 immediately scannable and efficient. Every word earns its place 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 creation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (e.g., success confirmation, container details), error conditions, or behavioral nuances like idempotency. For a tool that creates resources in a database system, more context is needed to use it effectively.

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 schema fully documents all three parameters (container_name, database_name, partition_key) with their types and descriptions. The description adds no additional parameter semantics beyond what's in the schema, which is acceptable given the high coverage, resulting in the baseline score of 3.

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 ('Cosmos DB container'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like cosmosdb_container_describe or cosmosdb_container_list, which would require mentioning this is specifically for creating new containers rather than describing or listing existing ones.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing database), when not to use it (e.g., if container already exists), or refer to sibling tools like cosmosdb_container_describe for checking existing containers first. The agent must infer usage from context alone.

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