DuckDB MCP server

Enables AI to query and analyze data through DuckDB, an in-process analytical database optimized for OLAP workloads with direct support for CSV, Parquet, and JSON files including remote sources like S3.
Back to servers
Setup instructions
Provider
Mustafa Hasan Khan
Release date
Apr 21, 2025
Language
Python
Package
Stats
531 downloads
7 stars

DuckDB MCP Server connects AI assistants like Claude to DuckDB, a high-performance analytical database, through the Model Context Protocol (MCP). This enables AI models to query data from various sources, access cloud storage data, and perform sophisticated data analysis using SQL.

Installation

Using pip

pip install duckdb-mcp-server

From source

git clone https://github.com/mustafahasankhan/duckdb-mcp-server.git
cd duckdb-mcp-server
pip install -e .

Requirements

  • Python 3.10+
  • An MCP-compatible client (Claude Desktop, Cursor, VS Code with Copilot, etc.)

Configuration

Command Line Options

duckdb-mcp-server --db-path path/to/database.db [options]

Required Parameters:

  • --db-path - Path to DuckDB database file (will be created if doesn't exist)

Optional Parameters:

  • --readonly - Run in read-only mode (will error if database doesn't exist)
  • --s3-region - AWS S3 region (default: uses AWS_DEFAULT_REGION env var)
  • --s3-profile - AWS profile for S3 credentials (default: uses AWS_PROFILE or 'default')
  • --creds-from-env - Use AWS credentials from environment variables

Setting Up with Claude Desktop

  1. Install Claude Desktop from claude.ai/download

  2. Edit Claude Desktop's configuration file:

    macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    Windows: %APPDATA%/Claude/claude_desktop_config.json

  3. Add DuckDB MCP Server configuration:

{
  "mcpServers": {
    "duckdb": {
      "command": "duckdb-mcp-server",
      "args": [
        "--db-path",
        "~/claude-duckdb/data.db"
      ]
    }
  }
}

Example Usage

Once configured, you can ask your AI assistant to analyze data using DuckDB:

"Load the sales.csv file and show me the top 5 products by revenue"

The AI will generate and execute the appropriate SQL:

-- Load and query the CSV data
SELECT 
    product_name,
    SUM(quantity * price) AS revenue
FROM read_csv('sales.csv')
GROUP BY product_name
ORDER BY revenue DESC
LIMIT 5;

Working with S3 Data

Query data directly from S3 buckets:

"Analyze the daily user signups from our analytics data in S3"

The AI will generate appropriate SQL to query S3:

SELECT 
    date_trunc('day', signup_timestamp) AS day,
    COUNT(*) AS num_signups
FROM read_parquet('s3://my-analytics-bucket/signups/*.parquet')
GROUP BY day
ORDER BY day DESC;

Cloud Storage Authentication

DuckDB MCP Server handles AWS authentication in this order:

  1. Explicit credentials (if --creds-from-env is enabled)
  2. Named profile credentials (via --s3-profile)
  3. Default credential chain (environment, shared credentials file, etc.)

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 "duckdb" '{"command":"duckdb-mcp-server","args":["--db-path","~/claude-duckdb/data.db"]}'

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": {
        "duckdb": {
            "command": "duckdb-mcp-server",
            "args": [
                "--db-path",
                "~/claude-duckdb/data.db"
            ]
        }
    }
}

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": {
        "duckdb": {
            "command": "duckdb-mcp-server",
            "args": [
                "--db-path",
                "~/claude-duckdb/data.db"
            ]
        }
    }
}

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