databasesanalytics-data

MotherDuck & DuckDB

motherduckdb

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.

github stars

435

0 commentsdiscussion

Both formats append explainx.ai attribution and the canonical URL for this MCP server listing.

Works with local files and cloud databasesRead-only mode by default for securityAlternative to fully-managed remote option

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

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](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": "" } } } } ``` See [Command Line Parameters](#command-line-parameters) for more options, [Securing for Production](#securing-for-production) for deployment guidance, and [Troubleshooting](#troubleshooting) if you encounter issues. ## Client Setup | Client | Config Location | One-Click Install | |--------|-----------------|-------------------| | **Claude Desktop** | Settings → Developer → Edit Config | [.mcpb (MCP Bundle)](https://github.com/motherduckdb/mcp-server-motherduck/releases/latest/download/mcp-server-motherduck.mcpb) | | **Claude Code** | Use CLI commands below | - | | **Codex CLI** | Use CLI commands below | - | | **Cursor** | Settings → MCP → Add new global MCP server | [Install in Cursor](https://cursor.com/en/install-mcp?name=DuckDB&config=eyJjb21tYW5kIjoidXZ4IG1jcC1zZXJ2ZXItbW90aGVyZHVjayAtLWRiLXBhdGggOm1lbW9yeTogLS1yZWFkLXdyaXRlIC0tYWxsb3ctc3dpdGNoLWRhdGFiYXNlcyIsImVudiI6e319) | | **VS Code** | `Ctrl+Shift+P` → "Preferences: Open User Settings (JSON)" | [![Install with UV in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square)](https://insiders.vscode.dev/redirect/mcp/install?name=mcp-server-motherduck&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22mcp-server-motherduck%22%2C%22--db-path%22%2C%22%3Amemory%3A%22%2C%22--read-write%22%2C%22--allow-switch-databases%22%5D%7D) | Any MCP-compatible client can use this server. Add the JSON configuration from [Quick Start](#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 ```
## Tools | Tool | Description | Required Inputs | Optional Inputs | |------|-------------|-----------------|-----------------| | `execute_query` | Execute SQL query (DuckDB dialect) | `sql` | - | | `list_databases` | List all databases (useful for MotherDuck or multiple attached DBs) | - | - | | `list_tables` | List tables and views | - | `database`, `schema` | | `list_columns` | List columns of a table/view | `table` | `database`, `schema` | | `switch_database_connection`* | Switch to different database | `path` | `create_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](https://motherduck.com/docs/sql-reference/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](https://motherduck.com/docs/key-tasks/service-accounts-guide/)** with **[read-scaling tokens](https://motherduck.com/docs/key-tasks/authenticating-and-connecting-to-motherduck/read-scaling/#creating-a-read-scaling-token)** and enable **[SaaS mode](https://motherduck.com/docs/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/#authentication-using-saas-mode)** to restrict local file access. **Self-hosting DuckDB MCP:** Use `--init-sql` to apply security settings. See the [Securing DuckDB guide](https://duckdb.org/docs/stable/operations_manual/securing_duckdb/overview) for available options. ## Command Line Parameters | Parameter | Default | Description | |-----------|---------|-------------| | `--db-path` | `:memory:` | Database path: local file (absolute), `md:` (MotherDuck), or `s3://` URL | | `--motherduck-token` | `motherduck_token` env var | MotherDuck access token | | `--read-write` | `False` | Enable write access | | `--motherduck-saas-mode` | `False` | MotherDuck SaaS mode (restricts local access) | | `--allow-switch-databases` | `False` | Enable `switch_database_connection` tool | | `--max-rows` | `1024` | Max rows returned | | `--max-chars` | `50000` | Max characters returned | | `--query-timeout` | `-1` | Query timeout in seconds (-1 = disabled) | | `--init-sql` | `None` | SQL to execute on startup | | `--motherduck-connection-parameters` | `session_hint=mcp&`
`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 ---

FAQ

What is the MotherDuck & DuckDB MCP server?
MotherDuck & DuckDB is a Model Context Protocol (MCP) server profile on explainx.ai. MCP lets AI hosts (e.g. Claude Desktop, Cursor) call tools and resources through a standard interface; this page summarizes categories, install hints, and community ratings.
How do MCP servers relate to agent skills?
Skills are reusable instruction packages (often SKILL.md); MCP servers expose live capabilities. Teams frequently combine both—skills for workflows, MCP for APIs and data. See explainx.ai/skills and explainx.ai/mcp-servers for parallel directories.
How are reviews shown for MotherDuck & DuckDB?
This profile displays 27 aggregated ratings (sample rows for discoverability plus signed-in user reviews). Average score is about 4.5 out of 5—verify behavior in your own environment before production use.

Use Cases

Direct Database Queries from AI

Enable Claude to query your database directly using natural language

Example

Ask 'Show me top 10 customers by revenue this month' and get SQL results instantly

Eliminate manual SQL writing for ad-hoc queries, get insights 10x faster

Data Analysis & Reporting

Generate complex reports and analytics without leaving conversation

Example

Analyze sales trends, cohort retention, user behavior patterns conversationally

Democratize data access—non-technical team members can query databases

Schema Exploration

Understand database structure, relationships, and data models

Example

'Explain the user_orders table schema and its relationships'

Onboard engineers faster, explore unfamiliar databases efficiently

Data Validation & Quality Checks

Run data quality queries to catch anomalies and inconsistencies

Example

Find duplicate records, missing values, orphaned foreign keys automatically

Maintain data integrity with less manual SQL work

Implementation Guide

Prerequisites

  • Claude Desktop 0.7.0+ or Cursor with MCP support
  • Database credentials (read-only recommended for safety)
  • Network access from Claude client to database
  • Understanding of database security and access control

Time Estimate

15-30 minutes including configuration and testing

Installation Steps

  1. 1.Install MCP server: npm install -g @modelcontextprotocol/server-[name]
  2. 2.Configure database connection in Claude Desktop config (~/.claude/mcp.json)
  3. 3.Provide connection string: host, port, database, username, password
  4. 4.Restart Claude Desktop to load MCP server
  5. 5.Test connection: 'List all tables in database'
  6. 6.Run simple query: 'Show me 5 rows from users table'
  7. 7.Verify results and permissions are correct
  8. 8.Document query patterns for team use

Troubleshooting

  • Connection refused: Check database is running and network accessible
  • Authentication failed: Verify credentials, check user permissions
  • Claude can't see tables: Grant appropriate read permissions to database user
  • Slow queries: Add indexes, limit result set size, use read replicas
  • MCP server not loading: Check config syntax, restart Claude Desktop

Best Practices

✓ Do

  • +Use read-only database credentials to prevent accidental writes
  • +Connect to read replica, not production primary database
  • +Set query timeout limits to prevent long-running queries
  • +Document database schema and common queries for AI context
  • +Monitor query performance and optimize slow queries
  • +Use connection pooling for better performance
  • +Test with non-production data first

✗ Don't

  • Don't use production write credentials—risk of data corruption
  • Don't query production database during peak traffic hours
  • Don't expose sensitive PII without proper access controls
  • Don't skip query result validation—AI can misinterpret schema
  • Don't allow unlimited result set sizes—set LIMIT clauses
  • Don't share database credentials in plain text config files

💡 Pro Tips

  • Create database views for common queries to simplify AI access
  • Add schema comments/descriptions so AI understands column meanings
  • Use semantic table/column names ('customer_lifetime_value' not 'clv')
  • Set up query logging to audit what Claude is querying
  • Create saved query templates for recurring analysis
  • Combine with data visualization tools for better insights

Technical Details

Architecture

MCP server acts as bridge between Claude and database, translating natural language to SQL queries and returning results in structured format.

Protocols

  • Model Context Protocol (MCP)
  • Database-specific protocols (PostgreSQL, MySQL, MongoDB)

Compatibility

  • PostgreSQL
  • MySQL
  • SQLite
  • MongoDB
  • Redis

When to Use This

✓ Use When

Use for ad-hoc data queries, exploratory analysis, report generation, schema exploration, and democratizing data access. Best for read-heavy analytics workloads.

✗ Avoid When

Avoid for production write operations, mission-critical transactions, real-time OLTP workloads, or when database contains sensitive PII without proper access controls. Use read replicas, not primary.

Integration

  • Read replica connection for analytics queries
  • Database view layer to abstract complex joins
  • Query result caching for repeated questions
  • Audit logging of all AI-generated queries

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.

List & Promote Your MCP Server

Share your MCP server with the developer community

GET_STARTED →
MCP server reviews

Ratings

4.527 reviews
  • Jin Agarwal· Dec 8, 2024

    MotherDuck & DuckDB is a well-scoped MCP server in the explainx.ai directory — install snippets and categories matched our Claude Code setup.

  • Min Sanchez· Nov 27, 2024

    We wired MotherDuck & DuckDB into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.

  • Kiara Taylor· Oct 18, 2024

    According to our notes, MotherDuck & DuckDB benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.

  • Aditi Diallo· Sep 25, 2024

    MotherDuck & DuckDB is among the better-indexed MCP projects we tried; the explainx.ai summary tracks the official description.

  • Yash Thakker· Sep 21, 2024

    According to our notes, MotherDuck & DuckDB benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.

  • Amelia Bhatia· Sep 13, 2024

    Strong directory entry: MotherDuck & DuckDB surfaces stars and publisher context so we could sanity-check maintenance before adopting.

  • Aanya Gonzalez· Aug 16, 2024

    Strong directory entry: MotherDuck & DuckDB surfaces stars and publisher context so we could sanity-check maintenance before adopting.

  • Dhruvi Jain· Aug 12, 2024

    We wired MotherDuck & DuckDB into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.

  • Kabir Huang· Jul 23, 2024

    MotherDuck & DuckDB reduced integration guesswork — categories and install configs on the listing matched the upstream repo.

  • Hassan Anderson· Jul 15, 2024

    MotherDuck & DuckDB has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.

showing 1-10 of 27

1 / 3