Execute a SQL query on the DuckDB or MotherDuck database
MotherDuck DuckDB provides a powerful SQL analytics interface for AI assistants and IDEs, enabling seamless interaction with both local DuckDB databases and cloud-based MotherDuck services. This MCP server allows you to query data of any size using DuckDB's SQL dialect, access cloud storage integrations, and share databases across your organization. With hybrid execution capabilities, you can work with local files or connect to MotherDuck's cloud service for more complex analytics needs. The serverless architecture eliminates the need to configure instances or clusters, making it ideal for data analysis workflows directly from your AI assistant or development environment.
MotherDuck DuckDB is an MCP server that enables AI assistants and IDEs to interact with DuckDB and MotherDuck databases through SQL queries. It provides a seamless way to analyze data locally or in the cloud without leaving your development environment.
Before getting started, you'll need:
uv
package manager installed (install via pip install uv
or brew install uv
)No special prerequisites are needed for local DuckDB usage, as the MCP server can create an in-memory database on-the-fly or connect to existing database files.
claude_desktop_config.json
:{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"YOUR_MOTHERDUCK_TOKEN_HERE"
]
}
}
}
mcp.json
file that opens, add:{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"YOUR_MOTHERDUCK_TOKEN_HERE"
]
}
}
}
Ctrl + Shift + P
and type Preferences: Open User Settings (JSON)
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "motherduck_token",
"description": "MotherDuck Token",
"password": true
}
],
"servers": {
"motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"${input:motherduck_token}"
]
}
}
}
}
Alternatively, you can create a .vscode/mcp.json
file in your workspace with similar configuration to share it with your team.
The MCP server accepts several configuration options:
--db-path
: Specifies the database path
md:
for MotherDuck cloud databasemy_database.db
)--motherduck-token
: Your MotherDuck authentication token (required for cloud functionality)--saas-mode
: Enable SaaS mode for additional featuresOnce installed, you can interact with your database using SQL queries. Here are some examples:
CREATE TABLE users (id INTEGER, name VARCHAR, email VARCHAR);
INSERT INTO users VALUES (1, 'John Doe', 'john@example.com'), (2, 'Jane Smith', 'jane@example.com');
SELECT * FROM users WHERE id = 1;
CREATE TABLE sales AS SELECT * FROM read_csv_auto('/path/to/sales.csv');
SELECT * FROM 'md:my_shared_database.public.customer_data';
When using the MotherDuck token, be careful not to expose it in shared configurations or public repositories. Consider using environment variables or secure credential storage for production environments.