Skip to main content
Glama
DynamoDB Read-Only MCP

DynamoDB Read-Only MCP

by jjikky

DynamoDB 只读 MCP

npm 版本 铁匠徽章

一个利用模型上下文协议 (MCP) 查询 AWS DynamoDB 数据库的服务器。该服务器允许像 Claude 这样的法学硕士 (LLM) 通过自然语言请求查询 DynamoDB 数据。

特征

该 MCP 服务器提供以下功能:

  • 表管理工具:

    • list-tables :查看所有 DynamoDB 表的列表

    • describe-table :查看特定表的详细信息

  • 数据查询工具:

    • scan-table :扫描表的全部或部分数据

    • query-table :在表中搜索符合特定条件的数据

    • paginate-query-table :检索符合特定条件的跨页数据

    • get-item :检索具有特定键的项目

    • count-items :计算表中的项目数

  • 资源:

    • dynamodb-tables-info :为所有表提供元数据的资源

    • dynamodb-table-schema :提供特定表的架构信息的资源

  • 提示:

    • dynamodb-query-help :编写 DynamoDB 查询的帮助提示

Related MCP server: Azure Cosmos DB MCP Server

安装和执行

您可以使用下面的使用Run with NPX方法无需安装即可运行它。

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 DynamoDB 只读服务器:

npx -y @smithery/cli install @jjikky/dynamo-readonly-mcp --client claude

安装

  1. 克隆存储库:

    git clone https://github.com/jjikky/dynamo-readonly-mcp.git
    cd dynamo-readonly-mcp
  2. 安装所需的软件包:

    npm install
  3. 创建一个.env文件并设置您的 AWS 凭证:

    AWS_ACCESS_KEY_ID=your_access_key
    AWS_SECRET_ACCESS_KEY=your_secret_key
    AWS_REGION=your_region

构建并运行

npm run build
npm start

连接到 Claude 桌面

要将此 MCP 服务器与 Claude Desktop 一起使用,您需要修改 Claude Desktop 配置文件。

  1. 打开Claude桌面配置文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

    • Windows: %APPDATA%\Claude\claude_desktop_config.json

  2. 添加服务器配置如下:

    {
      "mcpServers": {
        "dynamodb-readonly": {
          "command": "node",
          "args": ["/absolute-path/dynamo-readonly-mcp/dist/index.js"],
          "env": {
            "AWS_ACCESS_KEY_ID": "your_access_key",
            "AWS_SECRET_ACCESS_KEY": "your_secret_key",
            "AWS_REGION": "your_region"
          }
        }
      }
    }
  3. 重新启动 Claude Desktop。

使用 NPX 运行

您还可以使用npx运行此服务器,而无需全局安装:

{
  "mcpServers": {
    "dynamodb-readonly": {
      "command": "npx",
      "args": ["-y", "dynamo-readonly-mcp"],
      "env": {
        "AWS_ACCESS_KEY_ID": "your_access_key",
        "AWS_SECRET_ACCESS_KEY": "your_secret_key",
        "AWS_REGION": "your_region"
      }
    }
  }
}

使用示例

您可以向 Claude 询问以下问题:

  1. “您能告诉我 DynamoDB 中有哪些表吗?”

  2. “解释用户表的结构”

  3. “在‘用户’表中查找 groupId 为‘0lxp4paxk7’ 的用户数量”


建筑学

该MCP服务器由以下分层结构组成:

  1. 客户端界面(Claude Desktop) - 用户与 LLM 之间的交互

  2. MCP协议层-提供标准化的消息交换方法

  3. DynamoDB 服务器- 实现与 DynamoDB 交互的功能

  4. AWS SDK - 与 AWS DynamoDB 服务通信

关键运行机制

1.初始化与连接

当服务器启动时,会发生以下过程:

async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error('DynamoDB read-only MCP server is running...');
}
  • StdioServerTransport通过标准输入/输出建立通信通道。

  • server.connect(transport)通过 MCP 协议连接到 Claude Desktop。

  • 在连接期间,服务器会向客户端发送有关支持的工具、资源和提示的信息。

2. 工具请求处理

当用户向 Claude 询问“显示 DynamoDB 表的列表”时:

  1. 克劳德分析了这个请求并调用了list-tables工具。

  2. 该请求通过MCP协议发送到服务器。

  3. 服务器执行相应的工具处理程序:

server.tool('list-tables', 'Gets a list of all DynamoDB tables', {}, async () => {
  try {
    const tables = await listTables();
    return {
      content: [{ type: 'text', text: JSON.stringify(tables, null, 2) }],
    };
  } catch (error) {
    return { isError: true, content: [{ type: 'text', text: `Error: ${error.message}` }] };
  }
});
  1. 将结果通过MCP协议返回给Claude。

  2. Claude 将此结果处理成自然语言并呈现给用户。

