DuckDB Data Analysis
STDIOMCP server implementation enabling AI assistants to interact with DuckDB for data analysis.
MCP server implementation enabling AI assistants to interact with DuckDB for data analysis.
A Model Context Protocol (MCP) server implementation that enables AI assistants like Claude to interact with DuckDB for powerful data analysis capabilities.
DuckDB MCP Server connects AI assistants to DuckDB - a high-performance analytical database - through the Model Context Protocol (MCP). This allows AI models to:
pip install duckdb-mcp-server
git clone https://github.com/mustafahasankhan/duckdb-mcp-server.git cd duckdb-mcp-server pip install -e .
duckdb-mcp-server --db-path path/to/database.db [options]
--db-path
- Path to DuckDB database file (will be created if doesn't exist)--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 variablesInstall Claude Desktop from claude.ai/download
Edit Claude Desktop's configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
Add DuckDB MCP Server configuration:
{ "mcpServers": { "duckdb": { "command": "duckdb-mcp-server", "args": [ "--db-path", "~/claude-duckdb/data.db" ] } } }
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;
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;
DuckDB MCP Server handles AWS authentication in this order:
--creds-from-env
is enabled)--s3-profile
)# Clone the repository git clone https://github.com/yourusername/duckdb-mcp-server.git cd duckdb-mcp-server # Set up a virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install in development mode pip install -e ".[dev]" # Run tests pytest
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.