Registry / database / mcp-server-duckdb

mcp-server-duckdb

JSON →
library1.1.0pypypiunverified

mcp-server-duckdb is a Python library that provides a Micro-Capability Platform (MCP) server exposing a DuckDB database via HTTP. It allows clients to execute SQL queries against a DuckDB instance, supporting both read and write operations, and a read-only mode. The current version is 1.1.0, with an active, feature-driven release cadence.

pip install mcp-server-duckdb
INSTALL
IMPORT
SIG · MCP-SERVER-DUCKDB
M
mcp-server-duckdb
databasepythonv1.1.0
Install
7.1s avg
Import
Disk
114MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 8.35s
py 3.11
✕ build_error
✓ 7.8s
py 3.12
✕ build_error
✓ 5.75s
py 3.13
✕ build_error
✓ 6.45s
py 3.9
✕ build_error
✕ build_error
114MB installed
● package 114MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

run_server
from mcp_server_duckdb.server import run_server
from mcp_server_duckdb import run_server

This quickstart demonstrates how to start the `mcp-server-duckdb` server programmatically and then interact with it using HTTP requests. It creates a simple table, inserts data, and queries it. For persistent databases, specify a file path with `--db-path` when starting the server.

import os import requests from subprocess import Popen, PIPE, TimeoutExpired import time # Start the server in a separate process # For simplicity, we use a temporary in-memory database here # In production, specify a persistent .duckdb file, e.g., --db-path my_database.duckdb print('Starting mcp-server-duckdb...') server_process = Popen(['mcp-server-duckdb', '--port', '8001'], stdout=PIPE, stderr=PIPE) time.sleep(2) # Give the server a moment to start # Example: Send a query try: # Create a table response = requests.post( 'http://localhost:8001/queries', json={'query': "CREATE TABLE users (id INTEGER, name VARCHAR);"} ) response.raise_for_status() print('CREATE TABLE response:', response.json()) # Insert data response = requests.post( 'http://localhost:8001/queries', json={'query': "INSERT INTO users VALUES (1, 'Alice'), (2, 'Bob');"} ) response.raise_for_status() print('INSERT INTO response:', response.json()) # Select data response = requests.post( 'http://localhost:8001/queries', json={'query': "SELECT * FROM users;"} ) response.raise_for_status() print('SELECT * response:', response.json()) except requests.exceptions.RequestException as e: print(f"Error communicating with server: {e}") finally: # Terminate the server process print('Stopping mcp-server-duckdb...') server_process.terminate() try: stdout, stderr = server_process.communicate(timeout=5) print('Server stdout:', stdout.decode()) print('Server stderr:', stderr.decode()) except TimeoutExpired: server_process.kill() stdout, stderr = server_process.communicate() print('Server (killed) stdout:', stdout.decode()) print('Server (killed) stderr:', stderr.decode())
Debug
Known issues
breakingThe API for database queries was consolidated into a single `/queries` endpoint. Before v1.0.0, there were separate endpoints for read and write operations (e.g., `/read-query`, `/write-query`).
fix
Migrate all database interactions to use the `/queries` endpoint with a single `query` parameter in the request body.
affects: <1.0.0
gotchaTemporary tables and macros created within a session will not persist across multiple queries by default. Each query opens and closes a new DuckDB connection.
fix
Update to v1.1.0 or later and start the server with the `--keep-connection` flag to maintain a persistent DuckDB connection across queries.
affects: <1.1.0
gotchaAttempting write operations (e.g., INSERT, UPDATE, CREATE TABLE) when the server is started with the `--readonly` flag will result in an error.
fix
Ensure the server is not started with `--readonly` if write operations are intended. If using an older version (<0.2.2), fix for readonly logic might be necessary.
affects: >=0.2.0
Upgrade
Version history
1.1.0latest on PyPI · released May 5, 2025
Audit
Dependencies
duckdbrequiredCore database engine for query execution.
fastapirequiredWeb framework used to build the HTTP server API.
uvicornrequiredASGI server to run the FastAPI application.
Agent activity
21 hits · last 30 days
node
20
Resources
mcp-server-duckdb — pip install mcp-server-duckdb · libregistry