Add agent-friendly enhancements (Step 13)#3
Merged
andreagrandi merged 7 commits intomasterfrom Mar 5, 2026
Merged
Conversation
Embeds a structured markdown reference document via go:embed that describes all commands, flags, authentication, name resolution, and common pitfalls for AI agents.
Lists all commands as JSON or prints detailed schema for a specific command including args, flags, types, defaults, enums, and output keys.
Default --format is now `table` in TTY and `json` when piped. Explicit --format flag always overrides auto-detection.
Errors are classified as CONFIG_ERROR, AUTH_ERROR, API_ERROR, RESOLUTION_ERROR, or GENERAL_ERROR with optional suggestions.
Validates SQL queries and search input for control characters and max length before sending to the Metabase API.
Filters output columns on `query sql` and `card run` to reduce output size for agent context windows. Marks Step 13 complete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mb-cli context- Embedded markdown reference document for AI agents with all commands, flags, authentication, name resolution, and common pitfallsmb-cli schema [command]- JSON introspection of all commands with args, flags, types, defaults, enums, and output keys--formatistablein TTY,jsonwhen piped--error-format json- Structured JSON error output on stderr with error type classification (CONFIG, AUTH, API, RESOLUTION, GENERAL)--fieldsflag - Filter output columns onquery sqlandcard runto reduce output size for agent context windowsTest plan
make testpasses (all new tests for context, schema, tty, error_format, validation, fields_filter)mb-cli context | headprints agent referencemb-cli schema | jq .lists all commands as valid JSONmb-cli schema "query sql" --prettyshows args/flags/defaults--formatoverridesMB_HOST="" mb-cli database list --error-format jsonoutputs structured JSON error on stderrmb-cli query sql --db 71 --sql "SELECT 1 AS id, 'Alice' AS name, 'a@b.com' AS email" --fields id,namereturns only id and name