MotherDuck & DuckDB MCP server

Integrates MotherDuck and local DuckDB databases for flexible querying and analysis of structured data in MCP-compatible environments.
Back to servers
Setup instructions
Provider
MotherDuck
Release date
Jan 08, 2025
Language
Python
Package
Stats
34.1K downloads
321 stars

The MotherDuck's DuckDB MCP Server is an implementation that enables AI assistants and IDEs to interact with DuckDB and MotherDuck databases for SQL analytics. It allows you to query local or cloud-based databases, access data in cloud storage, and perform SQL analytics without complex infrastructure setup.

Installation Prerequisites

General Requirements

  • uv package manager installed via pip install uv or brew install uv
  • A compatible MCP client (Claude Desktop, VS Code, Cursor, etc.)

For DuckDB Usage

  • No special prerequisites - can create an in-memory database or connect to existing files

For MotherDuck Usage

Setup Instructions

Installing in Cursor

  1. Open Cursor and go to Settings → MCP
  2. Click "+ Add new global MCP server"
  3. Add the following configuration to the mcp.json file:
{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        "md:",
        "--motherduck-token",
        "<YOUR_MOTHERDUCK_TOKEN_HERE>"
      ]
    }
  }
}

Installing in VS Code

Manual Installation

Add to your VS Code 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}"
        ]
      }
    }
  }
}

Alternatively, create a .vscode/mcp.json file in your workspace with:

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

Installing in Claude Desktop

  1. Open Claude Desktop
  2. Go to Settings → Developer tab
  3. Click "Edit Config"
  4. Add the following configuration:
{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        "md:",
        "--motherduck-token",
        "<YOUR_MOTHERDUCK_TOKEN_HERE>"
      ]
    }
  }
}

Installing in Claude Code

Option 1: Using CLI Commands

claude mcp add mcp-server-motherduck uvx mcp-server-motherduck -- --db-path md: --motherduck-token <YOUR_MOTHERDUCK_TOKEN_HERE>

Option 2: Using 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:

  • --local (default) for project-specific configuration
  • --project to share with your team via .mcp.json
  • --user to make available across all projects

Usage Examples

Command Line Parameters

Parameter Type Default Description
--transport Choice stdio Transport type: stdio, sse, or stream
--port Integer 8000 Port for sse/stream transport modes
--db-path String md: Path to DuckDB file or MotherDuck database
--motherduck-token String None MotherDuck access token
--read-only Flag False Connect in read-only mode
--home-dir String None Home directory for DuckDB
--saas-mode Flag False Connect in SaaS mode (restricted permissions)
--json-response Flag False Enable JSON responses for HTTP stream

Basic Command Examples

# Connect to local DuckDB file in read-only mode
uvx mcp-server-motherduck --transport stream --db-path /path/to/local.db --read-only

# Connect to MotherDuck with token
uvx mcp-server-motherduck --transport stream --db-path md: --motherduck-token YOUR_TOKEN

# Connect to MotherDuck in SaaS mode for enhanced security
uvx mcp-server-motherduck --transport stream --db-path md: --motherduck-token YOUR_TOKEN --saas-mode

Working with Local DuckDB

For in-memory database:

{
  "mcpServers": {
    "mcp-server-motherduck": {
      "command": "uvx",
      "args": [
        "mcp-server-motherduck",
        "--db-path",
        ":memory:"
      ]
    }
  }
}

For local DuckDB file:

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

For local DuckDB file in read-only mode:

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

Security Recommendations

For secure public deployment, use a read scaling token and SaaS mode:

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

Running in SSE Mode

Direct SSE Mode

uvx mcp-server-motherduck --transport sse --port 8000 --db-path md: --motherduck-token <your_motherduck_token>

Using Supergateway

npx -y supergateway --stdio "uvx mcp-server-motherduck --db-path md: --motherduck-token <your_motherduck_token>"

Troubleshooting

  • Verify your MotherDuck token is correct if experiencing connection issues
  • Ensure --home-dir is set correctly for local file access problems
  • Check that uvx is in your PATH
  • If you see spawn uvx ENOENT errors, try using the full path to uvx (output of which uvx)

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-server-motherduck" '{"command":"uvx","args":["mcp-server-motherduck","--db-path","md:","--motherduck-token","<YOUR_MOTHERDUCK_TOKEN_HERE>"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

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

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later