Skip to main content
Glama
imankamyabi

DynamoDB MCP Server

by imankamyabi

create_gsi

Add a global secondary index to a DynamoDB table by specifying the index name, partition key, projection type, and read/write capacities for optimized query performance.

Instructions

Creates a global secondary index on a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexNameYesName of the new index
nonKeyAttributesNoNon-key attributes to project (optional)
partitionKeyYesPartition key for the index
partitionKeyTypeYesType of partition key
projectionTypeYesType of projection
readCapacityYesProvisioned read capacity units
sortKeyNoSort key for the index (optional)
sortKeyTypeNoType of sort key (optional)
tableNameYesName of the table
writeCapacityYesProvisioned write capacity units

Implementation Reference

  • The handler function that implements the core logic of the 'create_gsi' tool by constructing and sending an UpdateTableCommand to DynamoDB to create a Global Secondary Index.
    async function createGSI(params: any) {
      try {
        const command = new UpdateTableCommand({
          TableName: params.tableName,
          AttributeDefinitions: [
            { AttributeName: params.partitionKey, AttributeType: params.partitionKeyType },
            ...(params.sortKey ? [{ AttributeName: params.sortKey, AttributeType: params.sortKeyType }] : []),
          ],
          GlobalSecondaryIndexUpdates: [
            {
              Create: {
                IndexName: params.indexName,
                KeySchema: [
                  { AttributeName: params.partitionKey, KeyType: "HASH" as const },
                  ...(params.sortKey ? [{ AttributeName: params.sortKey, KeyType: "RANGE" as const }] : []),
                ],
                Projection: {
                  ProjectionType: params.projectionType,
                  ...(params.projectionType === "INCLUDE" ? { NonKeyAttributes: params.nonKeyAttributes } : {}),
                },
                ProvisionedThroughput: {
                  ReadCapacityUnits: params.readCapacity,
                  WriteCapacityUnits: params.writeCapacity,
                },
              },
            },
          ],
        });
        
        const response = await dynamoClient.send(command);
        return {
          success: true,
          message: `GSI ${params.indexName} creation initiated on table ${params.tableName}`,
          details: response.TableDescription,
        };
      } catch (error) {
        console.error("Error creating GSI:", error);
        return {
          success: false,
          message: `Failed to create GSI: ${error}`,
        };
      }
    }
  • The tool object definition for 'create_gsi', including name, description, and detailed inputSchema for parameter validation.
    const CREATE_GSI_TOOL: Tool = {
      name: "create_gsi",
      description: "Creates a global secondary index on a table",
      inputSchema: {
        type: "object",
        properties: {
          tableName: { type: "string", description: "Name of the table" },
          indexName: { type: "string", description: "Name of the new index" },
          partitionKey: { type: "string", description: "Partition key for the index" },
          partitionKeyType: { type: "string", enum: ["S", "N", "B"], description: "Type of partition key" },
          sortKey: { type: "string", description: "Sort key for the index (optional)" },
          sortKeyType: { type: "string", enum: ["S", "N", "B"], description: "Type of sort key (optional)" },
          projectionType: { type: "string", enum: ["ALL", "KEYS_ONLY", "INCLUDE"], description: "Type of projection" },
          nonKeyAttributes: { type: "array", items: { type: "string" }, description: "Non-key attributes to project (optional)" },
          readCapacity: { type: "number", description: "Provisioned read capacity units" },
          writeCapacity: { type: "number", description: "Provisioned write capacity units" },
        },
        required: ["tableName", "indexName", "partitionKey", "partitionKeyType", "projectionType", "readCapacity", "writeCapacity"],
      },
    };
  • src/index.ts:598-600 (registration)
    Registers the CREATE_GSI_TOOL in the list of available tools served by the MCP server in response to 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:614-616 (registration)
    Dispatch/registration case in the CallToolRequestHandler switch statement that invokes the createGSI handler for the 'create_gsi' tool.
    case "create_gsi":
      result = await createGSI(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 but provides minimal information. It states this is a creation operation but doesn't mention whether this requires specific permissions, whether it's a synchronous or asynchronous operation, what happens if the index already exists, or any rate limits or costs associated. For a complex database operation with 10 parameters, this is inadequate behavioral context.

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 extremely concise - a single sentence that directly states the tool's purpose without any unnecessary words. It's front-loaded with the core action and resource. Every word earns its place, making this an excellent example of efficient communication.

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 complex database operation with 10 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what a global secondary index is, when one would use it, what the operation returns, or how it differs from local secondary indexes. The agent would need to infer too much from the bare description and parameter names alone.

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%, with all parameters well-documented in the input schema. The description adds no additional parameter information beyond what's already in the structured schema. According to the scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no parameter information in the description.

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 action ('creates') and resource ('global secondary index on a table'), making the purpose immediately understandable. However, it doesn't differentiate this from the sibling tool 'create_lsi' (local secondary index), which would be important context for an AI agent choosing between similar tools.

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 about when to use this tool versus alternatives. With sibling tools like 'create_lsi', 'create_table', and 'update_gsi' available, the agent receives no help in determining which tool is appropriate for different scenarios. There's no mention of prerequisites, constraints, or typical use cases.

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