Skip to main content
Glama
imankamyabi

DynamoDB MCP Server

by imankamyabi

put_item

Inserts or replaces an item in a DynamoDB table using the specified table name and item details, ensuring data management without delete functionality.

Instructions

Inserts or replaces an item in a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemYesItem to put into the table
tableNameYesName of the table

Implementation Reference

  • The handler function that executes the 'put_item' tool. It marshals the provided item and sends a PutItemCommand to the DynamoDB client.
    async function putItem(params: any) {
      try {
        const command = new PutItemCommand({
          TableName: params.tableName,
          Item: marshall(params.item),
        });
        
        await dynamoClient.send(command);
        return {
          success: true,
          message: `Item added successfully to table ${params.tableName}`,
          item: params.item,
        };
      } catch (error) {
        console.error("Error putting item:", error);
        return {
          success: false,
          message: `Failed to put item: ${error}`,
        };
      }
  • Input schema for the 'put_item' tool, defining required parameters: tableName (string) and item (object).
    inputSchema: {
      type: "object",
      properties: {
        tableName: { type: "string", description: "Name of the table" },
        item: { type: "object", description: "Item to put into the table" },
      },
      required: ["tableName", "item"],
    },
  • src/index.ts:162-173 (registration)
    Definition of the PUT_ITEM_TOOL Tool object, which includes the name, description, and input schema for registration.
    const PUT_ITEM_TOOL: Tool = {
      name: "put_item",
      description: "Inserts or replaces an item in a table",
      inputSchema: {
        type: "object",
        properties: {
          tableName: { type: "string", description: "Name of the table" },
          item: { type: "object", description: "Item to put into the table" },
        },
        required: ["tableName", "item"],
      },
    };
  • src/index.ts:598-600 (registration)
    Registration of the 'put_item' tool (via PUT_ITEM_TOOL) in the ListToolsRequestHandler, listing it among available tools.
    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:629-631 (registration)
    Dispatch registration in the CallToolRequestHandler switch statement, which calls the putItem handler for the 'put_item' tool.
    case "put_item":
      result = await putItem(args);
      break;

Tool Definition Quality

Score is being calculated. Check back soon.

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