mcp-server-motherduck
OfficialYou can connect AI assistants and IDEs to DuckDB/MotherDuck databases for SQL analytics and data engineering.\n\n- Execute read/write SQL queries (DuckDB dialect) via execute_query.\n- Browse database catalogs: list databases, tables/views, and columns.\n- Switch between database connections (local files, :memory:, md: MotherDuck, s3://) on-the-fly if enabled.\n- Query across local and remote databases, and ingest/export data from/to local filesystem.\n- Run locally via stdio or HTTP transport with configurable row/char limits and security options.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-motherduck query the top 10 customers by total sales from last month"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
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.
Related MCP server: MotherDuck DuckDB MCP Server
Client Setup
Client | Config Location | One-Click Install |
Claude Desktop | Settings → Developer → Edit Config | |
Claude Code | Use CLI commands below | - |
Codex CLI | Use CLI commands below or | - |
Gemini CLI | Use CLI commands below or | - |
Cursor | Settings → MCP → Add new global MCP server | |
VS Code |
| |
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.
In-Memory DuckDB (Dev Mode):
claude mcp add --scope user duckdb --transport stdio -- uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databasesLocal DuckDB (Read-Only):
claude mcp add --scope user duckdb --transport stdio -- uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdbMotherDuck (Read-Write):
claude mcp add --scope user motherduck --transport stdio --env motherduck_token=YOUR_TOKEN -- uvx mcp-server-motherduck --db-path md: --read-writeIn-Memory DuckDB (Dev Mode):
codex mcp add duckdb -- uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databasesLocal DuckDB (Read-Only):
codex mcp add duckdb -- uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdbMotherDuck (Read-Write):
codex mcp add motherduck --env motherduck_token=YOUR_TOKEN -- uvx mcp-server-motherduck --db-path md: --read-writeIn-Memory DuckDB (Dev Mode):
gemini mcp add -s user duckdb uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databasesLocal DuckDB (Read-Only):
gemini mcp add -s user duckdb uvx mcp-server-motherduck --db-path /absolute/path/to/db.duckdbMotherDuck (Read-Write):
gemini mcp add -s user -e motherduck_token=YOUR_TOKEN motherduck uvx mcp-server-motherduck --db-path md: --read-writeAdd 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 SQL query (DuckDB dialect) |
| - |
| List all databases (useful for MotherDuck or multiple attached DBs) | - | - |
| List tables and views | - |
|
| List columns of a table/view |
|
|
| Switch to different database |
|
|
*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-motherduckConnect 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 |
|
| Database path: local file (absolute), |
|
| MotherDuck access token |
|
| Enable write access |
|
| MotherDuck SaaS mode (restricts local access) |
|
| Enable |
|
| Max rows returned |
|
| Max characters returned |
|
| Query timeout in seconds (-1 = disabled) |
|
| SQL to execute on startup |
|
| Additional MotherDuck connection string parameters ( |
|
| Use temporary connections for read-only local files |
|
| Transport type: |
|
| For protocol compatibility only (e.g. with AWS Bedrock AgentCore Runtime). Server still maintains global state via the shared DatabaseClient. |
|
| Port for HTTP transport |
|
| Host for HTTP transport |
Environment Variables
Variable | Description |
| MotherDuck access token (alternative to |
| Used by DuckDB for extensions and config. Override with |
| AWS access key for S3 database connections |
| AWS secret key for S3 database connections |
| AWS session token for temporary credentials (IAM roles, SSO, EC2 instance profiles) |
| AWS region for S3 connections |
| AWS endpoint for S3 connections |
Troubleshooting
spawn uvx ENOENT: Specify full path touvx(runwhich uvxto find it)File locked: Make sure
--ephemeral-connectionsis 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
Run the
Release New VersionGitHub ActionEnter version in
MAJOR.MINOR.PATCHformatThe 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
Available Tools
5 toolsexecute_queryExecute QueryADestructive
Execute a SQL query on the DuckDB or MotherDuck database. Unqualified table names resolve to current_database() and current_schema() automatically. Fully qualified names (database.schema.table) are only needed when multiple DuckDB databases are attached or when connected to MotherDuck.
Inputs: sql (required). Returns: result
list_columnsList ColumnsARead-only
List all columns of a table or view with their types and comments. If database/schema are not specified, uses the current database/schema.
Inputs: table (required), schema, database. Returns: result
list_databasesList DatabasesARead-only
List all databases available in the connection. Useful when multiple DuckDB databases are attached or when connected to MotherDuck.
Inputs: no named parameters. Returns: result
list_tablesList TablesBRead-only
List all tables and views in a database with their comments. If database is not specified, uses the current database.
Inputs: schema, database. Returns: result
switch_database_connectionSwitch Database ConnectionA
Switch to a different database connection. For local files, use absolute paths only. The new connection respects the server's read-only/read-write mode. For local files, the file must exist unless create_if_not_exists=True (requires read-write mode).
Inputs: path (required), create_if_not_exists. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: execute_query runs SQL, list_databases/tables/columns return metadata, switch_database_connection manages connections. Overlap is minimal because the listing tools target different entity levels (databases, tables, columns).
All tools use a consistent verb_noun snake_case pattern: execute_query, list_databases, list_tables, list_columns, switch_database_connection. The naming is predictable and readable.
Five tools is well-scoped for a database interface: one query executor, three metadata listers, and one connection switcher. No obvious missing core operations given the server's purpose.
The surface covers querying, schema exploration, and connection management. However, it lacks tools for database writing/DDL (e.g., create table, insert) or connection closing, which might be needed for full lifecycle management.
Maintenance
Related MCP Connectors
Hosted MotherDuck MCP server: explore data, run DuckDB SQL, and build Dives and Flights.
Query, join, profile, clean and convert CSV/JSON/Parquet with server-side DuckDB over MCP.
Official Duck Framework MCP server for AI-assisted development and project scaffolding.
MCP server for interacting with the Supabase platform
Related MCP Servers
- AlicenseBqualityAmaintenanceUniversal database MCP server connecting to MySQL, PostgreSQL, SQLite, DuckDB and etc.23,996MIT
- AlicenseAqualityDmaintenanceA local MCP server implementation that interacts with DuckDB and MotherDuck databases, providing SQL analytics capabilities to AI Assistants and IDEs.1MIT
- AlicenseNot gradedqualityDmaintenanceA local MCP server enabling AI assistants to query and analyze data via DuckDB SQL engine, supporting local files, memory, S3, and MotherDuck.14 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceMCP server for SQL analytics on DuckDB and MotherDuck databases, enabling AI assistants and IDEs to query data via natural language.1MIT