DynamoDB MCP(管理控制台平面)服务器是一款与 AWS DynamoDB 交互的命令行工具。它可创建、删除和更新表,还能执行读写、查询和扫描等数据操作,让您轻松管理和操作 DynamoDB 数据库。
DynamoDB MCP 服务器为您提供便捷的方式来管理和操作 DynamoDB 数据库。您可以通过以下步骤快速上手。
使用以下命令拉取 Docker 镜像:
docker pull mcp/dynamodb-mcp-server
下载源代码,安装依赖项并进行构建。
创建一个简单的 DynamoDB 表:
create_table \
--table-name Users \
--key-schema KeySchema=[{KeyType=HASH, AttributeName=userId}, {KeyType=RANGE, AttributeName=timestamp}] \
--provisioned-throughput ReadCapacityUnits=5, WriteCapacityUnits=5
创建一个带有全局二级索引的表:
create_table \
--table-name Users \
--key-schema KeySchema=[{KeyType=HASH, AttributeName=userId}, {KeyType=RANGE, AttributeName=timestamp}] \
--provisioned-throughput ReadCapacityUnits=5, WriteCapacityUnits=5 \
--global-secondary-indexes GlobalSecondaryIndexes=[{
IndexName=UserByEmail,
KeySchema=[{KeyType=HASH, AttributeName=email}],
Projection=Projection=[{ProjectionType=ALL}],
ProvisionedThroughput=ProvisionedThroughput={ReadCapacityUnits=2, WriteCapacityUnits=2}
}]
删除指定名称的表:
delete_table --table-name Users
更新表的读写容量:
update_table \
--table-name Users \
--provisioned-throughput ReadCapacityUnits=10, WriteCapacityUnits=8
向表中插入一条记录:
put_item \
--table-name Users \
--item {userId: S=123, timestamp: N=1679000000, name: S=John Doe, email: S=john@example.com}
通过主键查询记录:
get_item \
--table-name Users \
--key {userId=S(123), timestamp=N(1679000000)}
更新指定条目的部分属性:
update_item \
--table-name Users \
--key {userId=S(123)} \
--update-expression "SET #n = :name" \
--expression-attribute-names "#n": name \
--expression-attribute-values ":name": Jane Doe
扫描整个表并返回所有记录:
scan_table --table-name Users
查看完整的命令列表,请运行 dynamodb-mcp-server help
。