MotherDuck & DuckDB▌

by motherduckdb
Integrates MotherDuck and local DuckDB for flexible querying and analysis of structured data in MCP-compatible environme
Integrates MotherDuck and local DuckDB databases for flexible querying and analysis of structured data in MCP-compatible environments.
best for
- / Data analysts querying structured datasets
- / SQL analytics through AI assistants
- / Data engineering workflows
- / Cross-database querying between local and cloud
capabilities
- / Execute SQL queries on DuckDB databases
- / Query local DuckDB files and in-memory databases
- / Connect to MotherDuck cloud databases
- / Access S3-hosted DuckDB databases
- / Switch between database connections
- / Browse database catalogs and schemas
what it does
Connects AI assistants to DuckDB databases (local, MotherDuck, or S3) for SQL analytics and data queries.
how to install
You can install MotherDuck & DuckDB in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
license
MIT
MotherDuck & DuckDB is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
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](https://motherduck.com/docs/sql-reference/mcp/) ### Remote vs Local MCP | | **[Remote MCP](https://motherduck.com/docs/sql-reference/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 | > 📝 **Migrating from v0.x?** > - **Read-only by default**: The server now runs in read-only mode by default. Add `--read-write` to enable write access. See [Securing for Production](#securing-for-production). > - **Default database changed**: `--db-path` default changed from `md:` to `:memory:`. Add `--db-path md:` explicitly for MotherDuck. > - **MotherDuck read-only requires read-scaling token**: MotherDuck connections in read-only mode require a [read-scaling token](https://motherduck.com/docs/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/#read-scaling-tokens). Regular tokens require `--read-write`. ## 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](#environment-variables) for S3 authentication. If you're considering third-party access to the MCP, see [Securing for Production](#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": "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 ````dbinstance_inactivity_ttl=0s` | Additional MotherDuck connection string parameters (`key=value` pairs separated by `&`) | | `--ephemeral-connections` | `True` | Use temporary connections for read-only local files | | `--transport` | `stdio` | Transport type: `stdio` or `http` | | `--stateless-http` | `False` | For protocol compatibility only (e.g. with [AWS Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-mcp-protocol-contract.html)). Server still maintains global state via the shared DatabaseClient. | | `--port` | `8000` | Port for HTTP transport | | `--host` | `127.0.0.1` | Host for HTTP transport | ## Environment Variables | Variable | Description | |----------|-------------| | `motherduck_token` or `MOTHERDUCK_TOKEN` | MotherDuck access token (alternative to `--motherduck-token`) | | `HOME` | Used by DuckDB for extensions and config. Override with `--home-dir` if not set. | | `AWS_ACCESS_KEY_ID` | AWS access key for S3 database connections | | `AWS_SECRET_ACCESS_KEY` | AWS secret key for S3 database connections | | `AWS_SESSION_TOKEN` | AWS session token for temporary credentials (IAM roles, SSO, EC2 instance profiles) | | `AWS_D ---