Query and analyze data with MotherDuck and local DuckDB
An MCP server implementation that interacts with DuckDB and MotherDuck databases, providing SQL analytics capabilities to AI Assistants and IDEs.
The server provides one prompt:
duckdb-motherduck-initial-prompt
: A prompt to initialize a connection to DuckDB or MotherDuck and start working with itThe server offers one tool:
query
: Execute a SQL query on the DuckDB or MotherDuck database
query
(string, required): The SQL query to executeAll interactions with both DuckDB and MotherDuck are done through writing SQL queries.
uv
installed, you can install it using pip install uv
or brew install uv
If you plan to use the MCP with Claude Desktop or any other MCP comptabile client, the client need to be installed.
Install Cursor from cursor.com/downloads if you haven't already
Open Cursor:
mcp.json
file to which you add the following configuration:{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
]
}
}
}
Add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P
and typing 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}"
]
}
}
}
}
Optionally, you can add it to a file called .vscode/mcp.json
in your workspace. This will allow you to share the configuration with others.
{
"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}"
]
}
}
}
Install Claude Desktop from claude.ai/download if you haven't already
Open the Claude Desktop configuration file:
claude_desktop_config.json
:{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
]
}
}
}
Important Notes:
YOUR_MOTHERDUCK_TOKEN_HERE
with your actual MotherDuck tokenYOUR_HOME_FOLDER_PATH
with the path to your home directory (needed by DuckDB for file operations). For example, on macOS, it would be /Users/your_username
HOME
environment variable is required for DuckDB to function properly.If the MCP server is exposed to third parties and should only have read access to data, we recommend using a read scaling token and running the MCP server in SaaS mode.
Read Scaling Tokens are special access tokens that enable scalable read operations by allowing up to 4 concurrent read replicas, improving performance for multiple end users while restricting write capabilities. Refer to the Read Scaling documentation to learn how to create a read-scaling token.
SaaS Mode in MotherDuck enhances security by restricting it's access to local files, databases, extensions, and configurations, making it ideal for third-party tools that require stricter environment protection. Learn more about it in the SaaS Mode documentation.
Secure Configuration
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_READ_SCALING_TOKEN_HERE>",
"--saas-mode"
]
}
}
}
To connect to a local DuckDB, instead of using the MotherDuck token, specify the path to your local DuckDB database file or use :memory:
for an in-memory database.
In-memory database:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
":memory:"
]
}
}
}
Local DuckDB file:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uvx",
"args": [
"mcp-server-motherduck",
"--db-path",
"/path/to/your/local.db"
]
}
}
}
Once configured, you can e.g. ask Claude to run queries like:
The server is designed to be run by tools like Claude Desktop and Cursor, but you can start it manually for testing purposes. When testing the server manually, you can specify which database to connect to using the --db-path
parameter:
Default MotherDuck database:
--motherduck-token
parameter.uvx mcp-server-motherduck --db-path md: --motherduck-token <your_motherduck_token>
Specific MotherDuck database:
uvx mcp-server-motherduck --db-path md:your_database_name --motherduck-token <your_motherduck_token>
Local DuckDB database:
uvx mcp-server-motherduck --db-path /path/to/your/local.db
In-memory database:
uvx mcp-server-motherduck --db-path :memory:
If you don't specify a database path but have set the motherduck_token
environment variable, the server will automatically connect to the default MotherDuck database (md:
).
The server could also be running SSE mode using supergateway
by running the following command:
npx -y supergateway --stdio "uvx mcp-server-motherduck --db-path md: --motherduck-token <your_motherduck_token>"
And you can point your clients such as Claude Desktop, Cursor to this endpoint.
To run the server from a local development environment, use the following configuration:
{
"mcpServers": {
"mcp-server-motherduck": {
"command": "uv",
"args": [
"--directory",
"/path/to/your/local/mcp-server-motherduck",
"run",
"mcp-server-motherduck",
"--db-path",
"md:",
"--motherduck-token",
"<YOUR_MOTHERDUCK_TOKEN_HERE>"
]
}
}
}
--home-dir
parameter is set correctlyuvx
command is available in your PATHspawn uvx ENOENT
errors, try specifying the full path to uvx
(output of which uvx
)This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
Knowledge graph-based persistent memory system
Read-only database access with schema inspection
Database interaction and business intelligence capabilities
Embeddings, vector search, document storage, and full-text search with the open-source AI application database
Query your ClickHouse database server.
Immutable ledger database with live synchronization
Provides AI assistants with a secure and structured way to explore and analyze data in GreptimeDB.
Connect to a Hologres instance, get table metadata, query and analyze data.
Open source MCP server specializing in easy, fast, and secure tools for Databases.
Search, Query and interact with data in your Milvus Vector Database.