Skip to main content
Glama
imankamyabi

DynamoDB MCP Server

by imankamyabi

update_item

Modify specific attributes of an item in a DynamoDB table using defined update expressions, attribute mappings, and values, with optional conditions and return options.

Instructions

Updates specific attributes of an item in a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conditionExpressionNoCondition for update (optional)
expressionAttributeNamesYesAttribute name mappings
expressionAttributeValuesYesValues for the update expression
keyYesPrimary key of the item to update
returnValuesNoWhat values to return
tableNameYesName of the table
updateExpressionYesUpdate expression (e.g., 'SET #n = :name')

Implementation Reference

  • The handler function that executes the 'update_item' tool logic by constructing and sending an UpdateItemCommand to DynamoDB.
    async function updateItem(params: any) {
      try {
        const command = new UpdateItemCommand({
          TableName: params.tableName,
          Key: marshall(params.key),
          UpdateExpression: params.updateExpression,
          ExpressionAttributeNames: params.expressionAttributeNames,
          ExpressionAttributeValues: marshall(params.expressionAttributeValues),
          ConditionExpression: params.conditionExpression,
          ReturnValues: params.returnValues || "NONE",
        });
        
        const response = await dynamoClient.send(command);
        return {
          success: true,
          message: `Item updated successfully in table ${params.tableName}`,
          attributes: response.Attributes ? unmarshall(response.Attributes) : null,
        };
      } catch (error) {
        console.error("Error updating item:", error);
        return {
          success: false,
          message: `Failed to update item: ${error}`,
        };
      }
    }
  • Input schema and metadata definition for the 'update_item' tool.
    const UPDATE_ITEM_TOOL: Tool = {
      name: "update_item",
      description: "Updates specific attributes of an item in a table",
      inputSchema: {
        type: "object",
        properties: {
          tableName: { type: "string", description: "Name of the table" },
          key: { type: "object", description: "Primary key of the item to update" },
          updateExpression: { type: "string", description: "Update expression (e.g., 'SET #n = :name')" },
          expressionAttributeNames: { type: "object", description: "Attribute name mappings" },
          expressionAttributeValues: { type: "object", description: "Values for the update expression" },
          conditionExpression: { type: "string", description: "Condition for update (optional)" },
          returnValues: { type: "string", enum: ["NONE", "ALL_OLD", "UPDATED_OLD", "ALL_NEW", "UPDATED_NEW"], description: "What values to return" },
        },
        required: ["tableName", "key", "updateExpression", "expressionAttributeNames", "expressionAttributeValues"],
      },
    };
  • src/index.ts:598-600 (registration)
    Registration of the 'update_item' tool (as UPDATE_ITEM_TOOL) in the listTools response.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [CREATE_TABLE_TOOL, UPDATE_CAPACITY_TOOL, PUT_ITEM_TOOL, GET_ITEM_TOOL, QUERY_TABLE_TOOL, SCAN_TABLE_TOOL, DESCRIBE_TABLE_TOOL, LIST_TABLES_TOOL, CREATE_GSI_TOOL, UPDATE_GSI_TOOL, CREATE_LSI_TOOL, UPDATE_ITEM_TOOL],
    }));
  • src/index.ts:623-625 (registration)
    Dispatch/registration of the 'update_item' tool handler in the CallToolRequest switch statement.
    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 the full burden of behavioral disclosure. It mentions 'Updates' which implies mutation, but fails to describe critical behaviors: whether this is idempotent, what happens if the item doesn't exist, what permissions are required, whether changes are reversible, or what the response format looks like. For a mutation tool with zero annotation coverage, this is a significant gap.

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 that gets straight to the point without any wasted words. It's appropriately sized for the tool's complexity and front-loads the core functionality.

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?

For a mutation tool with 7 parameters (including complex nested objects), no annotations, and no output schema, the description is inadequate. It doesn't explain the return values, error conditions, or the behavioral implications of the update operation. The agent would need to rely heavily on the schema alone, missing important contextual information about how this tool behaves in practice.

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 schema description coverage is 100%, so all parameters are documented in the schema itself. The description adds minimal value beyond what's in the schema - it mentions 'specific attributes' which aligns with the updateExpression parameter, but doesn't provide additional context about parameter relationships or usage patterns. The baseline of 3 is appropriate when 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 verb ('Updates') and resource ('specific attributes of an item in a table'), making the purpose understandable. However, it doesn't explicitly differentiate this from sibling tools like 'put_item' (which might create/replace items) or 'update_capacity' (which modifies table capacity), leaving some ambiguity about when to choose this specific update tool.

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' (for full item replacement) or 'update_capacity' (for table-level changes). It lacks context about prerequisites (e.g., requires existing item), exclusions, or typical scenarios, leaving the agent to infer usage from the tool name 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/imankamyabi/dynamodb-mcp-server'

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