Mcp Server Motherduck

io.github.motherduckdb由 GitHub 账号 motherduckdb 发布v1.1.0更新于 Oct 24, 2026

SQL analytics and data engineering for AI Assistants and IDEs

已验证STDIO仅桌面数据库数据与分析

概览

AI 生成的概览

本地 MCP 服务器,将 AI 助手连接到 DuckDB 和 MotherDuck,使其能执行分析型 SQL、浏览目录并切换数据库。

可以做什么
对 DuckDB 或 MotherDuck 执行 SQL 查询,启用后可包含读写语句,结果以 JSON 返回,默认受行数和字符数上限限制。浏览数据库目录,列出数据库、表和视图,以及某个表或视图的列。在启用切换标志时,将当前数据库连接切换到其他本地文件、S3 路径或 MotherDuck 数据库。可跨本地与远程数据库查询,并通过本地文件系统导入或导出数据。
适用场景
当助手需要用 DuckDB 的 SQL 引擎分析数据、处理本地 DuckDB 文件、内存数据库或 MotherDuck,或在 IDE 与聊天客户端中执行数据工程查询时使用。这是本地版本;另有托管的 MotherDuck 远程服务器可免安装使用。
运行要求
以 Python 包形式通过 uvx 在本地运行,需先安装 uv。通过参数指定数据库路径:内存、绝对路径的本地文件、s3:// 地址或 MotherDuck 的 md:。MotherDuck 需要令牌,可通过 motherduck_token 或 MOTHERDUCK_TOKEN 变量或令牌参数提供;S3 访问需要 AWS_ACCESS_KEY_ID、AWS_SECRET_ACCESS_KEY,可选 AWS_SESSION_TOKEN、AWS_DEFAULT_REGION 和 AWS_ENDPOINT。DuckDB 使用 HOME 存放扩展和配置。
安装前请注意
写入默认关闭,需用读写标志开启;内存开发配置被描述为没有防护措施,具备读写权限并可在运行时切换到任意数据库。README 警告,向第三方开放访问时仅只读模式并不足够,因为它仍允许访问本地文件系统和更改 DuckDB 设置。MotherDuck 令牌和 AWS 凭据属于机密,通过环境变量或参数传入。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Server Motherduck,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[MotherDuck / DuckDB Local MCP Server]

DuckDB / MotherDuck Local MCP Server

SQL analytics and data engineering for AI Assistants and IDEs.


Connect AI assistants to your data using DuckDB's powerful analytical SQL engine. Supports connecting to local DuckDB files, in-memory databases, S3-hosted databases, and MotherDuck. Allows executing SQL read- and write-queries, browsing database catalogs, and switching between different database connections on-the-fly.

Looking for a fully-managed remote MCP server for MotherDuck? → Go to the MotherDuck Remote MCP docs

Remote vs Local MCP

Remote MCPLocal MCP (this repo)
HostingHosted by MotherDuckRuns locally/self-hosted
SetupZero-setupRequires local installation
AccessRead-write supportedRead-write supported
Local filesystem-Query across local and remote databases, ingest data from / export data to local filesystem

Quick Start

Prerequisites: Install uv via pip install uv or brew install uv

Connecting to In-Memory DuckDB (Dev Mode)

json
{  "mcpServers": {    "DuckDB (in-memory, r/w)": {      "command": "uvx",      "args": ["mcp-server-motherduck", "--db-path", ":memory:", "--read-write", "--allow-switch-databases"]    }  }}

Full flexibility with no guardrails — read-write access and the ability to switch to any database (local files, S3, or MotherDuck) at runtime.

Connecting to a Local DuckDB File in Read-Only Mode

json
{  "mcpServers": {    "DuckDB (read-only)": {      "command": "uvx",      "args": ["mcp-server-motherduck", "--db-path", "/absolute/path/to/your.duckdb"]    }  }}