3. 具体参数处理

当用户请求“告诉我用户表的结构”时:

  1. Claude 确定此请求应该使用describe-table工具。

  2. Claude 将参数配置为{ tableName: "Users" } 。

  3. 此信息被发送到 MCP 服务器:

server.tool(
  'describe-table',
  'Gets detailed information about a DynamoDB table',
  {
    tableName: z.string().describe('Name of the table to get detailed information for'),
  },
  async ({ tableName }) => {
    // Query table information using the tableName parameter
    const tableInfo = await describeTable(tableName);
    // Return results
  }
);

这里, z.string()使用 Zod 库来验证参数。

4.资源处理

资源是另一个提供只读数据的 MCP 功能:

server.resource('dynamodb-tables-info', 'DynamoDB table information', async () => {
  // Create and return resource data
  const tables = await listTables();
  const tablesInfo = await Promise.all(/* Query table information */);

  return {
    contents: [
      {
        uri: 'dynamodb://tables-info',
        text: JSON.stringify(tablesInfo, null, 2),
        mimeType: 'application/json',
      },
    ],
  };
});

克劳德访问资源并将其用作上下文信息。

5. 及时处理

MCP服务器可以提供针对特定任务的提示模板:

server.prompt(
  'dynamodb-query-help',
  'A prompt that helps write DynamoDB queries',
  {
    tableName: z.string().describe('Table name to query'),
    queryType: z.enum(['basic', 'advanced']).default('basic'),
  },
  async ({ tableName, queryType }) => {
    // Generate prompt content
    return {
      messages: [
        {
          role: 'user',
          content: { type: 'text', text: helpContent },
        },
      ],
    };
  }
);

当用户请求“向我展示如何为用户表编写查询”时使用此提示。

数据流摘要

  1. 用户使用自然语言向 Claude 发出请求

  2. Claude 分析请求并选择适当的 MCP 工具/资源/提示

  3. MCP 客户端以标准格式向服务器发送请求

  4. 服务器处理请求并调用 AWS DynamoDB API

  5. DynamoDB 返回结果

  6. 服务器将结果转换为MCP格式并发送给客户端

  7. Claude 将结果处理成自然语言并呈现给用户

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

Available Tools

7 tools
count-itemsB

Count items in a DynamoDB table

Inputs: tableName (required), expressionAttributeValues, filterExpression.

describe-tableC

Get detailed information about a DynamoDB table

Inputs: tableName (required).

get-itemC

Get an item from a DynamoDB table based on a specific key

Inputs: key (required), tableName (required).

list-tablesB

Get a list of all DynamoDB tables

Inputs: no named parameters.

paginate-query-tableC

Paginate query results

Inputs: expressionAttributeValues (required), keyConditionExpression (required), tableName (required), projectionExpression.

query-tableC

Query items from a DynamoDB table based on conditions

Inputs: expressionAttributeValues (required), keyConditionExpression (required), tableName (required), filterExpression, +3 more.

scan-tableC

Scan items from a DynamoDB table

Inputs: tableName (required), expressionAttributeValues, filterExpression, limit, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 7 tools

    Disambiguation5/5

    Every tool has a clearly distinct purpose with no ambiguity: count-items focuses on counting, describe-table on metadata, get-item on single retrieval, list-tables on table enumeration, paginate-query-table on pagination, query-table on conditional queries, and scan-table on full scans. The descriptions clearly differentiate each tool's function, making misselection unlikely.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with hyphens (e.g., count-items, describe-table, get-item). There are no deviations in style or convention, making the naming predictable and easy to understand across the entire set.

    Tool Count5/5

    With 7 tools, the count is well-scoped for a read-only DynamoDB server, covering essential operations like listing, describing, retrieving, querying, scanning, and counting. Each tool earns its place without redundancy, fitting within the typical 3-15 range for focused server purposes.

    Completeness4/5

    The tool set provides comprehensive read-only coverage for DynamoDB, including table listing, metadata retrieval, item access, queries, scans, and pagination. A minor gap exists in not supporting batch operations like batch-get-item, but agents can work around this with existing tools, and the core read workflows are well-covered.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A server that enables interaction with PostgreSQL, MySQL, MariaDB, or SQLite databases through Claude Desktop using natural language queries.
      1
      -
    • A
      license
      B
      quality
      D
      maintenance
      A server that enables LLMs like Claude to interact with Azure Cosmos DB databases through natural language queries, acting as a translator between AI assistants and database systems.
      4
      3
      MIT
    • A
      license
      C
      quality
      C
      maintenance
      A server that enables LLMs (like Claude and VSCode Copilot) to interact with Azure Cosmos DB data through natural language queries, acting as a translator between AI assistants and your database.
      3
      21 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      This server provides database access capabilities to Claude, supporting SQLite, SQL Server, PostgreSQL, and MySQL databases.
      MIT