一个用于管理Amazon DynamoDB资源的模型上下文协议服务器。此服务器提供了表管理、容量管理和数据操作工具。
Iman Kamyabi (ikmyb@icloud.com)
注意:不支持删除操作以防止意外的数据丢失。
npm install
export AWS_ACCESS_KEY_ID="your_access_key"
export AWS_SECRET_ACCESS_KEY="your_secret_key"
export AWS_REGION="your_region"
npm run build
npm start
创建具有指定配置的新DynamoDB表。
参数:
tableName: 要创建的表名partitionKey: 分区键名称partitionKeyType: 分区键类型(S=字符串, N=数字, B=二进制)sortKey: (可选)排序键名称sortKeyType: (可选)排序键类型readCapacity: 预配置的读取容量单位writeCapacity: 预配置的写入容量单位示例:
{
"tableName": "Users",
"partitionKey": "userId",
"partitionKeyType": "S",
"readCapacity": 5,
"writeCapacity": 5
}
列出账户中的所有DynamoDB表。
参数:
limit: (可选)返回的最大表数exclusiveStartTableName: (可选)分页开始的表名示例:
{
"limit": 10
}
获取DynamoDB表的详细信息。
参数:
tableName: 要描述的表名示例:
{
"tableName": "Users"
}
在表上创建全局二级索引。
参数:
tableName: 表名indexName: 新索引名partitionKey: 索引的分区键partitionKeyType: 分区键类型sortKey: (可选)索引的排序键sortKeyType: (可选)排序键类型projectionType: 投影类型(ALL, KEYS_ONLY, INCLUDE)nonKeyAttributes: (可选)要投影的非键属性readCapacity: 预配置的读取容量单位writeCapacity: 预配置的写入容量单位示例:
{
"tableName": "Users",
"indexName": "EmailIndex",
"partitionKey": "email",
"partitionKeyType": "S",
"projectionType": "ALL",
"readCapacity": 5,
"writeCapacity": 5
}
更新全局二级索引的预配置容量。
参数:
tableName: 表名indexName: 要更新的索引名readCapacity: 新的读取容量单位writeCapacity: 新的写入容量单位示例:
{
"tableName": "Users",
"indexName": "EmailIndex",
"readCapacity": 10,
"writeCapacity": 10
}
在表上创建本地二级索引(必须在创建表时完成)。
参数:
tableName: 表名indexName: 新索引名partitionKey: 表的分区键partitionKeyType: 分区键类型sortKey: 索引的排序键sortKeyType: 排序键类型projectionType: 投影类型(ALL, KEYS_ONLY, INCLUDE)nonKeyAttributes: (可选)要投影的非键属性readCapacity: (可选)预配置的读取容量单位writeCapacity: (可选)预配置的写入容量单位示例:
{
"tableName": "Users",
"indexName": "CreatedAtIndex",
"partitionKey": "userId",
"partitionKeyType": "S",
"sortKey": "createdAt",
"sortKeyType": "N",
"projectionType": "ALL"
}
更新表的预配置容量。
参数:
tableName: 表名readCapacity: 新的读取容量单位writeCapacity: 新的写入容量单位示例:
{
"tableName": "Users",
"readCapacity": 10,
"writeCapacity": 10
}
在表中插入或替换项目。
参数:
tableName: 表名item: 要放入表中的项目(作为JSON对象)示例:
{
"tableName": "Users",
"item": {
"userId": "123",
"name": "John Doe",
"email": "john@example.com"
}
}
通过其主键从表中检索项目。
参数:
tableName: 表名key: 要检索的项目的主键示例:
{
"tableName": "Users",
"key": {
"userId": "123"
}
}
更新表中项目的特定属性。
参数:
tableName: 表名key: 要更新的项目的主键updateExpression: 更新表达式expressionAttributeNames: 属性名称映射expressionAttributeValues: 更新表达式的值conditionExpression: (可选)更新条件returnValues: (可选)要返回的值示例:
{
"tableName": "Users",
"key": {
"userId": "123"
},
"updateExpression": "SET #n = :name",
"expressionAttributeNames": {
"#n": "name"
},
"expressionAttributeValues": {
":name": "Jane Doe"
}
}
使用键条件和可选过滤器查询表。
参数:
tableName: 表名keyConditionExpression: 键条件表达式expressionAttributeValues: 键条件表达式的值expressionAttributeNames: (可选)属性名称映射filterExpression: (可选)结果的过滤表达式limit: (可选)返回的最大项目数示例:
{
"tableName": "Users",
"keyConditionExpression": "userId = :id",
"expressionAttributeValues": {
":id": "123"
}
}
使用可选过滤器扫描整个表。
参数:
tableName: 表名filterExpression: (可选)过滤表达式expressionAttributeValues: (可选)过滤表达式的值expressionAttributeNames: (可选)属性名称映射limit: (可选)返回的最大项目数示例:
{
"tableName": "Users",
"filterExpression": "age > :minAge",
"expressionAttributeValues": {
":minAge": 21
}
}
这里有一些你可以问Claude的问题,当你使用这个DynamoDB MCP服务器时:
将以下内容添加到你的claude_desktop_config.json中:
{
"mcpServers": {
"dynamodb": {
"command": "docker",
"args": [ "run", "-i", "--rm", "-e", "AWS_ACCESS_KEY_ID", "-e", "AWS_SECRET_ACCESS_KEY", "-e", "AWS_REGION", "-e", "AWS_SESSION_TOKEN", "mcp/dynamodb-mcp-server" ],
"env": {
"AWS_ACCESS_KEY_ID": "your_access_key",
"AWS_SECRET_ACCESS_KEY": "your_secret_key",
"AWS_REGION": "your_region",
"AWS_SESSION_TOKEN": "your_session_token"
}
}
}
}
Docker:
docker build -t mcp/dynamodb-mcp-server -f Dockerfile .
要在开发模式下运行并自动重新加载:
npm run dev
此MCP服务器根据MIT许可证发布。这意味着你可以自由地使用、修改和分发该软件,但需遵守MIT许可证的条款和条件。更多详情,请参见项目存储库中的LICENSE文件。