Connects to a specific DuckDB file in read-only mode. Won't hold on to the file lock, so convenient to use alongside a write connection to the same DuckDB file. You can also connect to remote DuckDB files on S3 using s3://bucket/path.duckdb — see Environment Variables for S3 authentication. If you're considering third-party access to the MCP, see Securing for Production.

Connecting to MotherDuck in Read-Write Mode

json
{  "mcpServers": {    "MotherDuck (local, r/w)": {      "command": "uvx",      "args": ["mcp-server-motherduck", "--db-path", "md:", "--read-write"],      "env": {        "motherduck_token": "<YOUR_MOTHERDUCK_TOKEN>"      }    }  }}

See Command Line Parameters for more options, Securing for Production for deployment guidance, and Troubleshooting if you encounter issues.

Client Setup

ClientConfig LocationOne-Click Install
Claude DesktopSettings → Developer → Edit Config.mcpb (MCP Bundle)
Claude CodeUse CLI commands below-
Codex CLIUse CLI commands below or ~/.codex/config.toml-
Gemini CLIUse CLI commands below or ~/.gemini/settings.json-
CursorSettings → MCP → Add new global MCP server[Install in Cursor]
VS CodeCtrl+Shift+P → "Preferences: Open User Settings (JSON)"[Install with UV in VS Code]
Kiro~/.kiro/settings/mcp.json (global) or .kiro/settings/mcp.json (project)[Add to Kiro]

Any MCP-compatible client can use this server. Add the JSON configuration from Quick Start to your client's MCP config file. Consult your client's documentation for the config file location.

Claude Code CLI commands

In-Memory DuckDB (Dev Mode):

bash
claude mcp add --scope user duckdb --transport stdio -- uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases

Local DuckDB (Read-Only):

bash
claude mcp add --scope user duckdb --transport stdio -- uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdb

MotherDuck (Read-Write):

bash
claude mcp add --scope user motherduck --transport stdio --env motherduck_token=YOUR_TOKEN -- uvx mcp-server-motherduck --db-path md: --read-write
Codex CLI commands

In-Memory DuckDB (Dev Mode):

bash
codex mcp add duckdb -- uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases

Local DuckDB (Read-Only):

bash
codex mcp add duckdb -- uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdb

MotherDuck (Read-Write):

bash
codex mcp add motherduck --env motherduck_token=YOUR_TOKEN -- uvx mcp-server-motherduck --db-path md: --read-write
Gemini CLI commands

In-Memory DuckDB (Dev Mode):

bash
gemini mcp add -s user duckdb uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases

Local DuckDB (Read-Only):

bash
gemini mcp add -s user duckdb uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdb

MotherDuck (Read-Write):

bash
gemini mcp add -s user -e motherduck_token=YOUR_TOKEN motherduck uvx mcp-server-motherduck --db-path md: --read-write
Kiro manual JSON config

Add the following to your Kiro MCP config file (~/.kiro/settings/mcp.json for global, or .kiro/settings/mcp.json for project-scoped). See the Kiro MCP documentation for more details.

In-Memory DuckDB (Dev Mode):

json
{  "mcpServers": {    "DuckDB (in-memory, r/w)": {      "command": "uvx",      "args": ["mcp-server-motherduck", "--db-path", ":memory:", "--read-write", "--allow-switch-databases"]    }  }}

MotherDuck (Read-Write):

json
{  "mcpServers": {    "MotherDuck (local, r/w)": {      "command": "uvx",      "args": ["mcp-server-motherduck", "--db-path", "md:", "--read-write"],      "env": {        "motherduck_token": "<YOUR_MOTHERDUCK_TOKEN>"      }    }  }}

Tools

ToolDescriptionRequired InputsOptional Inputs
execute_queryExecute SQL query (DuckDB dialect)sql-
list_databasesList all databases (useful for MotherDuck or multiple attached DBs)--
list_tablesList tables and views-database, schema
list_columnsList columns of a table/viewtabledatabase, schema
switch_database_connection*Switch to different databasepathcreate_if_not_exists

*Requires --allow-switch-databases flag

All tools return JSON. Results are limited to 1024 rows / 50,000 chars by default (configurable via --max-rows, --max-chars).

