MotherDuck DuckDB MCP Server
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., "@MotherDuck DuckDB MCP Serverlist all tables in the DuckDB database"
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.
MotherDuck's DuckDB MCP Server
A local MCP server implementation that interacts with DuckDB and MotherDuck databases, providing SQL analytics capabilities to AI Assistants and IDEs.
This repository contains the self-hosted/local MCP server implementation. If you're looking for MotherDuck's hosted/remote MCP option, see the MotherDuck MCP docs.
Resources
Close the Loop: Faster Data Pipelines with MCP, DuckDB & AI (Blogpost)
Faster Data Pipelines development with MCP and DuckDB (YouTube)
Related MCP server: DuckDB MCP Server
Features
Hybrid execution: query data from local DuckDB or/and cloud-based MotherDuck databases
Cloud storage integration: access data stored in Amazon S3 or other cloud storage thanks to MotherDuck's integrations
Data sharing: create and share databases
SQL analytics: use DuckDB's SQL dialect to query any size of data directly from your AI Assistant or IDE
Serverless architecture: run analytics without needing to configure instances or clusters
Components
Prompts
The server provides one prompt:
duckdb-motherduck-initial-prompt: A prompt to initialize a connection to DuckDB or MotherDuck and start working with it
Tools
The server offers one tool:
query: Execute a SQL query on the DuckDB or MotherDuck databaseInputs:
query(string, required): The SQL query to execute
All interactions with both DuckDB and MotherDuck are done through writing SQL queries.
Result Limiting: Query results are automatically limited to prevent using up too much context:
Maximum 1024 rows by default (configurable with
--max-rows)Maximum 50,000 characters by default (configurable with
--max-chars)Truncated responses include a note about truncation
Command Line Parameters
The MCP server supports the following parameters:
Parameter | Type | Default | Description |
| Choice |
| Transport type. Options: |
| Integer |
| Port to listen on for sse and stream transport mode |
| String |
| Host to bind the MCP server for sse and stream transport mode |
| String |
| Path to local DuckDB database file, MotherDuck database, or S3 URL (e.g., |
| String |
| Access token to use for MotherDuck database connections (uses |
| Flag |
| Flag for connecting to DuckDB or MotherDuck in read-only mode. For DuckDB it uses short-lived connections to enable concurrent access |
| String |
| Home directory for DuckDB (uses |
| Flag |
| Flag for connecting to MotherDuck in SaaS mode. (disables filesystem and write permissions for local DuckDB) |
| Flag |
| Enable JSON responses for HTTP stream. Only supported for |
| Integer |
| Maximum number of rows to return from queries. |
| Integer |
| Maximum number of characters in query results. |
| Integer |
| Query execution timeout in seconds. Set to -1 to disable timeout (default). |
Quick Usage Examples
# Connect to local DuckDB file in read-only mode
uvx mcp-server-motherduck --db-path /path/to/local.db --read-only
# Connect to MotherDuck with token
uvx mcp-server-motherduck --db-path md: --motherduck-token YOUR_TOKEN
# Connect to local DuckDB file in read-only mode
uvx mcp-server-motherduck --db-path /path/to/local.db --read-only
# Connect to MotherDuck in SaaS mode for enhanced security with stream transport mode
uvx mcp-server-motherduck --transport stream --db-path md: --motherduck-token YOUR_TOKEN --saas-mode
# Customize result truncation limits
uvx mcp-server-motherduck --db-path md: --motherduck-token YOUR_TOKEN --max-rows 2048 --max-chars 100000
# Enable query timeout (5 minutes)
uvx mcp-server-motherduck --db-path md: --motherduck-token YOUR_TOKEN --query-timeout 300Getting Started
General Prerequisites
uvinstalled, you can install it usingpip install uvorbrew install uv
If you plan to use the MCP with Claude Desktop or any other MCP comptabile client, the client need to be installed.
Prerequisites for DuckDB
No prerequisites. The MCP server can create an in-memory database on-the-fly
Or connect to an existing local DuckDB database file , or one stored on remote object storage (e.g., AWS S3).
Prerequisites for MotherDuck
Sign up for a MotherDuck account
Generate an access token via the MotherDuck UI
Store the token securely for use in the configuration
Usage with Cursor
Install Cursor from cursor.com/downloads if you haven't already
Open Cursor:
To set it up globally for the first time, go to Settings->MCP and click on "+ Add new global MCP server".
This will open a
mcp.jsonfile to which you add the following configuration:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
]
}
}
}Usage with VS Code
For the quickest installation, click one of the "Install with UV" buttons at the top.
Manual Installation
Add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open User Settings (JSON).
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "motherduck_token",
"description": "MotherDuck Token",
"password": true
}
],
"servers": {
"motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"${input:motherduck_token}"
]
}
}
}
}Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.
{
"inputs": [
{
"type": "promptString",
"id": "motherduck_token",
"description": "MotherDuck Token",
"password": true
}
],
"servers": {
"motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"${input:motherduck_token}"
]
}
}
}Usage with Claude Desktop
Install Claude Desktop from claude.ai/download if you haven't already
Open the Claude Desktop configuration file:
To quickly access it or create it the first time, open the Claude Desktop app, select Settings, and click on the "Developer" tab, finally click on the "Edit Config" button.
Add the following configuration to your
claude_desktop_config.json:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
]
}
}
}Important Notes:
Replace
YOUR_MOTHERDUCK_TOKEN_HEREwith your actual MotherDuck token
Usage with Claude Code
Claude Code supports MCP servers through CLI commands or JSON configuration. Here are two ways to set it up:
Option 1: Using CLI Commands
Add the MotherDuck MCP server directly using the Claude Code CLI:
claude mcp add mcp-server-motherduck uvx mcp-server-motherduck -- --db-path md: --motherduck-token <YOUR_MOTHERDUCK_TOKEN_HERE>Option 2: Using JSON Configuration
Add the server using a JSON configuration:
claude mcp add-json mcp-server-motherduck '{
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
]
}'Scoping Options:
Use
--local(default) for project-specific configurationUse
--projectto share the configuration with your team via.mcp.jsonUse
--userto make the server available across all your projects
Important Notes:
Replace
YOUR_MOTHERDUCK_TOKEN_HEREwith your actual MotherDuck tokenClaude Code also supports environment variable expansion, so you can use
${MOTHERDUCK_TOKEN}if you've set the environment variable
Securing your MCP Server when querying MotherDuck
If the MCP server is exposed to third parties and should only have read access to data, we recommend using a read scaling token and running the MCP server in SaaS mode.
Read Scaling Tokens are special access tokens that enable scalable read operations by allowing up to 4 concurrent read replicas, improving performance for multiple end users while restricting write capabilities. Refer to the Read Scaling documentation to learn how to create a read-scaling token.
SaaS Mode in MotherDuck enhances security by restricting it's access to local files, databases, extensions, and configurations, making it ideal for third-party tools that require stricter environment protection. Learn more about it in the SaaS Mode documentation.
Secure Configuration
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_READ_SCALING_TOKEN_HERE>",
"--saas-mode"
]
}
}
}Connect to local DuckDB
To connect to a local DuckDB, instead of using the MotherDuck token, specify the path to your local DuckDB database file or use :memory: for an in-memory database.
In-memory database:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
":memory:"
]
}
}
}Local DuckDB file:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"/path/to/your/local.db"
]
}
}
}Local DuckDB file in readonly mode:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"/path/to/your/local.db",
"--read-only"
]
}
}
}Note: readonly mode for local file-backed DuckDB connections also makes use of short lived connections. Each time the query MCP tool is used a temporary, reaodnly connection is created + query is executed + connection is closed. This feature was motivated by a workflow where DBT was for modeling data within duckdb and then an MCP client (Windsurf/Cline/Claude/Cursor) was used for exploring the database. The short lived connections allow each tool to run and then release their connection, allowing the next tool to connect.
Connect to DuckDB on S3
You can connect to DuckDB databases stored on Amazon S3 by providing an S3 URL as the database path. The server will automatically configure the necessary S3 credentials from your environment variables.
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"s3://your-bucket/path/to/database.duckdb"
],
"env": {
"AWS_ACCESS_KEY_ID": "<your_key>",
"AWS_SECRET_ACCESS_KEY": "<your_secret>",
"AWS_DEFAULT_REGION": "<your_region>"
}
}
}
}Note: For S3 connections:
AWS credentials must be provided via environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, and optionallyAWS_DEFAULT_REGION)For temporary credentials (AWS SSO), set the
AWS_SESSION_TOKENenvironment variable (and optionallyAWS_DEFAULT_REGION) to automatically use DuckDB'scredential_chainprovider.The S3 database is attached to an in-memory DuckDB instance
The httpfs extension is automatically installed and configured for S3 access
Both read and write operations are supported
Example Queries
Once configured, you can e.g. ask Claude to run queries like:
"Create a new database and table in MotherDuck"
"Query data from my local CSV file"
"Join data from my local DuckDB database with a table in MotherDuck"
"Analyze data stored in Amazon S3"
Running in SSE mode
The server can run in SSE mode in two ways:
Direct SSE mode
Run the server directly in SSE mode using the --transport sse flag:
uvx mcp-server-motherduck --transport sse --port 8000 --db-path md: --motherduck-token <your_motherduck_token>This will start the server listening on the specified port (default 8000) and you can point your clients directly to this endpoint.
Using supergateway
Alternatively, you can run SSE mode using supergateway:
npx -y supergateway --stdio "uvx mcp-server-motherduck --db-path md: --motherduck-token <your_motherduck_token>"Both methods allow you to point your clients such as Claude Desktop, Cursor to the SSE endpoint.
Development configuration
To run the server from a local development environment, use the following configuration:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uv",
"args": [
"--directory",
"/path/to/your/local/mcp-server-motherduck",
"run",
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
]
}
}
}Troubleshooting
If you encounter connection issues, verify your MotherDuck token is correct
For local file access problems, ensure the
--home-dirparameter is set correctlyCheck that the
uvxcommand is available in your PATHIf you encounter
spawn uvx ENOENTerrors, try specifying the full path touvx(output ofwhich uvx)In version previous for v0.4.0 we used environment variables, now we use parameters
License
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
mcp-name: io.github.motherduckdb/mcp-server-motherduck
Available Tools
1 toolqueryA
Use this to execute a query on the MotherDuck or DuckDB database
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL query to execute that is a dialect of DuckDB SQL |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states that it executes a query, but does not mention whether the query is read-only, can modify data, what permissions are needed, or how results are returned. Given the open-ended nature of SQL queries, this is a significant gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence that directly states the tool's purpose without wasted words. It is concise and easy to parse.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Although the tool is simple and has full schema coverage, the absence of annotations and an output schema means the description should clarify expected behavior (e.g., whether it returns results or supports only SELECT queries). It does not, leaving some ambiguity. However, for a minimal query tool, it provides the core essentials.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description covers 100% of the single parameter ('SQL query to execute that is a dialect of DuckDB SQL'), so the description adds no additional meaning. Baseline 3 is appropriate because the schema already provides sufficient semantic detail for the parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's function: 'Use this to execute a query on the MotherDuck or DuckDB database.' It specifies a verb (execute), a resource (query on a database), and distinguishes it from potential sibling tools, though none are listed.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description begins with 'Use this to execute a query,' giving explicit guidance on when to invoke the tool. Since there are no sibling tools or alternatives mentioned, it fully covers the main use case, though it does not discuss when not to use it or any prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v0.8.0- First observed
query
TDQS
Only one tool exists, so there is no possibility of confusion or overlap. The tool's purpose is clear.
The single tool name 'query' is a simple, imperative verb that clearly describes its action. No mixed conventions to judge.
With only one tool, the server feels thin for a general-purpose database server, though it can technically execute any SQL. It falls in the borderline range for a small server.
The tool allows arbitrary query execution, which can cover metadata via system tables, but lacks dedicated tools for listing tables or schemas, requiring agents to know SQL to explore the database.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Query, join, profile, clean and convert CSV/JSON/Parquet with server-side DuckDB over MCP.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
- SupabaseOAuthcom.supabase
MCP server for interacting with the Supabase platform
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceAn MCP server for MotherDuck and local DuckDB.517MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server implementation that connects AI assistants to DuckDB, enabling them to query and analyze data from various sources including CSV, Parquet, JSON, and cloud storage through SQL.18MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables SQL analytics on DuckDB and MotherDuck databases, allowing AI assistants and IDEs to query and analyze data.MIT
- AlicenseNot gradedqualityDmaintenanceA local MCP server enabling AI assistants to query and analyze data via DuckDB SQL engine, supporting local files, memory, S3, and MotherDuck.16Apache 2.0
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/fastmcp-me/mcp-server-motherduck'
If you have feedback or need assistance with the MCP directory API, please join our Discord server