# MotherDuck CLI
CLI for the [MotherDuck REST API](https://motherduck.com/docs/sql-reference/rest-api/motherduck-rest-api/).
[](https://github.com/lostmygithubaccount/md-cli/releases)
[](https://pypi.org/project/dkdc-md-cli/)
[](https://crates.io/crates/dkdc-md-cli)
[](https://github.com/lostmygithubaccount/md-cli/actions/workflows/ci.yml)
[](https://github.com/lostmygithubaccount/md-cli/blob/main/LICENSE)
**Important**: This is a personal project. I am not affiliated with MotherDuck.
## Install
Recommended:
```bash
Pre-built binaries are available for Linux and macOS via Python (`uv`). Windows users should install via `cargo` or use macOS/Linux.
uv:
```bash
uv tool install dkdc-md-cli
```
cargo:
```bash
cargo install dkdc-md-cli
```
Either option will install the `md` command globally. You can use `uvx` to run it without installing:
```bash
uvx --from dkdc-md-cli md
```
## Authentication
Set a MotherDuck API token via environment variable:
```bash
export MOTHERDUCK_TOKEN="your-token-here"
```
Token resolution order (first non-empty wins):
1. `--token` flag (pass `-` to read from stdin)
2. `motherduck_token`
3. `MOTHERDUCK_TOKEN`
4. `motherduck_api_key`
5. `MOTHERDUCK_API_KEY`
## Usage
```
md [--output text|json] [--token TOKEN] [--yes] <command>
```
### Global flags
| `--output` | `-o` | Output format: `text` (default) or `json` |
| `--token` | | API token (overrides env vars; `-` reads from stdin) |
| `--yes` | `-y` | Skip confirmation prompts |
### `service-account`
```bash
# Create a service account
md service-account create <username>
# Delete a service account (prompts for confirmation)
md service-account delete <username>
```
### `token`
```bash
# List tokens for a user
md token list <username>
# Create a new token
md token create <username> --name <name> [--ttl <seconds>] [--token-type <type>]
# Delete a token (prompts for confirmation)
md token delete <username> <token_id>
```
`--ttl`: time-to-live in seconds (300–31536000). Omit for no expiration.
`--token-type`: `read-write` (default) or `read-scaling`.
### `duckling`
```bash
# Get current duckling config
md duckling get <username>
# Set duckling config (at least one override required)
md duckling set <username> [--rw-size <size>] [--rs-size <size>] [--flock-size <n>]
```
Instance sizes: `pulse`, `standard`, `jumbo`, `mega`, `giga`.
Flock size: 0–64. `duckling set` fetches the current config and merges your overrides, so you only need to specify what you're changing.
### `account`
```bash
# List active accounts and their ducklings
md account list-active
```