create_table
Design and configure new DynamoDB tables by specifying table name, partition key, sort key, and provisioned read/write capacity units through the DynamoDB MCP Server.
Instructions
Creates a new DynamoDB table with specified configuration
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| partitionKey | Yes | Name of the partition key | |
| partitionKeyType | Yes | Type of partition key (S=String, N=Number, B=Binary) | |
| readCapacity | Yes | Provisioned read capacity units | |
| sortKey | No | Name of the sort key (optional) | |
| sortKeyType | No | Type of sort key (optional) | |
| tableName | Yes | Name of the table to create | |
| writeCapacity | Yes | Provisioned write capacity units |
Implementation Reference
- src/index.ts:234-265 (handler)Executes the create_table tool by constructing a DynamoDB CreateTableCommand based on input parameters (table name, keys, capacity) and sending it to the client, returning success/error response.async function createTable(params: any) { try { const command = new CreateTableCommand({ TableName: params.tableName, AttributeDefinitions: [ { AttributeName: params.partitionKey, AttributeType: params.partitionKeyType }, ...(params.sortKey ? [{ AttributeName: params.sortKey, AttributeType: params.sortKeyType }] : []), ], KeySchema: [ { AttributeName: params.partitionKey, KeyType: "HASH" as const }, ...(params.sortKey ? [{ AttributeName: params.sortKey, KeyType: "RANGE" as const }] : []), ], ProvisionedThroughput: { ReadCapacityUnits: params.readCapacity, WriteCapacityUnits: params.writeCapacity, }, }); const response = await dynamoClient.send(command); return { success: true, message: `Table ${params.tableName} created successfully`, details: response.TableDescription, }; } catch (error) { console.error("Error creating table:", error); return { success: false, message: `Failed to create table: ${error}`, }; } }
- src/index.ts:46-58 (schema)Input schema definition for the create_table tool, validating parameters such as tableName, partitionKey, capacities, and optional sortKey.inputSchema: { type: "object", properties: { tableName: { type: "string", description: "Name of the table to create" }, partitionKey: { type: "string", description: "Name of the partition key" }, partitionKeyType: { type: "string", enum: ["S", "N", "B"], description: "Type of partition key (S=String, N=Number, B=Binary)" }, sortKey: { type: "string", description: "Name of the sort key (optional)" }, sortKeyType: { type: "string", enum: ["S", "N", "B"], description: "Type of sort key (optional)" }, readCapacity: { type: "number", description: "Provisioned read capacity units" }, writeCapacity: { type: "number", description: "Provisioned write capacity units" }, }, required: ["tableName", "partitionKey", "partitionKeyType", "readCapacity", "writeCapacity"], },
- src/index.ts:598-600 (registration)Registers the create_table tool (as CREATE_TABLE_TOOL) among the list of available tools served in response to ListToolsRequestSchema.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:608-610 (registration)Registers the handler dispatch for create_table tool calls within the CallToolRequestSchema switch statement.case "create_table": result = await createTable(args); break;