DynamoDB 读取-only 控制台是一个借助 DynamoDB 消息协议 (MCP) 实现的服务器。它能让像 Claude 这样的大语言模型(LLM)通过自然语言查询来访问 DynamoDB 数据。用户只需发送自然语言请求,就能实现对 DynamoDB 表的只读访问。
DynamoDB 读取-only 控制台允许大语言模型通过自然语言查询访问 DynamoDB 数据。以下是使用前的准备步骤:
使用 Git 克隆仓库:
git clone https://github.com/yourusername/dynamodb-read-only-console.git
进入项目目录后,安装所需依赖:
npm install
创建并编辑 .env
文件:
DYNAMODB_ENDPOINT=your-endpoint
DYNAMODB_REGION=your-region
构建项目:
npm run build
启动服务器:
npm start
在 clay.json
文件中添加以下配置,使 Claude 能够连接到您的 MCP 服务:
{
"mcp": {
"servers": [
{
"url": "http://localhost:3000",
"options": {
"keepalive": true,
"family": 4
}
}
]
}
}
list-tables
):返回所有 DynamoDB 表的信息。describe-table
):获取指定表的详细信息。table-exists
):验证指定表是否存在。query-table
):通过键条件表达式查询表数据。advanced-query
):支持复杂的过滤和排序操作。scan-table
):返回表中的所有项,可按条件筛选。dynamodb-tables-info
):提供所有表的元数据。dynamodb-table-schema
):返回指定表的 schema 信息。dynamodb-indexes-info
):列出表中的所有索引及其配置。dynamodb-query-help
):提供如何编写有效 DynamoDB 查询的指导。best-practices-tip
):推荐高效的数据访问策略。error-recovery-tip
):在出现错误时,提供建议的修复步骤。用户发送查询:
"显示所有的 DynamoDB 表"
Claude 调用 list-tables
工具,返回结果如下:
[
{
"TableName": "Users",
"TableStatus": "ACTIVE",
"CreationDateTime": "2023-10-01T12:00:00Z"
},
{
"TableName": "Orders",
"TableStatus": "ACTIVE",
"CreationDateTime": "2023-10-02T14:30:00Z"
}
]
用户发送查询:
"告诉我 Users 表的结构"
Claude 调用 describe-table
工具,传递参数 {tableName: "Users"}
,返回结果如下:
{
"TableName": "Users",
"TableStatus": "ACTIVE",
"KeySchema": [
{ "AttributeName": "Username", "KeyType": "HASH" },
{ "AttributeName": "UserId", "KeyType": " RANGE" }
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 5
}
}
用户发送查询:
"列出 Users 表中所有用户的用户名"
Claude 调用 scan-table
工具,传递过滤条件 { TableName: "Users", Filter: { Username: {"contains": "admin"} } }
,返回结果如下:
[
{ "Username": "admin123" },
{ "Username": "superuser" },
{ "Username": "administrator" }
]
query
, scan
)。本项目使用 MIT 许可证。请查看 LICENSE 文件获取详细信息。