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;

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