Fix mcp list-tools tab completion offering completions for second positional arg#30221
Fix mcp list-tools tab completion offering completions for second positional arg#30221
mcp list-tools tab completion offering completions for second positional arg#30221Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d3b0a7e5-dece-4a46-a108-a7eba486df24 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…letions Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d3b0a7e5-dece-4a46-a108-a7eba486df24 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
mcp list-tools tab completion offering completions for second positional arg
|
Hey One thing that would help get this across the finish line:
If you'd like a hand, you can assign this prompt to your coding agent:
|
There was a problem hiding this comment.
Pull request overview
Fixes shell tab-completion for gh aw mcp list-tools so workflow-name completions are only suggested for the first (and only) positional argument, matching cobra.MaximumNArgs(1).
Changes:
- Wrapes
CompleteWorkflowNamesin aValidArgsFunctionguard that short-circuits when a positional arg is already present. - Adds
GH_AW_INFO_VERSION: "1.0.40"to an env block in themetrics-collector.lock.ymlworkflow.
Show a summary per file
| File | Description |
|---|---|
pkg/cli/mcp_list_tools.go |
Prevents workflow-name completions from being offered for a non-existent second positional argument. |
.github/workflows/metrics-collector.lock.yml |
Adds missing GH_AW_INFO_VERSION env var in one step for consistency with other lock workflows/steps. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
| if len(args) > 0 { | ||
| return nil, cobra.ShellCompDirectiveNoFileComp | ||
| } | ||
| return CompleteWorkflowNames(cmd, args, toComplete) | ||
| }, |
|
@copilot review all comments |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8928a2dd-abc1-4d17-af1d-f1d038e09f38 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8928a2dd-abc1-4d17-af1d-f1d038e09f38 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added
|
mcp list-toolsonly accepts one positional argument (cobra.MaximumNArgs(1)), but itsValidArgsFunctionwasCompleteWorkflowNamesdirectly — causing workflow names to be offered as completions for the second positional argument as well.Change
Wrap
CompleteWorkflowNamesto short-circuit whenlen(args) > 0:This aligns completion behavior with the command's declared argument cardinality.
Tests
Added
TestMCPListToolsValidArgsFunctioninpkg/cli/mcp_list_tools_test.gowith two sub-tests:no_completions_when_first_arg_already_provided— asserts the guard returns no completions andShellCompDirectiveNoFileCompwhen a positional arg is already presentcompletions_offered_for_first_arg— asserts at least one workflow name completion is returned when no args are present and workflows exist on disk