Skip to main content
Glama
robinong79

Azure Cosmos DB MCP Server

by robinong79

put_item

Insert or replace an item in an Azure Cosmos DB container by specifying the container name and the item details. Facilitates direct database interaction via natural language queries on the Azure Cosmos DB MCP Server.

Instructions

Inserts or replaces an item in a Azure Cosmos DB container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerNameYesName of the container
itemYesItem to insert into the container

Implementation Reference

  • The handler function that implements the put_item tool logic. It extracts the 'item' from params (note: ignores 'containerName' from schema, uses global container), creates the item in Cosmos DB using container.items.create(), and returns success status with the resource.
    async function putItem(params: any) {
      try {
        const { item } = params;
        const { resource } = await container.items.create(item);
    
        return {
          success: true,
          message: `Item added successfully to container`,
          item: resource,
        };
      } catch (error) {
        console.error("Error putting item:", error);
        return {
          success: false,
          message: `Failed to put item: ${error}`,
        };
      }
    }
  • Tool object defining the schema for put_item, including name, description, and inputSchema specifying containerName (string) and item (object).
    const PUT_ITEM_TOOL: Tool = {
      name: "put_item",
      description: "Inserts or replaces an item in a Azure Cosmos DB container",
      inputSchema: {
        type: "object",
        properties: {
          containerName: { type: "string", description: "Name of the  container" },
          item: { type: "object", description: "Item to insert into the container" },
        },
        required: ["containerName", "item"],
      },
    };
  • src/index.ts:177-179 (registration)
    Registers the put_item tool in the ListToolsRequestSchema handler by including PUT_ITEM_TOOL in the tools array.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [PUT_ITEM_TOOL, GET_ITEM_TOOL, QUERY_CONTAINER_TOOL, UPDATE_ITEM_TOOL],
    }));
  • src/index.ts:187-188 (registration)
    Dispatches to the putItem handler in the CallToolRequestSchema switch statement based on tool name "put_item".
    case "put_item":
      result = await putItem(args);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'inserts or replaces', hinting at mutation, but fails to detail critical aspects like required permissions, whether operations are idempotent, error handling for missing containers, or rate limits. This leaves significant gaps for safe and effective tool invocation.

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 that efficiently conveys the core action without unnecessary words. It is front-loaded with the key information, making it easy to parse quickly, which is ideal for concise tool descriptions.

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 complexity of a database mutation tool with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits (e.g., side effects, error responses), usage context relative to siblings, and return values, making it incomplete for reliable agent operation.

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?

The input schema has 100% description coverage, clearly documenting both parameters ('containerName' and 'item'). The description adds no additional semantic context beyond what the schema provides, such as format examples or constraints, so it meets the baseline for adequate but not enhanced parameter understanding.

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 ('Inserts or replaces') and the target resource ('an item in a Azure Cosmos DB container'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'update_item' (which might handle partial updates) or 'get_item' (which retrieves), leaving room for ambiguity in tool selection.

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 like 'update_item' or 'query_container'. It lacks context such as whether this is for new items only, overwriting existing ones, or handling conflicts, which could lead to misuse by an AI agent.

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

Related 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/robinong79/mcp-cosmos'

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