DuckDB MCP Server

DuckDB MCP Server

A beginner-friendly MCP server that exposes a run_sql tool for querying a DuckDB employee database, returning results as Markdown tables. It enables AI assistants to run SQL queries through the Model Context Protocol.

Category
Visit Server

README

DuckDB MCP Server

Tool preview

This project is a small Model Context Protocol (MCP) server that lets you query a DuckDB-based employee database through a simple tool interface. It is a beginner-friendly example for exploring how MCP servers work and how SQL can be exposed to AI assistants or local tools.

If you are new to this project, the best way to start is:

  1. set up the environment,
  2. seed the sample database,
  3. run the MCP server locally,
  4. try a few SQL queries.

What this project does

The server exposes a single tool named run_sql that accepts a SQL statement and returns the result as a Markdown table. The sample database contains employee, department, salary, and attendance data so you can explore join queries and reporting-style SQL.

Project files

  • duck_db_mcp.py - the MCP server implementation
  • seed_employee_db.py - creates and populates the DuckDB database
  • employee.duckdb - the generated database file
  • pyproject.toml - project dependencies
  • Makefile - helper commands for setup

Quick start

1. Create and activate a virtual environment

uv init
uv venv

2. Install dependencies

uv add "mcp[cli]" fastmcp duckdb pandas tabulate

3. Create the sample database

make setup-db

You can also run this directly:

python3 seed_employee_db.py

Run the MCP server locally

Test the server in development mode

mcp dev duck_db_mcp.py

Or with uv:

uv run mcp dev duck_db_mcp.py

Install the MCP server

mcp install duck_db_mcp.py

Start exploring

Once the server is running, try simple queries like these:

Example: list employees and departments

SELECT
    e.first_name,
    e.last_name,
    d.department_name
FROM employee e
JOIN department d
    ON e.department_id = d.department_id
ORDER BY e.last_name;

Example: view salary information

SELECT
    e.first_name,
    e.last_name,
    s.net_salary,
    s.pay_month
FROM employee e
JOIN salary s
    ON e.employee_id = s.employee_id
ORDER BY s.net_salary DESC;

Example: employee attendance summary

SELECT
    e.first_name,
    e.last_name,
    a.attendance_date,
    a.status
FROM employee e
JOIN attendance a
    ON e.employee_id = a.employee_id
ORDER BY a.attendance_date, e.last_name;

Claude Desktop MCP config

If you want to use this server from Claude Desktop, install it first:

mcp install duck_db_mcp.py

A typical configuration looks like this:

{
  "DuckDB SQL Server": {
    "command": "/opt/homebrew/bin/uv",
    "args": [
      "run",
      "--frozen",
      "--with",
      "mcp[cli]",
      "mcp",
      "run",
      "/Users/rahulkumar/Desktop/AI/mcp_server_learning/duck_db_mcp/duck_db_mcp.py"
    ],
    "env": {
      "VIRTUAL_ENV": "/Users/rahulkumar/Desktop/AI/mcp_server_learning/duck_db_mcp/.venv",
      "PATH": "/Users/rahulkumar/Desktop/AI/mcp_server_learning/duck_db_mcp/.venv/bin:/opt/homebrew/bin:/usr/bin:/bin"
    }
  }
}

Install from GitHub

If you want someone else to install this package directly from GitHub, use this command:

uvx --from git+https://github.com/panditrahulsharma/duck_db_mcp.git duck_mcp

For Claude Desktop, the config can look like this:

{
  "mcpServers": {
    "DuckDB SQL Server": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/panditrahulsharma/duck_db_mcp.git",
        "duck_mcp"
      ]
    }
  }
}

Make sure the latest changes in pyproject.toml and duck_db_mcp.py have been committed and pushed to GitHub before trying this install method.

Git MCP config

If you also want to use Git-related MCP tools, you can add a Git MCP server configuration in the same client config. A typical example is:


{
  "mcpServers": {

    "DuckDB SQL Server": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/panditrahulsharma/duck_db_mcp.git",
        "duck_mcp"
      ]
    }
  }
}

This is useful when you want your MCP client to access Git operations such as status, diff, branch, and commit history while working with this project.

Notes for contributors

When adding or changing tools, make sure the docstring is clear and descriptive. A well-written docstring helps MCP clients understand what the tool does and how to use it correctly.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured