# MotherDuck / DuckDB (MCP Server)

> Query local DuckDB files and MotherDuck cloud databases

- Type: MCP server
- Publisher: MotherDuck (official)
- Categories: Data & Analytics
- Website: https://github.com/motherduckdb/mcp-server-motherduck
- Source: https://github.com/motherduckdb/mcp-server-motherduck
- Transport: stdio
- Launch command: uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases
- Sign-in: api-key
- Environment variables: motherduck_token
- GitHub stars: 524
- Listed: 2024-12-12

## About

Official MotherDuck MCP server for DuckDB and MotherDuck. Connects to in-memory, local file, S3 or MotherDuck (md:) databases and runs DuckDB SQL, with optional read-write and database switching.

## Install

1. **Add the server to Codex**

   Codex CLI:

   ```bash
   codex mcp add motherduck-duckdb --env motherduck_token=YOUR_motherduck_token -- uvx mcp-server-motherduck --db-path :memory: --read-write --allow-switch-databases
   ```

   config.toml:

   ```toml
   [mcp_servers.motherduck-duckdb]
   command = "uvx"
   args = ["mcp-server-motherduck", "--db-path", ":memory:", "--read-write", "--allow-switch-databases"]
   
   [mcp_servers.motherduck-duckdb.env]
   motherduck_token = "YOUR_motherduck_token"
   ```

   Agents SDK:

   ```python
   from agents import Agent, Runner
   from agents.mcp import MCPServerStdio
   
   async with MCPServerStdio(
       name="MotherDuck / DuckDB",
       params={"command": "uvx", "args": ["mcp-server-motherduck", "--db-path", ":memory:", "--read-write", "--allow-switch-databases"]},
   ) as server:
       agent = Agent(name="Assistant", mcp_servers=[server])
       result = await Runner.run(agent, "Query this Parquet file on S3 and summarize it")
       print(result.final_output)
   ```

## Tools

- `execute_query`
- `list_databases`
- `list_tables`
- `list_columns`
- `switch_database_connection`

## Example prompts

- "Query this Parquet file on S3 and summarize it"
- "List tables in my MotherDuck database"
- "Show the columns of the sales table"
- "Create a table from this CSV"

## Also available as

- app: [MotherDuck](https://chatgptplugins.directory/apps/motherduck.md)

## Related

- [Supabase](https://chatgptplugins.directory/mcp/supabase.md): Manage Supabase databases, migrations, edge functions and logs
- [Graphiti MCP](https://chatgptplugins.directory/mcp/graphiti.md): Temporal knowledge graph memory for agents, by Zep
- [MCP Toolbox for Databases](https://chatgptplugins.directory/mcp/mcp-toolbox-databases.md): Google's open-source MCP server for 20+ databases
- [PostHog](https://chatgptplugins.directory/mcp/posthog.md): Query product analytics, feature flags, experiments and errors in PostHog
- [Apify](https://chatgptplugins.directory/mcp/apify.md): Run thousands of Apify Actors for scraping and automation from your agent
- [Firecrawl](https://chatgptplugins.directory/mcp/firecrawl.md): Scrape, search, crawl and interact with live web pages for LLMs

---
Source: https://chatgptplugins.directory/mcp/motherduck-duckdb · Index: https://chatgptplugins.directory/llms.txt · Independent and community-run. Not affiliated with or endorsed by OpenAI. ChatGPT is a trademark of OpenAI.
