Motherduck

Databases

SQL analytics and data engineering for AI Assistants and IDEs.

Your AI app calls the Motherduck MCP server, which does the databases work and sends the result back to the chat.

About Motherduck

Motherduck is the official MCP server from motherduckdb, filed in our directory under databases. SQL analytics and data engineering for AI Assistants and IDEs.

Motherduck runs on your own machine: your AI app starts it with the command uvx mcp-server-motherduck==1.1.1 and talks to it over standard input and output.

Motherduck is listed in the official MCP registry as io.github.motherduckdb/mcp-server-motherduck, version 1.1.1.

At a glance

Publisher
motherduckdb, the company behind the product
Runs
Locally on your machine
Install from
Python package on PyPI: mcp-server-motherduck
Written in
Python
License
MIT
GitHub stars
547
Official MCP registry
io.github.motherduckdb/mcp-server-motherduck

How to set up Motherduck

  1. Install uv on the machine that runs your AI app, because Motherduck starts with uvx and fetches its Python package on first run.
  2. Check the Motherduck README for keys or settings; the registry lists none that Motherduck requires.
  3. Add Motherduck to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Motherduck tools to confirm the connection.
  5. Run one read-only task with Motherduck first, and keep your app asking before each tool call until the results look right.

Motherduck compared with similar servers

  • PerformanceMonitor by erikdarlingdata has fewer GitHub stars than Motherduck (545 against 547); Motherduck is official while PerformanceMonitor is a community server, and both run locally.
  • Centralmind Gateway by centralmind has more GitHub stars than Motherduck (550 against 547); Motherduck is official while Centralmind Gateway is a community server, and both run locally.
  • Pgmcp by subnetmarco has fewer GitHub stars than Motherduck (544 against 547); Motherduck is official while Pgmcp is a community server, and both run locally.

Before you connect Motherduck

  • Give Motherduck its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Motherduck tool call until you trust what it does with them.
  • Treat text that Motherduck fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Motherduck on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Motherduck

How marketing and sales teams put Motherduck to work, by company size. Pick the size closest to yours and start Motherduck on one use case.

Small business

  • A small business with its own app can ask Motherduck plain questions about customers and orders, without writing SQL.
  • Owners can use Motherduck to pull a list of customers who haven't bought in 90 days and plan a win-back email.
  • Motherduck runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Marketing analysts can connect Motherduck to answer campaign questions from the warehouse directly, instead of waiting on the data team's queue.
  • Lifecycle teams can use Motherduck to build audience lists from product data and check counts before a send.
  • Start Motherduck on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises should point Motherduck at a read replica with a read-only role, so agents query freely without risk to production data.
  • Data teams can expose curated views through Motherduck, so marketing gets self-serve answers without access to raw customer tables.
  • Because Motherduck comes from motherduckdb, the company behind the product, it follows that product's own auth and permissions, which security teams usually prefer.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Motherduck README

From motherduckdb/mcp-server-motherduck on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

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": "<YOUR_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
Claude Desktop Settings → Developer → Edit Config .mcpb (MCP Bundle)
Claude Code Use CLI commands below -
Codex CLI Use CLI commands below or ~/.codex/config.toml -
Gemini CLI Use CLI commands below or ~/.gemini/settings.json -
Cursor Settings → MCP → Add new global MCP server
VS Code Ctrl+Shift+P → "Preferences: Open User Settings (JSON)"
Kiro ~/.kiro/settings/mcp.json (global) or .kiro/settings/mcp.json (project)

Any MCP-compatible client can use this server. Add the JSON configuration from 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):

claude mcp add --scope user duckdb --transport stdio -- uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases

Local DuckDB (Read-Only):

claude mcp add --scope user duckdb --transport stdio -- uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdb

MotherDuck (Read-Write):

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):

codex mcp add duckdb -- uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases

Local DuckDB (Read-Only):

codex mcp add duckdb -- uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdb

MotherDuck (Read-Write):

