fix: add enum constraints and positional arg hints to MCP tool schemas
What does this MR do and why?
After !2390 (merged) stripped flag descriptions from MCP tool schemas to reduce token usage, AI agents were misusing tools because constrained flags had no indication of their valid values.
This adds two targeted fixes:
-
Enum constraints for constrained flags — flags backed by
enumValue(e.g.--outputonglab api,--cache-mode,--note-type,--state) now emit an"enum"field in their JSON schema. An agent callingglab_apiwill now see{"type": "string", "enum": ["json", "ndjson"]}instead of just{"type": "string"}, eliminating the file-path misinterpretation described in the issue. -
Positional argument hints from
cmd.Use— theargsdescription is now derived from the command'sUsefield rather than hardcoded as"Positional arguments". Forglab_apithis becomes"Positional arguments: <endpoint>", giving agents the format hint they need at zero extra cost.
The AllowedValuer interface is intentionally exported so any future custom pflag.Value implementations can opt into the same schema enrichment.
MR acceptance checklist
- This MR does not have the ~"pipeline:skip-if-draft" label
- I have evaluated the MR acceptance checklist
- I have added/updated tests
Closes #8241 (closed)