This MotherDuck DuckDB MCP server provides SQL analytics capabilities for AI Assistants and IDEs by connecting to DuckDB and MotherDuck databases. With it, you can:
Initialize Connections: Connect to local DuckDB (in-memory, file-backed, read-only) or cloud-based MotherDuck databases (using access tokens)
Retrieve Databases: Access available databases after connection initialization
Read Schemas: Get table schemas from specific databases
Execute SQL Queries: Run analytics and data manipulation on connected databases
Hybrid Execution: Query data combining local and cloud sources
Cloud Storage Integration: Access data from Amazon S3 and other cloud storage
Data Sharing: Create and share databases (via MotherDuck functionality)
Serverless Analytics: Run analytics without configuring instances or clusters
Click on "Install 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-motherduckquery 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-only | 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.
Quick Start
Prerequisites: Install uv via pip install uv or brew install uv
Connecting to In-Memory DuckDB (Dev Mode)
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
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
See Command Line Parameters for more options, Securing for Production for deployment guidance, and Troubleshooting if you encounter issues.
Related MCP server: Duck Duck MCP
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 | - |
Cursor | Settings → MCP → Add new global MCP server | |
VS Code |
|
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):
Local DuckDB (Read-Only):
MotherDuck (Read-Write):
In-Memory DuckDB (Dev Mode):
Local DuckDB (Read-Only):
MotherDuck (Read-Write):
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-only, 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.
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 |
|
| 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 |
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:
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