Skip to main content
Glama
imankamyabi

DynamoDB MCP Server

by imankamyabi

update_gsi

Update the read and write capacity units of a DynamoDB global secondary index by specifying the table name, index name, and desired provisioned throughput.

Instructions

Updates the provisioned capacity of a global secondary index

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexNameYesName of the index to update
readCapacityYesNew read capacity units
tableNameYesName of the table
writeCapacityYesNew write capacity units

Implementation Reference

  • The main handler function that implements the update_gsi tool logic by sending an UpdateTableCommand to update the provisioned throughput of a Global Secondary Index (GSI).
    async function updateGSI(params: any) {
      try {
        const command = new UpdateTableCommand({
          TableName: params.tableName,
          GlobalSecondaryIndexUpdates: [
            {
              Update: {
                IndexName: params.indexName,
                ProvisionedThroughput: {
                  ReadCapacityUnits: params.readCapacity,
                  WriteCapacityUnits: params.writeCapacity,
                },
              },
            },
          ],
        });
        
        const response = await dynamoClient.send(command);
        return {
          success: true,
          message: `GSI ${params.indexName} capacity updated on table ${params.tableName}`,
          details: response.TableDescription,
        };
      } catch (error) {
        console.error("Error updating GSI:", error);
        return {
          success: false,
          message: `Failed to update GSI: ${error}`,
        };
      }
    }
  • The Tool object definition for 'update_gsi', including the input schema for validation.
    const UPDATE_GSI_TOOL: Tool = {
      name: "update_gsi",
      description: "Updates the provisioned capacity of a global secondary index",
      inputSchema: {
        type: "object",
        properties: {
          tableName: { type: "string", description: "Name of the table" },
          indexName: { type: "string", description: "Name of the index to update" },
          readCapacity: { type: "number", description: "New read capacity units" },
          writeCapacity: { type: "number", description: "New write capacity units" },
        },
        required: ["tableName", "indexName", "readCapacity", "writeCapacity"],
      },
    };
  • src/index.ts:598-600 (registration)
    Registration of the update_gsi tool (as UPDATE_GSI_TOOL) in the list of available tools returned by ListToolsRequest.
    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:617-619 (registration)
    Switch case in the CallToolRequest handler that dispatches 'update_gsi' calls to the updateGSI function.
    case "update_gsi":
      result = await updateGSI(args);
      break;
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