codex mcp add motherduck --env motherduck_token=YOUR_TOKEN -- uvx mcp-server-motherduck --db-path md: --read-write
Gemini CLI commands

In-Memory DuckDB (Dev Mode):

gemini mcp add -s user duckdb uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases

Local DuckDB (Read-Only):

gemini mcp add -s user duckdb uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdb

MotherDuck (Read-Write):

gemini mcp add -s user -e motherduck_token=YOUR_TOKEN motherduck uvx mcp-server-motherduck --db-path md: --read-write
Kiro manual JSON config

Add the following to your Kiro MCP config file (~/.kiro/settings/mcp.json for global, or .kiro/settings/mcp.json for project-scoped). See the Kiro MCP documentation for more details.

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"]
    }
  }
}

MotherDuck (Read-Write):

{
  "mcpServers": {
    "MotherDuck (local, r/w)": {
      "command": "uvx",
      "args": ["mcp-server-motherduck", "--db-path", "md:", "--read-write"],
      "env": {
        "motherduck_token": "<YOUR_MOTHERDUCK_TOKEN>"
      }
    }
  }
}

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, zero-setup, read-write capable, and hosted by MotherDuck.

Self-hosting MotherDuck MCP: Fork this repo and customize as needed. Use a service account with read-scaling tokens and enable SaaS mode to restrict local file access.

Self-hosting DuckDB MCP: Use --init-sql to apply security settings. See the Securing DuckDB guide for available options.

Docker

Build and run the server with Streamable HTTP on port 8000 (defaults to an in-memory DuckDB):

docker build -t mcp-server-motherduck .
docker run --rm -p 8000:8000 mcp-server-motherduck

Connect to MotherDuck by passing a token and overriding the command:

docker run --rm -p 8000:8000 \
  -e motherduck_token="$MOTHERDUCK_TOKEN" \
  mcp-server-motherduck --transport http --db-path md:

The MCP endpoint is available at http://localhost:8000/mcp. CLI flags and env vars from below still apply.

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). 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_DEFAULT_REGION AWS region for S3 connections
AWS_ENDPOINT AWS endpoint for S3 connections

Troubleshooting

  • spawn uvx ENOENT: Specify full path to uvx (run which uvx to find it)
  • File locked: Make sure --ephemeral-connections is turned on (default: true) and that you're not connected in read-write mode

Resources

Development

To run from source:

{
  "mcpServers": {
    "Local DuckDB (Dev)": {
      "command": "uv",
      "args": ["--directory", "/path/to/mcp-server-motherduck", "run", "mcp-server-motherduck", "--db-path", "md:"],
      "env": {
        "motherduck_token": "<YOUR_MOTHERDUCK_TOKEN>"
      }
    }
  }
}

Release Process

  1. Run the Release New Version GitHub Action
  2. Enter version in MAJOR.MINOR.PATCH format
  3. The workflow bumps version, publishes to PyPI/MCP registry, and creates the GitHub release with MCPB package

License

MIT License - see LICENSE file.

mcp-name: io.github.motherduckdb/mcp-server-motherduck

Questions about Motherduck

What is the Motherduck MCP server?

SQL analytics and data engineering for AI Assistants and IDEs. Motherduck is published by motherduckdb, the company behind the product, on GitHub at motherduckdb/mcp-server-motherduck, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Motherduck MCP server?

Add Motherduck to your AI app's MCP config with the command uvx mcp-server-motherduck==1.1.1. In Claude Code, run claude mcp add --transport stdio motherduck -- uvx mcp-server-motherduck==1.1.1. To run Motherduck this way you need uv installed.

Does Motherduck need an API key?

The registry lists no required keys for Motherduck. Check the Motherduck README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Motherduck an official MCP server?

Yes. Motherduck is published by motherduckdb, the company that makes the product it connects to, so it follows that product's own API and auth.

What license is Motherduck under?

Motherduck is released under the MIT license, according to its GitHub repository. The license covers the code of Motherduck; the service it connects to has its own terms.