
DuckDB 和 MotherDuck 的本地 MCP 服务器
概览
为AI助手和IDE提供SQL分析和数据工程。 利用DuckDB强大的分析SQL引擎,将AI助手连接到您的数据。支持连接本地DuckDB文件、内存数据库、S3托管数据库和MotherDuck。支持执行SQL读写查询、浏览数据库目录,并在不同数据库连接间实时切换。 📝 - : 服务器默认以只读模式运行。添加 --read-write 以启用写权限。参见生产保护。- : --db-path 默认从 md: 改为 :memory: 。为 MotherDuck 添加 --db-path md: 。- : MotherDuck 连接在只读模式下需要读取缩放令牌。普通令牌需要 --read-write。 : 通过 pip 安装 uv 安装 uv 或 brew 安装 uv 完全灵活且无限制——可读写访问,运行时可切换到任意数据库(本地文件、S3或MotherDuck)。 以只读模式连接特定的DuckDB文件。
概述(AI 翻译)
DuckDB / MotherDuck 本地 MCP 服务器
为AI助手和IDE提供SQL分析和数据工程。
利用DuckDB强大的分析SQL引擎,将AI助手连接到您的数据。支持连接本地DuckDB文件、内存数据库、S3托管数据库和MotherDuck。支持执行SQL读写查询、浏览数据库目录,并在不同数据库连接间实时切换。
正在寻找MotherDuck的全托管远程MCP服务器? → 访问MotherDuck远程MCP文档
远程与本地MCP
| 远程MCP | 本地MCP(本仓库) | |
|---|---|---|
| 主机 | 由MotherDuck托管 | 本地/自托管 |
| 设置 | 零设置 | 需要本地安装 |
| 访问支持读写 | 支持读写 | |
| 本地文件系统 | - | 跨本地和远程数据库查询,从/导出数据到本地文件系统 |
快速启动
前提条件:通过pip install uv或[[T2]安装uv
连接内存中的DuckDB(开发模式)
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
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 MCP | Local MCP (this repo) | |
|---|---|---|
| Hosting | Hosted by MotherDuck | Runs locally/self-hosted |
| Setup | Zero-setup | Requires local installation |
| Access | Read-write supported | Read-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)
{
"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
{
"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
{
"mcpServers": {
"MotherDuck (local, r/w)": {
"command": "uvx",
"args": ["mcp-server-motherduck", "--db-path", "md:", "--read-write"],
"env": {
"motherduck_token": ""
}
}
}
}
See Command Line Parameters for more options, Securing for Production for deployment guidance, and Troubleshooting if you encounter issues.
Client Setup
| Client | Config Location | One-Click Install |
安装
uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases配置
{
"mcpServers": {
"DuckDB (in-memory, r/w)": {
"command": "uvx",
"args": ["mcp-server-motherduck", "--db-path", ":memory:", "--read-write", "--allow-switch-databases"]
}
}
}