Skip to main content
Glama
robinong79

Azure Cosmos DB MCP Server

by robinong79

update_item

Modify specific attributes of an item in an Azure Cosmos DB container by providing the container name, item ID, and updated attributes.

Instructions

Updates specific attributes of an item in a Azure Cosmos DB container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerNameYesName of the container
idYesID of the item to update
updatesYesThe updated attributes of the item

Implementation Reference

  • The core handler function for the update_item tool. It reads the existing item from the hardcoded Cosmos DB container, merges the provided updates (ignoring containerName), and replaces the item in the database, returning success or error details.
    async function updateItem(params: any) {
      try {
        const { id, updates } = params;
        const { resource } = await container.item(id).read();
        
        if (!resource) {
          throw new Error("Item not found");
        }
    
        const updatedItem = { ...resource, ...updates };
    
        const { resource: updatedResource } = await container.item(id).replace(updatedItem);
        return {
          success: true,
          message: `Item updated successfully`,
          item: updatedResource,
        };
      } catch (error) {
        console.error("Error updating item:", error);
        return {
          success: false,
          message: `Failed to update item: ${error}`,
        };
      }
    }
  • Defines the tool object for update_item, including its name, description, and input schema specifying containerName, id, and updates object.
    const UPDATE_ITEM_TOOL: Tool = {
      name: "update_item",
      description: "Updates specific attributes of an item in a Azure Cosmos DB container",
      inputSchema: {
        type: "object",
        properties: {
          containerName: { type: "string", description: "Name of the container" },
          id: { type: "string", description: "ID of the item to update" },
          updates: { type: "object", description: "The updated attributes of the item" },
        },
        required: ["containerName", "id", "updates"],
      },
    };
  • src/index.ts:177-179 (registration)
    Registers the update_item tool in the ListToolsRequestHandler by including UPDATE_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:196-198 (registration)
    In the CallToolRequestHandler, the switch statement maps the 'update_item' tool name to invoke the updateItem handler function.
    case "update_item":
      result = await updateItem(args);
      break;
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 only states it updates attributes without disclosing key behavioral traits. It doesn't mention whether this is a partial or full update, if it requires specific permissions, what happens on failure, or if there are rate limits. The description is minimal and lacks critical operational context for a mutation tool.

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, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word contributes directly to the tool's purpose 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 the complexity of a database update operation with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, or behavioral nuances (e.g., concurrency, atomicity). For a mutation tool in a database context, this leaves significant gaps in understanding.

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 already documents all three parameters (containerName, id, updates) adequately. The description adds no additional meaning beyond implying 'updates' modifies attributes, which is redundant with the schema. This meets the baseline for high schema coverage.

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 ('Updates') and resource ('specific attributes of an item in a Azure Cosmos DB container'), making the purpose understandable. It distinguishes from siblings like 'get_item' (read) and 'put_item' (create/replace), but doesn't explicitly differentiate from 'query_container' (which likely searches rather than updates).

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 'put_item' or 'query_container'. It mentions updating attributes but doesn't specify prerequisites (e.g., item must exist) or exclusions (e.g., not for bulk updates), leaving the agent to 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

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