DuckDB MCP Extension logo

DuckDB MCP Extension

Community
teaguesterling

A simple MCP server extension for DuckDB

Publisherteaguesterling
Repositoryduckdb_mcp
LanguageC++
Forks
8
Stars
66
Available tools
0
Transport typestdio
Categories
LicenseApache-2.0
Links
  • Connect tools to AI workflows

    DuckDB MCP Extension exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    66 stars and 8 forks from the linked repository.

DuckDB MCP Extension

Documentation License: Apache 2.0

A Model Context Protocol (MCP) extension for DuckDB that enables seamless integration between SQL databases and AI assistants like Claude.

Features

  • Run as MCP Server: Expose your DuckDB database to AI assistants with built-in tools for querying, describing, and exploring data
  • HTTP Transport: Run as an HTTP server with authentication for web-based clients
  • Act as MCP Client: Connect to external MCP servers and query their resources using SQL
  • Custom Tools: Publish parameterized SQL queries as tools that AI assistants can discover and call
  • Multiple Formats: Output results as JSON, JSONL, Markdown (token-efficient), CSV, or plain text

Quick Start

As an MCP Server (for AI Assistants)

Create init-server.sql:

sql
LOAD 'duckdb_mcp';

CREATE TABLE products (id INT, name VARCHAR, price DECIMAL(10,2));
INSERT INTO products VALUES (1, 'Widget', 9.99), (2, 'Gadget', 24.99);

PRAGMA mcp_server_start('stdio');

Add to Claude Desktop configuration:

json
{
  "mcpServers": {
    "my-database": {
      "command": "duckdb",
      "args": ["-init", "/path/to/init-server.sql"]
    }
  }
}

Now Claude can query your database directly!

As an HTTP Server

Run DuckDB as an HTTP server that any HTTP client can connect to:

sql
LOAD 'duckdb_mcp';

-- Start HTTP server with authentication
PRAGMA mcp_server_start('http', 'localhost', 8080, '{"auth_token": "secret"}');

Then connect via HTTP:

bash
# Health check
curl http://localhost:8080/health

# Query with authentication
curl -X POST http://localhost:8080/mcp \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer secret" \
    -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"query","arguments":{"sql":"SELECT 1"}}}'

As an MCP Client

Windows: MCP client connections are not available — attaching to a server means spawning it over stdio, which is not implemented on Windows (#67). Use WSL. Running DuckDB as an MCP server works on Windows.

sql
LOAD 'duckdb_mcp';

-- Connect to an MCP server
ATTACH 'python3' AS server (TYPE mcp, ARGS '["path/to/server.py"]');

-- Read data through MCP
SELECT * FROM read_csv('mcp://server/file:///data.csv');

-- Call tools
SELECT mcp_call_tool('server', 'analyze', '{"dataset": "sales"}');

Built-in Server Tools

ToolDescription
queryExecute SQL SELECT queries (supports json/markdown/csv format)
describeGet table or query schema information
list_tablesList all tables and views
database_infoGet database overview
exportExport query results to files
executeRun DDL/DML statements (disabled by default)

Each is individually switchable in the server config, and builtin_tools turns the whole set off at once — for a server that should publish only its own curated tools:

sql
-- Publish only what mcp_publish_tool registered; no query/export/describe/...
PRAGMA mcp_server_start('stdio', 'localhost', 0, '{"builtin_tools": false}');

-- Or keep just one of them
PRAGMA mcp_server_start('stdio', 'localhost', 0,
    '{"builtin_tools": false, "enable_query_tool": true}');

An explicit enable_<tool>_tool always wins over builtin_tools, whichever order they appear in. builtin_tools: true means the default set, so it never switches on execute. See configuration reference.

Publishing Custom Tools

sql
-- 5-arg form (JSON output, the default)
PRAGMA mcp_publish_tool(name, description, sql_template, properties_json, required_json);

-- 6-arg form (explicit output format: 'json', 'markdown', or 'csv')
PRAGMA mcp_publish_tool(name, description, sql_template, properties_json, required_json, format);

All parameters are VARCHAR. Pass JSON as string literals, not json_object(...) or JSON type expressions.

Example:

sql
PRAGMA mcp_publish_tool(
    'search_products',                                                      -- name
    'Search products by name with optional category filter',                -- description
    'SELECT * FROM products
     WHERE name ILIKE ''%'' || $query || ''%''
       AND ($category IS NULL OR category = $category)',                    -- sql_template ($param placeholders)
    '{
        "query": {"type": "string", "description": "Search term"},
        "category": {"type": "string", "description": "Category filter"}
    }',                                                                     -- properties_json (JSON Schema)
    '["query"]',                                                            -- required_json (category is optional)
    'markdown'                                                              -- format
);

Optional parameters omitted by callers are substituted as SQL NULL. See the Custom Tools Guide for full details.

PRAGMA vs SELECT

All server management and publishing functions are available in two forms:

FormWhen to useExample
PRAGMAInit scripts, fire-and-forgetPRAGMA mcp_server_start('stdio');
SELECTWhen you need the return valueSELECT mcp_server_status();

PRAGMA versions produce no output, making init scripts clean. SELECT versions return status messages or structs.

Documentation

Full documentation is available at duckdb-mcp.readthedocs.io

Examples

The examples/ directory contains ready-to-use configurations:

ExampleDescription
01-simpleMinimal setup
02-configuredCustom configuration
03-with-dataE-commerce schema with data
04-securitySecurity hardening
05-custom-toolsCustom SQL tools
06-comprehensiveFull SaaS application
11-http-serverHTTP server with authentication

Installation

bash
# Clone and build
git clone https://github.com/teague/duckdb_mcp.git
cd duckdb_mcp
make

# Run
./build/release/duckdb
sql
LOAD 'duckdb_mcp';

Testing

bash
make test

License

Apache License 2.0 - see LICENSE and NOTICE for details.

Installation

TypingMind
{
  "mcpServers": {
    "duckdb-mcp": {
      "command": "duckdb",
      "args": [
        "-init",
        "/path/to/init-server.sql"
      ]
    }
  }
}

Use DuckDB MCP Extension MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once DuckDB MCP Extension is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add DuckDB MCP Extension as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the DuckDB MCP Extension MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "duckdb-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the DuckDB MCP Extension MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the DuckDB MCP Extension MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use DuckDB MCP Extension to help me with this task?
DuckDB MCP Extension
Sure. I read it.
Here is what I found using DuckDB MCP Extension.

Frequently asked questions

What is the DuckDB MCP Extension MCP server used for?

DuckDB MCP Extension is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use DuckDB MCP Extension MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use DuckDB MCP Extension with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use DuckDB MCP Extension MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With DuckDB MCP Extension connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect DuckDB MCP Extension MCP to TypingMind?

DuckDB MCP Extension runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does DuckDB MCP Extension MCP provide in TypingMind?

DuckDB MCP Extension exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use DuckDB MCP Extension MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If DuckDB MCP Extension requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