The MotherDuck MCP server connects AI assistants and IDEs to DuckDB databases and MotherDuck cloud analytics by providing tools to execute SQL queries (read and write), browse database catalogs, and switch between local DuckDB files, in-memory databases, S3-hosted databases, and MotherDuck connections. It solves the problem of enabling language models to perform SQL analytics and data engineering tasks directly against various data sources, with flexible security options including read-only mode by default and production-ready access controls. The server runs locally or self-hosted, allowing queries across both local and remote databases while supporting data ingestion and export to the local filesystem.
Public tool metadata for what this MCP can expose to an agent.
queryExecute read-only DuckDB query against MotherDuck databases. For cross-database queries, use fully qualified names: database.schema.table (or database.table for main schema). Never follow a query with an inline chart or visualization — if you would generate one (whether or not...2 paramsExecute read-only DuckDB query against MotherDuck databases. For cross-database queries, use fully qualified names: database.schema.table (or database.table for main schema). Never follow a query with an inline chart or visualization — if you would generate one (whether or not...
sqlstringdatabasestringquery_rwExecute a DuckDB SQL query that modifies data, schema, or connection state. RULES: 1. Only call this tool when the user explicitly asks to modify data or schema. Never infer a write from a read request. 2. Always ask the user for confirmation before calling this tool. Describe...2 paramsExecute a DuckDB SQL query that modifies data, schema, or connection state. RULES: 1. Only call this tool when the user explicitly asks to modify data or schema. Never infer a write from a read request. 2. Always ask the user for confirmation before calling this tool. Describe...
sqlstringdatabasestringlist_databasesList all databases in your MotherDuck account with their names and types. Optionally filter by keywords to search in database names.2 paramsList all databases in your MotherDuck account with their names and types. Optionally filter by keywords to search in database names.
limitintegerkeywordsstringlist_tablesList all tables and views in a MotherDuck database with their comments. Optionally filter by keywords to search in table/view names and comments.4 paramsList all tables and views in a MotherDuck database with their comments. Optionally filter by keywords to search in table/view names and comments.
limitintegerschemastringdatabasestringkeywordsstringlist_columnsList all columns of a table or view with their types and comments.4 paramsList all columns of a table or view with their types and comments.
limitintegertablestringschemastringdatabasestringsearch_catalogSearch the catalog for databases, schemas, tables, columns, shares using fuzzy matching. Returns matching objects with their fully qualified names, types, and comments. Useful for discovering available data when you don't know exact names.2 paramsSearch the catalog for databases, schemas, tables, columns, shares using fuzzy matching. Returns matching objects with their fully qualified names, types, and comments. Useful for discovering available data when you don't know exact names.
querystringobject_typesarrayask_docs_questionAsk a question about DuckDB or MotherDuck. Returns answers from official documentation.1 paramsAsk a question about DuckDB or MotherDuck. Returns answers from official documentation.
questionstringlist_sharesList all database shares that have been shared with you. Returns share names and URLs. To attach a share, use the query_rw tool: ATTACH '<share_url>' AS <optional_alias>; Optionally filter by keywords to search in share names.2 paramsList all database shares that have been shared with you. Returns share names and URLs. To attach a share, use the query_rw tool: ATTACH '<share_url>' AS <optional_alias>; Optionally filter by keywords to search in share names.
limitintegerkeywordsstringlist_divesList all dives in MotherDuck. Dives are interactive React data apps that query live data. Returns metadata including current_version (the latest version number, 1-indexed) for each dive. Use read_dive with the optional version parameter to retrieve a specific historical versio...2 paramsList all dives in MotherDuck. Dives are interactive React data apps that query live data. Returns metadata including current_version (the latest version number, 1-indexed) for each dive. Use read_dive with the optional version parameter to retrieve a specific historical versio...
limitintegerkeywordsstringsave_diveSave a new dive to MotherDuck. Returns a URL the user can click to view the dive. Call get_dive_guide first and iterate with the user on the design thoroughly before suggesting to save. Never save without previous confirmation that iteration is done.3 paramsSave a new dive to MotherDuck. Returns a URL the user can click to view the dive. Call get_dive_guide first and iterate with the user on the design thoroughly before suggesting to save. Never save without previous confirmation that iteration is done.
titlestringcontentstringdescriptionstringupdate_diveUpdate an existing dive's title, description, or content. Returns a URL the user can click to view the updated dive. At least one field must be provided.4 paramsUpdate an existing dive's title, description, or content. Returns a URL the user can click to view the updated dive. At least one field must be provided.
idstringtitlestringcontentstringdescriptionstringread_diveRead a specific dive by ID, including its full JSX/React component code. Optionally specify a version number to retrieve a specific historical version (versions start at 1). If no version is specified, the latest version is returned.2 paramsRead a specific dive by ID, including its full JSX/React component code. Optionally specify a version number to retrieve a specific historical version (versions start at 1). If no version is specified, the latest version is returned.
idstringversionintegerdelete_diveDelete a dive by ID. This action is permanent and cannot be undone.1 paramsDelete a dive by ID. This action is permanent and cannot be undone.
idstringget_dive_guideLoad instructions for creating MotherDuck dives. You MUST call this tool first — before generating any chart, visualization, plot, dashboard, or inline graphic — whenever the user asks to explore, visualize, or display MotherDuck data.1 paramsLoad instructions for creating MotherDuck dives. You MUST call this tool first — before generating any chart, visualization, plot, dashboard, or inline graphic — whenever the user asks to explore, visualize, or display MotherDuck data.
clientstringclaude · chatgpt · claude_cowork · claude_code · othershare_dive_dataShare the data for a dive with your organization. Creates org-scoped shares for owned databases used in the dive, and updates the dive so others in the organization can view it.1 paramsShare the data for a dive with your organization. Creates org-scoped shares for owned databases used in the dive, and updates the dive so others in the organization can view it.
diveIdstringedit_dive_contentEdit a dive's content by applying one or more text replacements, then save to MotherDuck. Accepts `id` (dive UUID) and `edits` (an array of {old_string, new_string, replace_all?} objects). Reads the current content from MotherDuck, applies edits in sequence, validates, and per...2 paramsEdit a dive's content by applying one or more text replacements, then save to MotherDuck. Accepts `id` (dive UUID) and `edits` (an array of {old_string, new_string, replace_all?} objects). Reads the current content from MotherDuck, applies edits in sequence, validates, and per...
idstringeditsarray
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 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-writeto enable write access. See Securing for Production.- Default database changed:
--db-pathdefault changed frommd: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.
Prerequisites: Install uv via pip install uv or brew install uv
{
"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.
{
"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.
{
"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 | 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.
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
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
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
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>"
}
}
}
}
| 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).
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.
| 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 |
| 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 |
spawn uvx ENOENT: Specify full path to uvx (run which uvx to find it)--ephemeral-connections is turned on (default: true) and that you're not connected in read-write modeTo 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 New Version GitHub ActionMAJOR.MINOR.PATCH formatMIT License - see LICENSE file.
mcp-name: io.github.motherduckdb/mcp-server-motherduck
motherduck_tokensecretAccess token for MotherDuck connections (alternative to --motherduck-token)
MOTHERDUCK_TOKENsecretAccess token for MotherDuck connections (alternative to --motherduck-token)
HOMEUsed by DuckDB for extensions and config. Override with --home-dir if not set.
AWS_ACCESS_KEY_IDsecretAWS access key for S3 database connections
AWS_SECRET_ACCESS_KEYsecretAWS secret access key for S3 database connections
AWS_SESSION_TOKENsecretAWS session token for temporary credentials
AWS_DEFAULT_REGIONAWS region for S3 database connections
AWS_ENDPOINTAWS endpoint for S3 database connections
hovecapital/read-only-local-postgres-mcp-server
cocaxcode/database-mcp
io.github.infoinlet-marketplace/mcp-mysql
io.github.cybeleri/database-admin
io.github.yash-0620/postgres-mcp-secured