PluginBench
MCP Server
Active
MIT

io.github.motherduckdb/mcp-server-motherduck MCP Server

io.github.motherduckdb/mcp-server-motherduck

Execute SQL queries and manage data across DuckDB, MotherDuck, and S3 from your AI assistant.

What is the io.github.motherduckdb/mcp-server-motherduck MCP server?

The MotherDuck MCP Server is a local MCP server that connects AI assistants to DuckDB's analytical SQL engine, supporting local files, in-memory databases, S3-hosted data, and MotherDuck cloud. It enables executing SQL queries, browsing database catalogs, and switching between database connections on-the-fly.

This server gives Claude, Cursor, and other AI assistants direct access to DuckDB and MotherDuck for SQL analytics and data engineering. You can query local DuckDB files, in-memory databases, S3 data, or MotherDuck, with optional read-write access. It's useful for data exploration, transformation, and analysis within your AI workflow.

How to install io.github.motherduckdb/mcp-server-motherduck

Copy-paste configuration for popular MCP clients.

transport: stdio
Config generated by PluginBench — verify against the source before use.
Environment / auth
  • motherduck_token
    secret

    Access token for MotherDuck connections (alternative to --motherduck-token)

  • MOTHERDUCK_TOKEN
    secret

    Access token for MotherDuck connections (alternative to --motherduck-token)

  • HOME

    Used by DuckDB for extensions and config. Override with --home-dir if not set.

  • AWS_ACCESS_KEY_ID
    secret

    AWS access key for S3 database connections

  • AWS_SECRET_ACCESS_KEY
    secret

    AWS secret access key for S3 database connections

  • AWS_SESSION_TOKEN
    secret

    AWS session token for temporary credentials

  • AWS_DEFAULT_REGION

    AWS region for S3 database connections

  • AWS_ENDPOINT

    AWS endpoint for S3 database connections

~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--transport",
        "--port",
        "--host",
        "--db-path",
        "--motherduck-token",
        "--read-write",
        "--allow-switch-databases",
        "--motherduck-saas-mode",
        "--init-sql",
        "--home-dir",
        "--max-rows",
        "--max-chars",
        "--query-timeout",
        "--ephemeral-connections"
      ],
      "env": {
        "motherduck_token": "<YOUR_MOTHERDUCK_TOKEN>",
        "MOTHERDUCK_TOKEN": "<YOUR_MOTHERDUCK_TOKEN>",
        "HOME": "<YOUR_HOME>",
        "AWS_ACCESS_KEY_ID": "<YOUR_AWS_ACCESS_KEY_ID>",
        "AWS_SECRET_ACCESS_KEY": "<YOUR_AWS_SECRET_ACCESS_KEY>",
        "AWS_SESSION_TOKEN": "<YOUR_AWS_SESSION_TOKEN>",
        "AWS_DEFAULT_REGION": "<YOUR_AWS_DEFAULT_REGION>",
        "AWS_ENDPOINT": "<YOUR_AWS_ENDPOINT>"
      }
    }
  }
}

Tools & capabilities

Tools this server exposes to the agent.

  • execute_query — Execute SQL queries using DuckDB dialect
  • list_databases — List all available databases (useful for MotherDuck or multiple attached databases)
  • list_tables — List tables and views in a database or schema
  • list_columns — List columns of a specific table or view
  • switch_database_connection — Switch to a different database connection (requires --allow-switch-databases flag)

Use cases

  • Query and analyze data in local DuckDB files or MotherDuck from your AI assistant
  • Transform and prepare data using SQL while chatting with Claude or Cursor
  • Explore database schemas and table structures interactively
  • Ingest data from local filesystem or S3 and export results back
  • Build data pipelines by combining SQL queries with AI-assisted data engineering

io.github.motherduckdb/mcp-server-motherduck MCP server FAQ

What is the MotherDuck MCP Server?

It's a local MCP server that connects AI assistants like Claude and Cursor to DuckDB and MotherDuck for SQL analytics. You can query local files, in-memory databases, S3 data, or MotherDuck cloud.

Is it free?

Yes, the server itself is free and open-source (MIT License). MotherDuck cloud services have their own pricing, but you can use it with free local DuckDB files.

How do I install it in Cursor?

Go to Settings → MCP → Add new global MCP server, then use the configuration with `uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases`. Alternatively, use the one-click Cursor install button from the GitHub repo.

How do I install it in Claude Desktop?

Edit your Claude Desktop config file (Settings → Developer → Edit Config) and add the MCP server configuration. You can also download the .mcpb bundle from the GitHub releases page.

Do I need authentication?

For local DuckDB files, no authentication is needed. For MotherDuck, you need a MotherDuck token, which you pass via the `motherduck_token` environment variable or `--motherduck-token` flag.

Can I use it in read-only mode?

Yes, read-only mode is the default. Add `--read-write` to enable write access. For MotherDuck in read-only mode, you need a read-scaling token instead of a regular token.

README (reference)

Source of truth, from the repository.

<p align="center"> <img src="src/mcp_server_motherduck/assets/duck_feet_square.png" alt="MotherDuck / DuckDB Local MCP Server" width="120"> </p> <h1 align="center">DuckDB / MotherDuck Local MCP Server</h1> <p align="center"> SQL analytics and data engineering for AI Assistants and IDEs. </p>

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 MCPLocal MCP (this repo)
HostingHosted by MotherDuckRuns locally/self-hosted
SetupZero-setupRequires local installation
AccessRead-write supportedRead-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.
  • 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. 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)

{
  "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

ClientConfig LocationOne-Click Install
Claude DesktopSettings → Developer → Edit Config.mcpb (MCP Bundle)
Claude CodeUse CLI commands below-
Codex CLIUse CLI commands below or ~/.codex/config.toml-
Gemini CLIUse CLI commands below or ~/.gemini/settings.json-
CursorSettings → MCP → Add new global MCP server<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor" height="20">
VS CodeCtrl+Shift+P → "Preferences: Open User Settings (JSON)"Install with UV in VS Code
Kiro~/.kiro/settings/mcp.json (global) or .kiro/settings/mcp.json (project)Add to Kiro

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.

<details> <summary><b>Claude Code CLI commands</b></summary>

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
</details> <details> <summary><b>Codex CLI commands</b></summary>

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
</details> <details> <summary><b>Gemini CLI commands</b></summary>

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
</details> <details> <summary><b>Kiro manual JSON config</b></summary>

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>"
      }
    }
  }
}
</details>

Tools

ToolDescriptionRequired InputsOptional Inputs
execute_queryExecute SQL query (DuckDB dialect)sql-
list_databasesList all databases (useful for MotherDuck or multiple attached DBs)--
list_tablesList tables and views-database, schema
list_columnsList columns of a table/viewtabledatabase, schema
switch_database_connection*Switch to different databasepathcreate_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

ParameterDefaultDescription
--db-path:memory:Database path: local file (absolute), md: (MotherDuck), or s3:// URL
--motherduck-tokenmotherduck_token env varMotherDuck access token
--read-writeFalseEnable write access
--motherduck-saas-modeFalseMotherDuck SaaS mode (restricts local access)
--allow-switch-databasesFalseEnable switch_database_connection tool
--max-rows1024Max rows returned
--max-chars50000Max characters returned
--query-timeout-1Query timeout in seconds (-1 = disabled)
--init-sqlNoneSQL to execute on startup
--motherduck-connection-parameterssession_hint=mcp&<br>dbinstance_inactivity_ttl=0sAdditional MotherDuck connection string parameters (key=value pairs separated by &)
--ephemeral-connectionsTrueUse temporary connections for read-only local files
--transportstdioTransport type: stdio or http
--stateless-httpFalseFor protocol compatibility only (e.g. with AWS Bedrock AgentCore Runtime). Server still maintains global state via the shared DatabaseClient.
--port8000Port for HTTP transport
--host127.0.0.1Host for HTTP transport

Environment Variables

VariableDescription
motherduck_token or MOTHERDUCK_TOKENMotherDuck access token (alternative to --motherduck-token)
HOMEUsed by DuckDB for extensions and config. Override with --home-dir if not set.
AWS_ACCESS_KEY_IDAWS access key for S3 database connections
AWS_SECRET_ACCESS_KEYAWS secret key for S3 database connections
AWS_SESSION_TOKENAWS session token for temporary credentials (IAM roles, SSO, EC2 instance profiles)
AWS_DEFAULT_REGIONAWS region for S3 connections
AWS_ENDPOINTAWS 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

Related MCP servers

Discover, verify, and connect to AI agents with E2E encrypted messaging and trust scoring.

View repository →

Autonomous coding pipeline: frontier models plan and review, a local model implements, gated by TDD.

5
Python
Apache-2.0
View repository →

Backlinks, Domain Rating & expired-domain drops via seo-backlinks.net (Common Crawl)

0
JavaScript
MIT
View repository →

Hosted MCP for verified B2B lead campaigns with success-only billing.

View repository →

AI-powered Hedera HCS topic intelligence for agents. Pay per call in HBAR.

View repository →

Hedera ecosystem intelligence for AI agents. 29 tools, pay per call in HBAR. HITL enforced.