mcp -motherduck
Local MCP server for DuckDB and MotherDuck
claude mcp add --transport stdio motherduckdb-mcp-server-motherduck uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases
How to use
This MCP server enables AI assistants and IDEs to query and manage DuckDB databases locally or against MotherDuck. It exposes tools to execute SQL read and write queries, inspect catalogs, list tables and columns, and switch between multiple database connections at runtime. The in-memory option is ideal for quick experimentation and development, while the local file option lets you work with existing DuckDB files. The MotherDuck option connects to MotherDuck using a token and provides read-write access to your MotherDuck databases, with the ability to switch between local and remote datasets during a session. You can invoke the server via uvx (Python/uv) and pass commands like --db-path, --read-write, and --allow-switch-databases to tailor access and capabilities per connection. All client tools expect a JSON-based MCP config, enabling seamless integration with IDEs, Claude/Codex, Cursor, VS Code, and other MCP clients. Use the Tools section to execute queries, enumerate databases, and explore schemas across attached data sources.
How to install
Prerequisites:
- Python 3.8+ and uv installed (pip install uv)
- Internet access to install Python packages if needed
- Optional: MotherDuck account and token for MotherDuck connections
- Install uv (Python UV) globally:
pip install uv
- Verify installation:
uv --version
- Ensure you have the MCP server package (mcp-server-motherduck) accessible in your PATH or project directory. The server is run via uvx as shown in the configuration.
- Prepare a DuckDB database (optional for local file path): create or locate a .duckdb file to connect to, or use an in-memory database with the dev/debug setup.
- If using MotherDuck, obtain a read-scaling token and set it via the environment variable motherduck_token in your MCP config or shell environment.
- Run your MCP config with your client, or start the MCP server locally by following your client’s instructions for loading an API config (the examples in this repo show the exact JSON blocks to paste into your client).
Additional notes
Tips and common issues:
- Read-only vs read-write: By default the server may run in read-only mode. Add --read-write to enable writes. For MotherDuck, ensure your token has appropriate permissions.
- Database paths: Use :memory: for in-memory operation. Use md: for MotherDuck connections. Absolute paths are required for local DuckDB files when using read-only mode.
- Switching databases at runtime: Include --allow-switch-databases where supported; this enables dynamic switching between connected databases without restarting the MCP server.
- Security: For production deployments, use proper authentication, tokens, and restricted file access. Consider MotherDuck Remote MCP for zero-setup deployments and SaaS-mode access control.
- Client compatibility: MCP results are returned as JSON and can be consumed by Claude, Codex, Cursor, VS Code, and other MCP clients. Ensure the client config matches the formats demonstrated in the Quick Start section of the README.
Related MCP Servers
mysql_mcp_server
A Model Context Protocol (MCP) server that enables secure interaction with MySQL databases
chunkhound
Local first codebase intelligence
edumcp
EDUMCP is a protocol that integrates the Model Context Protocol (MCP) with applications in the education field, dedicated to achieving seamless interconnection and interoperability among different AI models, educational applications, smart hardware, and teaching AGENTs.
lihil
2X faster ASGI web framework for python, offering high-level development, low-level performance.
MCP2Lambda
Run any AWS Lambda function as a Large Language Model (LLM) tool without code changes using Anthropic's Model Context Protocol (MCP).
EU_AI_ACT_MCP
EU AI Act MCP (Model Context Protocol) that connects to your AI agents, helping you to comply with the EU AI Act.