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

10 Best Small Local LLMs to Try Out (< 8GB)

10 Best Small Local LLMs to Try Out (< 8GB)

The world of Large Language Models (LLMs) has exploded, often conjuring images of massive, cloud-bound supercomputers churning out text. But what if you could harness significant AI power right on your personal computer, without constant internet connectivity or hefty cloud subscriptions? The exciting reality is that you can. Thanks to advancements in optimization techniques, a new breed of "small local LLMs" has emerged, delivering remarkable capabilities while fitting comfortably within the me

13 June 2025

React Tutorial: A Beginner's Guide

React Tutorial: A Beginner's Guide

Welcome, aspiring React developer! You've made a fantastic choice. React is a powerful and popular JavaScript library for building user interfaces, and learning it is a surefire way to boost your web development skills. This comprehensive, step-by-step guide will take you from zero to hero, equipping you with the practical knowledge you need to start building your own React applications in 2025. We'll focus on doing, not just reading, so get ready to write some code! 💡Want a great API Testing

13 June 2025

Top 15 Free Tools for API Documentation

Top 15 Free Tools for API Documentation

Looking for the best free API documentation tools? This guide covers 15 top choices. Explore the features and benefits of each tool and choose the one that is best for your project.

13 June 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs