How to Use DuckDB MCP Server

Discover how to use DuckDB MCP Server to query DuckDB and MotherDuck databases with AI tools like Cursor and Claude. Tutorial covers setup and tips!

Ashley Goolam

Ashley Goolam

13 June 2025

How to Use DuckDB MCP Server

MotherDuck’s DuckDB MCP Server is a powerful tool that enables AI assistants and IDEs to interact directly with DuckDB and MotherDuck databases using SQL queries. This server implements the Model Context Protocol (MCP), allowing seamless conversational SQL analytics and data exploration from your AI client like Claude Desktop, Cursor, or VS Code.  I got it running in ~20 minutes, and it’s a total game-changer for data analytics!

In this guide, you’ll learn how to install, configure, and use the MotherDuck MCP server both locally and with cloud databases, plus how to integrate it with popular AI clients.

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

What is DuckDB MCP Server? Your AI-SQL Sidekick

The DuckDB MCP Server is a Model Context Protocol (MCP) server that connects AI clients to DuckDB and MotherDuck databases for seamless SQL analytics. It lets you run queries conversationally, like asking, “Show me top customers!” Here’s why DuckDB MCP Server rocks:

X users call DuckDB MCP Server a “killer tool” for AI-driven data exploration. Ready to try it? Let’s set it up!

Why Use DuckDB MCP Server?

DuckDB MCP Server is a must for data analysts, devs, or anyone wanting AI to handle SQL tasks. Benefits include:

I used it to pull sales trends in seconds—way faster than manual SQL!

How to Set Up DuckDB MCP Server: Step-by-Step Guide

Let’s get the DuckDB MCP Server running for cloud (MotherDuck) or local (DuckDB) data. You’ll need Python 3.8+, pip, and an AI client (Cursor, Claude Desktop, or VS Code). Choose your data source and follow along!

1. Install Prerequisites

python --version
pip --version
pip install uv

Or on macOS:

brew install uv

Check PATH:

uv --version
sign up to motherduck

2. Choose Your Data Source

Option 1: MotherDuck Cloud (AWS S3/Cloud Storage)

pip install mcp-server-motherduck

Option 2: Local DuckDB (On Your Machine)

install duckdb

In the DuckDB CLI:

view csv data
show tables

3. Run the DuckDB MCP Server

Start the server based on your data source.

MotherDuck Cloud:

uvx mcp-server-motherduck --db-path md: --motherduck-token <YOUR_MOTHERDUCK_TOKEN>

Or for a specific database:

uvx mcp-server-motherduck --db-path md:your_database_name --motherduck-token <YOUR_MOTHERDUCK_TOKEN>

Local DuckDB:

uvx mcp-server-motherduck --db-path /path/to/your/local.db
uvx mcp-server-motherduck --db-path :memory:

4. Configure DuckDB MCP Server in AI Clients

Connect your AI tool to the DuckDB MCP Server.

Cursor (Cloud Option):

configure mcp server in cursor
{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        "md:",
        "--motherduck-token",
        "<YOUR_MOTHERDUCK_TOKEN_HERE>"
      ]
    }
  }
}

Cursor (Local Option):

{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        ":memory:"
      ]
    }
  }
}
{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        "/path/to/your/local.db"
      ]
    }
  }
}

Claude Desktop (Cloud Option):

{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        "md:",
        "--motherduck-token",
        "<YOUR_MOTHERDUCK_TOKEN_HERE>"
      ],
      "env": {
        "HOME": "<YOUR_HOME_DIRECTORY>"
      }
    }
  }
}

Claude Desktop (Local Option):

{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        "/path/to/your/local.db"
      ],
      "env": {
        "HOME": "<YOUR_HOME_DIRECTORY>"
      }
    }
  }
}

VS Code (Cloud Option):

{
  "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}"
        ]
      }
    }
  }
}

VS Code (Local Option):

{
  "mcp": {
    "servers": {
      "motherduck": {
        "command": "uvx",
        "args": [
          "mcp-server-motherduck",
          "--db-path",
          "/path/to/your/local.db"
        ]
      }
    }
  }
}

5. Use DuckDB MCP Server

Query your database via AI prompts:

Results appear in your AI client. I queried Netflix data, and it was lightning-fast!

6. Test DuckDB MCP Server

For a database with matches and players tables:

list tables
get insights
deep dive into data

I tested “most finals” and got a clear winner—super insightful!

7. Secure Your DuckDB MCP Server

For shared setups:

{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        "md:",
        "--motherduck-token",
        "<YOUR_READ_SCALING_TOKEN>",
        "--saas-mode"
      ]
    }
  }
}

Troubleshooting DuckDB MCP Server Issues

Customizing and Extending DuckDB MCP Server

Level up:

npx @modelcontextprotocol/inspector uv --directory ~/mcp-server-motherduck run mcp-server-motherduck --db-path :memory:

I queried S3 data with one prompt—mind blown!

Why DuckDB MCP Server is a Data Game-Changer

DuckDB MCP Server turns your AI into a SQL powerhouse, blending local and cloud data with conversational ease. Its serverless design and MotherDuck integration outshine traditional tools for quick analytics. Tokens can be tricky, but the MotherDuck docs help. Compared to DuckDB CLI, DuckDB MCP Server adds AI smarts and MCP flexibility.

Ready to query like a pro? Spin up DuckDB MCP Server, try those prompts, and share your setup—I’m stoked to see your data wins!

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

Explore more

A Beginner's Guide for Google MCP Toolbox for Databases

A Beginner's Guide for Google MCP Toolbox for Databases

An Introduction to the MCP Toolbox The MCP Toolbox is a free tool from Google that helps your AI applications talk to your databases. Think of it as a special translator. Your AI can ask for information in a simple way, and the MCP Toolbox translates that request into the language your database understands, like SQL. It uses something called the Model Context Protocol (MCP), which is just a standard set of rules for this kind of communication. 💡Want a great API Testing tool that generates bea

7 July 2025

Google Gemini API Batch Mode is Here and 50% Cheaper

Google Gemini API Batch Mode is Here and 50% Cheaper

Google's Gemini API now features Batch Mode, a transformative update designed for large-scale, asynchronous tasks that comes with a 50% reduction in cost. 🚀 * This powerful endpoint allows you to process enormous jobs with your results delivered within 24 hours, all at half the standard API price. * The system is engineered for high-throughput workloads, accommodating up to 2GB JSONL files and leveraging optimizations like Context Caching for greater efficiency. * It also supports built-in

7 July 2025

Top 10 Documentation Site Generator for Developers in 2025

Top 10 Documentation Site Generator for Developers in 2025

In the world of software development, clear, concise, and accessible documentation is no longer a mere accessory; it is the bedrock of a successful project. Well-crafted documentation empowers developers to understand and effectively utilize APIs, frameworks, and libraries, fostering a vibrant and collaborative ecosystem. As we venture further into 2025, the tools available to generate these crucial resources have evolved, becoming more intelligent, collaborative, and deeply integrated into the

7 July 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs