metabase-cli
Command-line client for Metabase. Logs in to an instance in your browser (OAuth, Metabase v62.3.3+) or with an API key, and stores credentials securely on your machine.
Supported Metabase versions
The CLI is built against Metabase majors 58 through 66 (the client's KNOWN_RANGE), the latest patch of each; a newer release runs as the major after the newest known one, with one stderr notice per run; a development build (master or a local build, reporting a tag such as vUNKNOWN) is treated as newer than every release, with every version-gated command available and no notice; and an older one keeps its real major and gets one stderr notice per run pointing at a Metabase upgrade; a command the server refuses for a feature it lacks names that feature and the version it needs.
Every command declares the client methods it calls, and each method names the server features it needs — a feature is a minimum major version, a premium token feature, or both. The server decides whether a request is allowed: every command sends its requests, and when the server refuses one (an endpoint it does not serve, or a premium feature it does not grant), the CLI probes the server once and reports what is missing with an actionable message (exit code 2):
- the server is older than the command's minimum version, or
- the command needs a premium feature (e.g.
remote_sync, content_translation, library) that isn't enabled.
A license activated or a server upgraded after mb auth login takes effect on the next command; nothing has to be refreshed first. A request is refused before it is sent only where a server without the feature would answer wrongly without a word: a parameter it would drop or rewrite (table list --unused-only without the dependencies feature lists every table), or a call whose answer it would misread (git-sync's synced collections). The tracked branch is read from the same probe that judges it, and refused there before it is answered. The notes on db list, table list, table update, table bulk-edit, field update, field set-sensitivity, card query, query, subscription create, search, git-sync status, git-sync import, git-sync export and git-sync export-preflight name the parameters and calls refused this way. subscription update refuses non-empty parameters as create does, data-action update refuses a collection_id or table_id before Metabase v65, which drops it, and transform-test create and update refuse a non-null now before v66, which drops it. A field filter or temporal-unit tag that names its column only by field-id, with no dimension, is refused before v66 by card create, card update, data-action create, data-action update, document create and document update (over the inline cards), transform create and transform update (over a query source) and query --metadata, since such a server drops the key and would save or read the filter bound to no column; query runs, compiles and exports such a query on every server, and an older one fails it with its own error. A command run in a worktree (--worktree <id>, or a profile's stored worktree id) is refused before every request on a server without worktrees (before Metabase 66, or without the remote_sync token), which would ignore the choice and answer from the main app; --worktree main is sent to every server, since the main app is all such a server has. Such a refusal is judged against a probe taken in the same run, never the cached one, so the command costs at most one request more than it would otherwise, even when the cache grants the feature: a cache can be wrong in that direction too, after a license lapses.
These refusals are the CLI's own judgement, read from its table of which release and which premium feature brings each feature, so a feature backported to an older release, or a rule the table gets wrong, is refused although the server would serve it. --skip-preflight, taken by every command that takes --url and --api-key (all but auth list, auth status, auth logout, skills, uuid and upgrade, none of which makes these checks), or MB_CLI_SKIP_PREFLIGHT=1 in the environment, skips them, sends the request anyway and lets the server answer; a refusal of a feature the server lacks names the flag. Each check it lets through prints one stderr warning naming what was skipped, because a server that truly lacks the feature may ignore or rewrite what it does not support and answer without saying so; when the server cannot be checked at all, the request goes out unchecked with one warning per run. It skips nothing else: input the CLI rejects, a refusal read from the server's own settings (pivoted exports turned off, an unset or unreadable tracked branch), and a refusal the server answers itself stand as they are.