Securing for Production

When giving third parties access to a self-hosted MCP server, read-only mode alone is not sufficient — it still allows access to the local filesystem, changing DuckDB settings, and other potentially sensitive operations.

For production deployments with third-party access, we recommend MotherDuck Remote MCP — zero-setup, read-write capable, and hosted by MotherDuck.

Self-hosting MotherDuck MCP: Fork this repo and customize as needed. Use a service account with read-scaling tokens and enable SaaS mode to restrict local file access.

Self-hosting DuckDB MCP: Use --init-sql to apply security settings. See the Securing DuckDB guide for available options.

Docker

Build and run the server with Streamable HTTP on port 8000 (defaults to an in-memory DuckDB):

bash
docker build -t mcp-server-motherduck .docker run --rm -p 8000:8000 mcp-server-motherduck

Connect to MotherDuck by passing a token and overriding the command:

bash
docker run --rm -p 8000:8000 \  -e motherduck_token="$MOTHERDUCK_TOKEN" \  mcp-server-motherduck --transport http --db-path md:

The MCP endpoint is available at http://localhost:8000/mcp. CLI flags and env vars from below still apply.

Command Line Parameters

ParameterDefaultDescription
--db-path:memory:Database path: local file (absolute), md: (MotherDuck), or s3:// URL
--motherduck-tokenmotherduck_token env varMotherDuck access token
--read-writeFalseEnable write access
--motherduck-saas-modeFalseMotherDuck SaaS mode (restricts local access)
--allow-switch-databasesFalseEnable switch_database_connection tool
--max-rows1024Max rows returned
--max-chars50000Max characters returned
--query-timeout-1Query timeout in seconds (-1 = disabled)
--init-sqlNoneSQL to execute on startup
--motherduck-connection-parameterssession_hint=mcp&
dbinstance_inactivity_ttl=0s
Additional MotherDuck connection string parameters (key=value pairs separated by &)
--ephemeral-connectionsTrueUse temporary connections for read-only local files
--transportstdioTransport type: stdio or http
--stateless-httpFalseFor protocol compatibility only (e.g. with AWS Bedrock AgentCore Runtime). Server still maintains global state via the shared DatabaseClient.
--port8000Port for HTTP transport
--host127.0.0.1Host for HTTP transport

Environment Variables

VariableDescription
motherduck_token or MOTHERDUCK_TOKENMotherDuck access token (alternative to --motherduck-token)
HOMEUsed by DuckDB for extensions and config. Override with --home-dir if not set.
AWS_ACCESS_KEY_IDAWS access key for S3 database connections
AWS_SECRET_ACCESS_KEYAWS secret key for S3 database connections
AWS_SESSION_TOKENAWS session token for temporary credentials (IAM roles, SSO, EC2 instance profiles)
AWS_DEFAULT_REGIONAWS region for S3 connections
AWS_ENDPOINTAWS endpoint for S3 connections

Troubleshooting

  • spawn uvx ENOENT: Specify full path to uvx (run which uvx to find it)
  • File locked: Make sure --ephemeral-connections is turned on (default: true) and that you're not connected in read-write mode

Resources

Development

To run from source:

json
{  "mcpServers": {    "Local DuckDB (Dev)": {      "command": "uv",      "args": ["--directory", "/path/to/mcp-server-motherduck", "run", "mcp-server-motherduck", "--db-path", "md:"],      "env": {        "motherduck_token": "<YOUR_MOTHERDUCK_TOKEN>"      }    }  }}

Release Process

  1. Run the Release New Version GitHub Action
  2. Enter version in MAJOR.MINOR.PATCH format
  3. The workflow bumps version, publishes to PyPI/MCP registry, and creates the GitHub release with MCPB package

License

MIT License - see LICENSE file.

mcp-name: io.github.motherduckdb/mcp-server-motherduck

来源:README.md,提交 41acb58

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v1.1.0最新Oct 7, 2026
  2. v1.0.8Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分