mcp-server-motherduck

Official

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Allows access to data stored in Amazon S3 through MotherDuck's cloud storage integrations

  • Integrates with local DuckDB to provide SQL analytics capabilities and allow querying data from local databases

MotherDuck MCP 服务器

集成 MotherDuck 和本地 DuckDB 的 MCP 服务器实现,为 Claude 提供 SQL 分析功能。

特征

  • 混合执行:从基于云的 MotherDuck 和本地 DuckDB 查询数据
  • 云存储集成:借助 MotherDuck 的集成,可以访问存储在 Amazon S3 或其他云存储中的数据
  • 数据共享:创建和共享数据库
  • SQL 分析:使用 DuckDB 的 SQL 方言直接从 Claude 查询任意大小的数据
  • 无服务器架构:无需配置实例或集群即可运行分析

成分

提示

服务器提供一个提示:

  • duckdb-motherduck-initial-prompt :提示初始化与 DuckDB 或 MotherDuck 的连接并开始使用它

工具

该服务器提供了一个工具:

  • query :在 MotherDuck/DuckDB 数据库上执行 SQL 查询
    • 输入
      • query (字符串,必需):要执行的 SQL 查询

与 DuckDB 和 MotherDuck 的所有交互都是通过编写 SQL 查询完成的。

入门

先决条件

  • MotherDuck 帐户(在motherduck.com注册)
  • MotherDuck 访问令牌
  • uv已安装,您可以使用pip install uvbrew install uv

如果您计划将 MotherDuck MCP 与 Claude Desktop 一起使用,您还需要安装 Claude Desktop。

设置你的 MotherDuck 代币

  1. 注册MotherDuck 账户
  2. 通过MotherDuck UI生成访问令牌
  3. 安全存储令牌以便在配置中使用

与 Claude Desktop 一起使用

  1. 如果你还没有安装 Claude Desktop,请从claude.ai/download安装
  2. 打开Claude桌面配置文件:
  • 要快速访问它或首次创建它,请打开 Claude Desktop 应用程序,选择“设置”,然后单击“开发人员”选项卡,最后单击“编辑配置”按钮。
  • 将以下配置添加到您的claude_desktop_config.json
{ "mcpServers": { "mcp-server-motherduck": { "command": "uvx", "args": [ "mcp-server-motherduck", "--db-path", "md:", "--motherduck-token", "<YOUR_MOTHERDUCK_TOKEN_HERE>" ], } } }

重要提示

  • YOUR_MOTHERDUCK_TOKEN_HERE替换为你的实际 MotherDuck 令牌
  • YOUR_HOME_FOLDER_PATH替换为你的主目录路径(DuckDB 需要用到它来操作文件)。例如,在 macOS 上,该路径为/Users/your_username
  • DuckDB 需要HOME环境变量才能正常运行。

示例查询

配置完成后,您可以要求 Claude 运行如下查询:

  • “在 MotherDuck 中创建一个新的数据库和表”
  • “从我的本地 CSV 文件查询数据”
  • “将本地 DuckDB 数据库中的数据与 MotherDuck 中的表连接起来”
  • “分析存储在 Amazon S3 中的数据”

测试

该服务器设计为由 Claude Desktop 和 Cursor 等工具运行,但您可以手动启动它进行测试。手动测试服务器时,可以使用--db-path参数指定要连接的数据库:

  1. 默认 MotherDuck 数据库
    • 要连接到默认的 MotherDuck 数据库,您需要使用--motherduck-token参数传递身份验证令牌。
    uvx mcp-server-motherduck --db-path md: --motherduck-token <your_motherduck_token>
  2. 具体的 MotherDuck 数据库
    uvx mcp-server-motherduck --db-path md:your_database_name --motherduck-token <your_motherduck_token>
  3. 本地 DuckDB 数据库
    uvx mcp-server-motherduck --db-path /path/to/your/local.db
  4. 内存数据库
    uvx mcp-server-motherduck --db-path :memory:

如果您未指定数据库路径但设置了motherduck_token环境变量,则服务器将自动连接到默认的 MotherDuck 数据库 ( md: )。

以 SSE 模式运行

服务器还可以通过运行以下命令使用supergateway以 SSE 模式运行:

npx -y supergateway --stdio "uvx mcp-server-motherduck --db-path md: --motherduck-token <your_motherduck_token>"

您可以将您的客户端(例如 Claude Desktop、Cursor)指向此端点。

故障排除

  • 如果遇到连接问题,请验证您的 MotherDuck 令牌是否正确
  • 对于本地文件访问问题,请确保--home-dir参数设置正确
  • 检查uvx命令是否在你的 PATH 中可用
  • 如果遇到spawn uvx ENOENT错误,请尝试指定uvx的完整路径( which uvx的输出)
  • 在之前的 v0.4.0 版本中我们使用环境变量,现在我们使用参数

执照

此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。

ID: 15mdwrzibz