MotherDuck CLI — install, auth, and connect
Last updated: 2026-04-09
Audience: Anyone using DuckDB CLI against Brainforge’s MotherDuck org (data engineering, analytics, agents).
Purpose
Single place for installing the DuckDB CLI, persisting authentication so you are not prompted in every new shell, and verifying a connection. Client-specific load steps (e.g. Default CSV exports) live in separate playbooks.
Related docs
| Doc | Use when |
|---|---|
| MotherDuck — Default export load | Landing Default product CSV exports into my_db / raw_export |
| MotherDuck: Brainforge warehouse overview | What databases/schemas exist (raw_export, raw_data, etc.) |
| MotherDuck: Default export pipeline (engineering) | Pipeline layout, script names, runtime expectations |
Official MotherDuck: DuckDB CLI + MotherDuck, Authenticating to MotherDuck.
1. Install (one-time per machine)
macOS (MotherDuck installer):
curl -s https://install.motherduck.com | shAdd the CLI to your PATH (installer usually suggests):
export PATH="$HOME/.duckdb/cli/latest:$PATH"Homebrew users may use brew install duckdb if versions remain compatible with MotherDuck; see MotherDuck’s version notes in their CLI doc.
Verify:
duckdb --version2. Persist auth (stops repeated browser prompts)
Each run of duckdb "md:" in a new shell without a token can open MotherDuck SSO. Set MOTHERDUCK_TOKEN once per machine so routine CLI use and Cursor agents do not keep asking you to authenticate.
- Interactive session:
duckdb, thenATTACH 'md:';— complete browser login if prompted. - In the same session:
PRAGMA PRINT_MD_TOKEN;— copy the value (secret; never commit it). - Persist it, for example:
export MOTHERDUCK_TOKEN='…'in~/.zshrc/~/.bashrc, or- Store in 1Password and
export MOTHERDUCK_TOKEN="$(op read 'op://Vault/Item/field')", or - Cursor: env that applies to integrated terminal / agent runs (gitignored
.env.localonly if your workflow loads it).
- New terminal — verify (should not open a browser):
duckdb "md:" -c "SHOW DATABASES;"Agents: Do not run duckdb "md:" in automation unless MOTHERDUCK_TOKEN is set for that process.
3. Quick queries after connect
SHOW ALL TABLES;
-- or scope to one database:
SHOW TABLES FROM raw_export;Discover tables by name:
SELECT database_name, schema_name, table_name
FROM duckdb_tables()
WHERE lower(table_name) LIKE '%your_pattern%'
ORDER BY 1, 2, 3;4. Troubleshooting
| Symptom | What to do |
|---|---|
| Browser SSO every time | Set and export MOTHERDUCK_TOKEN (§2); confirm new shells echo ${MOTHERDUCK_TOKEN:+set} shows set. |
| Non-interactive / CI failures | Same — token in env; no TTY for browser. |
| Version mismatch | Align DuckDB CLI with MotherDuck-supported versions per their docs. |