Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/mcp/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func resolveServiceReferences(flags []Flag) []Flag {

func applySmartDefaults(cmd string, args []string, flags []Flag) []Flag {
// Add JSON output for list commands if not specified
if len(args) > 0 && args[0] == "list" && !hasFlag(flags, "json") {
if len(args) > 0 && args[0] == "list" && cmd != "service" && !hasFlag(flags, "json") {
if globalContext.PreferredFormat == "json" || globalContext.PreferredFormat == "" {
flags = append(flags, Flag{Name: "json", Value: ""})
}
Expand Down
15 changes: 13 additions & 2 deletions internal/mcp/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ func TestApplySmartDefaults(t *testing.T) {
},
},
{
name: "adds json flag for list commands",
cmd: "service",
name: "adds json flag for non-service list commands",
cmd: "kv-store",
args: []string{"list"},
inputFlags: []Flag{},
checkFunc: func(t *testing.T, flags []Flag) {
Expand All @@ -326,6 +326,17 @@ func TestApplySmartDefaults(t *testing.T) {
}
},
},
{
name: "does not add json flag for service list commands",
cmd: "service",
args: []string{"list"},
inputFlags: []Flag{},
checkFunc: func(t *testing.T, flags []Flag) {
if hasFlag(flags, "json") {
t.Error("Expected json flag not to be added for service list command")
}
},
},
}

for _, tt := range tests {
Expand Down