Connecting to MotherDuck
MotherDuck is a serverless analytics platform built on DuckDB. The MCP server supports both read-write and read-scaling connections.Read-Write Connection
For full read and write access to your MotherDuck databases:Get your MotherDuck token from motherduck.com/settings/tokens
Read-Scaling Connection
For high-performance read-only access with automatic scaling:SaaS Mode (Secure Deployments)
SaaS mode restricts local filesystem access for secure third-party deployments:Querying MotherDuck Databases
Query Shared Sample Data
MotherDuck provides sample datasets for exploration:List MotherDuck Databases
Use thelist_databases tool to see all available databases:
Query Your Own Databases
Cross-Database Queries
Query across multiple databases in a single SQL statement:Attaching Multiple Databases
You can attach and query multiple MotherDuck databases simultaneously.Attach Additional Databases
List Attached Databases
Query Across Attached Databases
MotherDuck-Specific Features
Check Current Database
MotherDuck Metadata Function
MotherDuck provides special functions for database metadata:Check Connection Type
Verify if you’re using a read-scaling connection:Read-scaling connections have duckling IDs ending with
.rs.{number} (e.g., my_database.rs.3), while read-write connections end with .rw.Hybrid Local + Cloud Queries
Combine local DuckDB files with MotherDuck cloud databases in the same query.Attach Local Database to MotherDuck Session
Query Local and Cloud Together
Export Cloud Data to Local
Connection Parameters
Customize MotherDuck connection behavior with additional parameters:Default Parameters
The server includes these parameters by default:session_hint=mcp- Identifies MCP sessions in MotherDuck logsdbinstance_inactivity_ttl=0s- Keeps connections alive indefinitely
Best Practices
Use Read-Scaling for Analytics
Read-scaling tokens provide better performance for read-heavy analytical workloads with automatic horizontal scaling.
Service Accounts for Production
Use service accounts instead of personal tokens for production deployments.
Enable SaaS Mode
When giving third-party access, enable
--motherduck-saas-mode to restrict local filesystem access.Filter Cloud Queries
Always use WHERE clauses and LIMIT when querying large cloud datasets to minimize data transfer.
Troubleshooting
Token Authentication Errors
Error: “Please set themotherduck_token or MOTHERDUCK_TOKEN as an environment variable”
Solution: Set the token in your MCP configuration:
Read-Scaling Token Required
Error: “The —read-only flag with MotherDuck requires a read-scaling token” Solution: Either:- Use a read-scaling token instead of a regular token, OR
- Add
--read-writeflag to use regular tokens