Execute any SQL query on the DuckDB database
DuckDB MCP Server provides a seamless interface for interacting with DuckDB databases through the Model Context Protocol. It enables AI assistants to execute SQL queries, create tables, inspect schemas, and perform data analysis directly on DuckDB databases. With this server, you can leverage DuckDB's powerful analytical capabilities for local data processing without needing complex setup or infrastructure. The server supports both read-write and read-only modes, making it suitable for both data exploration and modification scenarios.
DuckDB MCP Server enables AI assistants to interact with DuckDB databases through SQL queries. DuckDB is an in-process analytical database system designed for local data analysis, making it perfect for working with CSV files, Parquet files, and other data sources without requiring a separate database server.
pip install mcp-server-duckdb
uv pip install mcp-server-duckdb
The server requires a path to a DuckDB database file and offers optional parameters for customizing behavior.
--readonly: Run server in read-only mode (default: false)
--keep-connection: Re-use a single DuckDB connection (default: false)
To start the server with a new or existing database:
mcp-server-duckdb /path/to/your/database.db
To start the server in read-only mode:
mcp-server-duckdb /path/to/your/database.db --readonly
To start the server with a persistent connection:
mcp-server-duckdb /path/to/your/database.db --keep-connection
Once the server is running, you can use the query
tool to interact with the database. Here are some example operations:
Create a table:
CREATE TABLE users (id INTEGER, name VARCHAR, email VARCHAR);
Insert data:
INSERT INTO users VALUES (1, 'John Doe', 'john@example.com');
Query data:
SELECT * FROM users WHERE id = 1;
Get schema information:
PRAGMA table_info(users);
Load data from CSV:
CREATE TABLE data AS SELECT * FROM read_csv_auto('/path/to/file.csv');
The server will return query results as text, or success messages for operations like CREATE and INSERT.