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
| Name | Required | Description | Default |
|---|---|---|---|
| indexName | Yes | Name of the index to update | |
| readCapacity | Yes | New read capacity units | |
| tableName | Yes | Name of the table | |
| writeCapacity | Yes | New write capacity units |
Implementation Reference
- src/index.ts:334-364 (handler)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}`, }; } }
- src/index.ts:94-107 (schema)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;