Skip to main content
Glama
imankamyabi

DynamoDB MCP Server

by imankamyabi

create_lsi

Enables creation of a local secondary index during DynamoDB table setup, specifying keys, types, projection, and capacity units for efficient data querying.

Instructions

Creates a local secondary index on a table (must be done during table creation)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexNameYesName of the new index
nonKeyAttributesNoNon-key attributes to project (optional)
partitionKeyYesPartition key for the table
partitionKeyTypeYesType of partition key
projectionTypeYesType of projection
readCapacityNoProvisioned read capacity units (optional, default: 5)
sortKeyYesSort key for the index
sortKeyTypeYesType of sort key
tableNameYesName of the table
writeCapacityNoProvisioned write capacity units (optional, default: 5)

Implementation Reference

  • The handler function createLSI that executes the tool logic: creates a DynamoDB table with a local secondary index (LSI) using CreateTableCommand, since LSIs must be defined at table creation time.
    async function createLSI(params: any) {
      try {
        // Note: LSIs must be created during table creation, so we need the table's primary key info
        const command = new CreateTableCommand({
          TableName: params.tableName,
          AttributeDefinitions: [
            { AttributeName: params.partitionKey, AttributeType: params.partitionKeyType },
            { AttributeName: params.sortKey, AttributeType: params.sortKeyType },
          ],
          KeySchema: [
            { AttributeName: params.partitionKey, KeyType: "HASH" as const },
          ],
          LocalSecondaryIndexes: [
            {
              IndexName: params.indexName,
              KeySchema: [
                { AttributeName: params.partitionKey, KeyType: "HASH" as const },
                { AttributeName: params.sortKey, KeyType: "RANGE" as const },
              ],
              Projection: {
                ProjectionType: params.projectionType,
                ...(params.projectionType === "INCLUDE" ? { NonKeyAttributes: params.nonKeyAttributes } : {}),
              },
            },
          ],
          ProvisionedThroughput: {
            ReadCapacityUnits: params.readCapacity || 5,
            WriteCapacityUnits: params.writeCapacity || 5,
          },
        });
        
        const response = await dynamoClient.send(command);
        return {
          success: true,
          message: `LSI ${params.indexName} created on table ${params.tableName}`,
          details: response.TableDescription,
        };
      } catch (error) {
        console.error("Error creating LSI:", error);
        return {
          success: false,
          message: `Failed to create LSI: ${error}`,
        };
      }
    }
  • Tool definition including name, description, and input schema for validating parameters like tableName, indexName, keys, projection, etc.
    const CREATE_LSI_TOOL: Tool = {
      name: "create_lsi",
      description: "Creates a local secondary index on a table (must be done during table creation)",
      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 table" },
          partitionKeyType: { type: "string", enum: ["S", "N", "B"], description: "Type of partition key" },
          sortKey: { type: "string", description: "Sort key for the index" },
          sortKeyType: { type: "string", enum: ["S", "N", "B"], description: "Type of sort key" },
          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 (optional, default: 5)" },
          writeCapacity: { type: "number", description: "Provisioned write capacity units (optional, default: 5)" },
        },
        required: ["tableName", "indexName", "partitionKey", "partitionKeyType", "sortKey", "sortKeyType", "projectionType"],
      },
    };
  • src/index.ts:598-600 (registration)
    Registration of CREATE_LSI_TOOL in the list of available tools returned by ListToolsRequestSchema handler.
    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:620-622 (registration)
    Dispatch registration in the CallToolRequestSchema switch statement that maps 'create_lsi' to the createLSI handler.
    case "create_lsi":
      result = await createLSI(args);
      break;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a creation operation (implying mutation) and mentions a timing constraint, but lacks details on permissions required, whether the operation is reversible, error conditions, or what happens to existing data. For a complex 10-parameter mutation tool, this is inadequate.

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 a single, efficient sentence that states the core purpose and key constraint without unnecessary words. It's appropriately sized and front-loaded with the essential information.

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 index creation tool with 10 parameters, no annotations, and no output schema, the description is insufficient. It lacks information about what the tool returns, error handling, permissions needed, or how it interacts with sibling tools like 'create_table'. The timing constraint is helpful but doesn't compensate for other gaps.

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?

Schema description coverage is 100%, providing detailed documentation for all 10 parameters. The description adds no parameter-specific information beyond what's in the schema, so it meets the baseline of 3. However, it doesn't explain relationships between parameters (e.g., how projectionType relates to nonKeyAttributes).

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 a local secondary index') and the resource ('on a table'), with specific mention of the constraint 'must be done during table creation'. However, it doesn't explicitly differentiate from sibling 'create_gsi' (global secondary index), which is a closely related alternative.

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 a critical constraint ('must be done during table creation'), which implies when to use it, but offers no explicit guidance on when to choose this tool over alternatives like 'create_gsi' or 'create_table'. No prerequisites or exclusions are mentioned beyond the timing constraint.

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