A Model Context Protocol (MCP) server implementation for DuckDB, exposing a single versatile SQL “query” tool that lets LLMs read/write a local DuckDB database (with optional read-only mode).
https://github.com/ktanaka101/mcp-server-duckdbStop wrestling with complex database APIs when you need LLM-powered data analysis. This MCP server turns any DuckDB database into a conversational interface that your LLM can query directly—with a single, unified SQL endpoint that trusts your LLM to generate the right queries.
Most database MCP servers fragment functionality across dozens of tools: create_table, insert_data, select_rows, join_tables—you get the idea. This approach creates unnecessary complexity and forces you to manage multiple tool calls for simple operations.
This server takes a different approach: one versatile query tool that accepts any valid DuckDB SQL. Your LLM generates the appropriate SQL whether it's analyzing CSV files, creating complex joins, or building analytical pipelines. Modern LLMs excel at SQL generation—why not leverage that instead of constraining them with rigid tool boundaries?
DuckDB isn't just another database—it's built specifically for analytical workloads. You get:
SELECT * FROM read_csv_auto('data.csv') and you're analyzing data immediatelyCSV Analysis Made Trivial
-- Your LLM can instantly analyze any CSV file
SELECT customer_segment, AVG(revenue), COUNT(*)
FROM read_csv_auto('sales_data.csv')
GROUP BY customer_segment
ORDER BY AVG(revenue) DESC;
Multi-file Analysis Without ETL
-- Analyze multiple Parquet files as if they were one table
SELECT date_trunc('month', order_date) as month,
SUM(total_amount) as monthly_revenue
FROM read_parquet('orders/*.parquet')
WHERE order_date >= '2024-01-01'
GROUP BY month;
Safe Exploration with Read-Only Mode Perfect for letting LLMs analyze production data exports without risk:
uvx mcp-server-duckdb --db-path ./production_export.db --readonly
Claude Desktop Setup (2 minutes):
{
"mcpServers": {
"duckdb": {
"command": "uvx",
"args": [
"mcp-server-duckdb",
"--db-path",
"~/analysis/data.db"
]
}
}
}
Performance Optimization:
"args": [
"mcp-server-duckdb",
"--db-path", "~/analysis/data.db",
"--keep-connection"
]
The --keep-connection flag maintains a persistent database connection, enabling TEMP tables and faster query execution—crucial for complex analytical workflows.
Data Scientists: Skip the Jupyter setup for quick data exploration. Your LLM becomes an interactive SQL analyst that can pivot between different analytical approaches in seconds.
DevOps Teams: Analyze log files, metrics, or deployment data stored in CSV/Parquet format. Your LLM can correlate across multiple data sources and identify patterns you might miss.
Product Teams: Quick analysis of user behavior data exports. Ask natural language questions and get SQL-powered insights without learning BI tools.
Financial Analysis: Process transaction data, calculate rolling averages, identify trends—all through conversational queries that generate the exact SQL needed.
DuckDB's analytical capabilities mean your LLM can perform sophisticated operations:
Your LLM gets access to all of this through natural language—no need to remember specific function syntax or analytical patterns.
Automatic Installation:
npx -y @smithery/cli install mcp-server-duckdb --client claude
Manual Setup:
uvx mcp-server-duckdb --db-path ~/your-data/analysis.db
The server automatically creates the database file and directory structure if they don't exist. For read-only analysis of existing databases, add the --readonly flag to prevent any modifications.
Development and Debugging:
npx @modelcontextprotocol/inspector uv run mcp-server-duckdb --db-path ./test.db
The MCP Inspector provides real-time visibility into query execution and results—essential for debugging complex analytical workflows.
This isn't just another database connector—it's a complete analytical environment that makes your LLM significantly more capable at data work. The combination of DuckDB's analytical power and a unified SQL interface creates workflows that weren't practical before.