Skip to content

Add agent-friendly enhancements (Step 13)#3

Merged
andreagrandi merged 7 commits intomasterfrom
agent-friendly
Mar 5, 2026
Merged

Add agent-friendly enhancements (Step 13)#3
andreagrandi merged 7 commits intomasterfrom
agent-friendly

Conversation

@andreagrandi
Copy link
Owner

Summary

  • mb-cli context - Embedded markdown reference document for AI agents with all commands, flags, authentication, name resolution, and common pitfalls
  • mb-cli schema [command] - JSON introspection of all commands with args, flags, types, defaults, enums, and output keys
  • TTY auto-detection - Default --format is table in TTY, json when piped
  • --error-format json - Structured JSON error output on stderr with error type classification (CONFIG, AUTH, API, RESOLUTION, GENERAL)
  • Input validation - Reject control characters in SQL queries and search input, max SQL length check
  • --fields flag - Filter output columns on query sql and card run to reduce output size for agent context windows

Test plan

  • make test passes (all new tests for context, schema, tty, error_format, validation, fields_filter)
  • mb-cli context | head prints agent reference
  • mb-cli schema | jq . lists all commands as valid JSON
  • mb-cli schema "query sql" --pretty shows args/flags/defaults
  • Piped output defaults to JSON, explicit --format overrides
  • MB_HOST="" mb-cli database list --error-format json outputs structured JSON error on stderr
  • SQL with control characters rejected with validation error
  • mb-cli query sql --db 71 --sql "SELECT 1 AS id, 'Alice' AS name, 'a@b.com' AS email" --fields id,name returns only id and name

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.
@andreagrandi andreagrandi merged commit f8ebf03 into master Mar 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant