motherduck-mcp
Enables executing SQL queries on DuckDB databases locally or on MotherDuck cloud, with support for multiple databases, read-only mode, and Claude Desktop integration.
README
MotherDuck MCP Server - Detailed Installation Guide This guide explains the step-by-step manual installation of the MotherDuck MCP Server on Windows.
📋 Table of Contents Requirements
Manual Installation
Configuration Options
Claude Desktop Integration
Usage Examples
Troubleshooting
🔧 Requirements System Requirements Operating System: Windows 10/11 (Linux and macOS also supported)
Python: Version 3.10 or higher (tested with 3.12.7)
Git: To clone the repository
Claude Desktop: Used as the MCP client
Python Packages duckdb==1.3.0
mcp>=1.9.4
python-dotenv
Other dependencies will be installed automatically
🚀 Manual Installation Step 1: Clone the Repository bash Copy Edit
Create the project directory
mkdir D:\AOT cd D:\AOT
Clone the repository
git clone https://github.com/motherduckdb/mcp-server-motherduck.git
Enter the project directory
cd mcp-server-motherduck Step 2: Create Python Virtual Environment bash Copy Edit
Create virtual environment
python -m venv venv
Activate (choose depending on your terminal):
For PowerShell:
.\venv\Scripts\Activate.ps1
For Command Prompt:
venv\Scripts\activate.bat
For Git Bash:
source venv/Scripts/activate Note: If you get an execution policy error in PowerShell:
powershell Copy Edit Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Step 3: Install Dependencies bash Copy Edit
Upgrade pip
python -m pip install --upgrade pip
Install the project and dependencies
pip install -e .
If python-dotenv is missing, install manually
pip install python-dotenv Step 4: Test the Installation bash Copy Edit
View help menu
mcp-server-motherduck --help
Test with an in-memory database
mcp-server-motherduck --db-path :memory: Expected output:
pgsql
Copy
Edit
[motherduck] INFO - 🦆 MotherDuck MCP Server v0.6.0
[motherduck] INFO - Ready to execute SQL queries via DuckDB/MotherDuck
[motherduck] INFO - Database client initialized in duckdb mode
[motherduck] INFO - ✅ Successfully connected to duckdb database
Use Ctrl+C to stop the test.
⚙️ Configuration Options
- In-Memory Database (Recommended for testing) json Copy Edit { "mcpServers": { "motherduck-local": { "command": "D:\AOT\mcp-server-motherduck\venv\Scripts\mcp-server-motherduck.exe", "args": [ "--db-path", ":memory:" ] } } }
- Local DuckDB File json Copy Edit { "mcpServers": { "motherduck-local": { "command": "D:\AOT\mcp-server-motherduck\venv\Scripts\mcp-server-motherduck.exe", "args": [ "--db-path", "D:\mydata\database.db" ] } } }
- MotherDuck Cloud First, create an account on MotherDuck and obtain your token.
json Copy Edit { "mcpServers": { "motherduck-cloud": { "command": "D:\AOT\mcp-server-motherduck\venv\Scripts\mcp-server-motherduck.exe", "args": [ "--db-path", "md:", "--motherduck-token", "YOUR_MOTHERDUCK_TOKEN_HERE" ] } } } 4. Read-Only Mode (for security) json Copy Edit { "mcpServers": { "motherduck-readonly": { "command": "D:\AOT\mcp-server-motherduck\venv\Scripts\mcp-server-motherduck.exe", "args": [ "--db-path", "database.db", "--read-only" ] } } } 🔌 Claude Desktop Integration Locate the Config File Windows: %APPDATA%\Claude\claude_desktop_config.json
Alternative: Claude Desktop → Settings → Developer → Edit Config
Integration Steps Exit Claude Desktop
Add one of the configurations above into the config file
Save the file
Restart Claude Desktop
Open a new chat and see your server in the MCP menu
Multiple Server Configuration json Copy Edit { "mcpServers": { "motherduck-local": { "command": "D:\AOT\mcp-server-motherduck\venv\Scripts\mcp-server-motherduck.exe", "args": ["--db-path", ":memory:"] }, "motherduck-cloud": { "command": "D:\AOT\mcp-server-motherduck\venv\Scripts\mcp-server-motherduck.exe", "args": [ "--db-path", "md:", "--motherduck-token", "YOUR_TOKEN" ] }, "motherduck-filedb": { "command": "D:\AOT\mcp-server-motherduck\venv\Scripts\mcp-server-motherduck.exe", "args": ["--db-path", "D:\databases\mydata.db"] } } } 💡 Usage Examples Basic SQL Operations sql Copy Edit -- Create table CREATE TABLE users ( id INTEGER PRIMARY KEY, name VARCHAR(100), email VARCHAR(100), signup_date DATE );
-- Insert data INSERT INTO users VALUES (1, 'Ahmet Yılmaz', 'ahmet@email.com', '2024-01-15'), (2, 'Ayşe Demir', 'ayse@email.com', '2024-02-20');
-- Query data SELECT * FROM users WHERE signup_date > '2024-01-01';
-- Aggregation SELECT COUNT(*) as total_users, DATE_TRUNC('month', signup_date) as month FROM users GROUP BY month; Load CSV File sql Copy Edit -- Load from CSV COPY sales FROM 'D:\data\sales.csv' (AUTO_DETECT TRUE);
-- Read Parquet file SELECT * FROM read_parquet('D:\data\big_data.parquet');
-- Read from S3 (MotherDuck Cloud) SELECT * FROM 's3://bucket-name/data/*.parquet'; Advanced Features sql Copy Edit -- Window functions SELECT name, sale_amount, ROW_NUMBER() OVER (ORDER BY sale_amount DESC) as rank FROM sales;
-- Using CTE WITH monthly_summary AS ( SELECT DATE_TRUNC('month', date) as month, SUM(amount) as total FROM sales GROUP BY 1 ) SELECT * FROM monthly_summary WHERE total > 10000; 🔍 Troubleshooting Problem: "No module named 'dotenv'" Solution:
bash Copy Edit pip uninstall python-dotenv -y pip install --force-reinstall python-dotenv Problem: "mcp-server-motherduck: command not found" Solution:
bash Copy Edit
Ensure venv is active
which python # Should point to venv directory
Alternative execution
python -m mcp_server_motherduck --db-path :memory: Problem: "Server Disconnected" in Claude Desktop Fixes:
Check for JSON syntax errors in the config file
Use double backslashes (\) in file paths
Ensure the venv path is correct
Restart Claude Desktop completely
Check logs under Developer → MCP Logs
Problem: PowerShell Execution Policy Solution:
powershell Copy Edit
Allow for current user
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Or temporary bypass
powershell -ExecutionPolicy Bypass -File ".\venv\Scripts\Activate.ps1" Problem: Invalid MotherDuck Token Fixes:
Make sure your token is valid
Enclose token in quotes
Generate a new token from MotherDuck Dashboard
📚 Additional Resources DuckDB Documentation
MotherDuck Documentation
MCP Protocol Specification
Project GitHub Page
🤝 Contributing Fork the project
Create a feature branch (git checkout -b feature/new-feature)
Commit your changes (git commit -am 'Added new feature')
Push the branch (git push origin feature/new-feature)
Open a Pull Request
📄 License This project is licensed under the MIT License. See the LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。