Skip to content

Commit 14207bf

Browse files
committed
use cli hints flag setting from DD
1 parent f4fb932 commit 14207bf

File tree

7 files changed

+56
-10
lines changed

7 files changed

+56
-10
lines changed

cmd/docker-mcp/catalog/ls.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"time"
88

9+
"github.com/docker/mcp-gateway/cmd/docker-mcp/hints"
910
"github.com/docker/mcp-gateway/pkg/telemetry"
1011
)
1112

@@ -47,5 +48,7 @@ func humanPrintCatalog(cfg Config) {
4748
for name, catalog := range cfg.Catalogs {
4849
fmt.Printf("%s: %s\n", name, catalog.DisplayName)
4950
}
50-
fmt.Println("\033[36mTip: Use \033[1;3m'docker mcp catalog show <name>'\033[0;36m to browse a catalog's servers\033[0m")
51+
if hints.Enabled() {
52+
fmt.Println("\033[36mTip: Use \033[1;3m'docker mcp catalog show <name>'\033[0;36m to browse a catalog's servers\033[0m")
53+
}
5154
}

cmd/docker-mcp/catalog/show.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/moby/term"
1414
"gopkg.in/yaml.v3"
1515

16+
"github.com/docker/mcp-gateway/cmd/docker-mcp/hints"
1617
"github.com/docker/mcp-gateway/pkg/yq"
1718
)
1819

@@ -153,8 +154,9 @@ func Show(ctx context.Context, name string, format Format, mcpOAuthDcrEnabled bo
153154
fmt.Printf(" %s\n", strings.Repeat("─", headerLineWidth))
154155
fmt.Printf(" %d servers total\n", serverCount)
155156
fmt.Println()
156-
fmt.Println("\033[36mTip: \033[1;3mdocker mcp server inspect <server-name>\033[0;36m to view server details, \033[1;3mdocker mcp server enable <server-name>\033[0;36m to add servers\033[0m")
157-
fmt.Println()
157+
if hints.Enabled() {
158+
fmt.Println("\033[36mTip: \033[1;3mdocker mcp server inspect <server-name>\033[0;36m to view server details, \033[1;3mdocker mcp server enable <server-name>\033[0;36m to add servers\033[0m")
159+
}
158160

159161
return nil
160162
}

cmd/docker-mcp/client/connect.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package client
33
import (
44
"context"
55
"fmt"
6+
7+
"github.com/docker/mcp-gateway/cmd/docker-mcp/hints"
68
)
79

810
func Connect(ctx context.Context, cwd string, config Config, vendor string, global, quiet bool) error {
@@ -33,6 +35,8 @@ func Connect(ctx context.Context, cwd string, config Config, vendor string, glob
3335
return err
3436
}
3537
fmt.Printf("You might have to restart '%s'.\n", vendor)
36-
fmt.Println("\033[36mTip: Your client is now connected! Try \033[1;3m'docker mcp tools ls'\033[0;36m to see available tools\033[0m")
38+
if hints.Enabled() {
39+
fmt.Println("\033[36mTip: Your client is now connected! Try \033[1;3m'docker mcp tools ls'\033[0;36m to see available tools\033[0m")
40+
}
3741
return nil
3842
}

cmd/docker-mcp/commands/server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/docker/cli/cli/command"
99
"github.com/spf13/cobra"
1010

11+
"github.com/docker/mcp-gateway/cmd/docker-mcp/hints"
1112
"github.com/docker/mcp-gateway/cmd/docker-mcp/server"
1213
"github.com/docker/mcp-gateway/pkg/config"
1314
"github.com/docker/mcp-gateway/pkg/docker"
@@ -42,8 +43,10 @@ func serverCommand(docker docker.Client, dockerCli command.Cli) *cobra.Command {
4243
fmt.Fprintln(cmd.OutOrStdout(), "No server is enabled")
4344
} else {
4445
fmt.Fprintln(cmd.OutOrStdout(), strings.Join(list, ", "))
45-
fmt.Fprintln(cmd.OutOrStdout(), "\033[36mTip: Connect to Claude/Cursor to use these servers with \033[1;3m'docker mcp client connect <client-name>'\033[0m")
46-
fmt.Fprintln(cmd.OutOrStdout(), "")
46+
if hints.Enabled() {
47+
fmt.Fprintln(cmd.OutOrStdout(), "\033[36mTip: Connect to a client (IE: Claude/Cursor) to use these servers with \033[1;3m'docker mcp client connect <client-name>'\033[0m")
48+
fmt.Fprintln(cmd.OutOrStdout(), "")
49+
}
4750
}
4851

4952
return nil

cmd/docker-mcp/hints/hints.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package hints
2+
3+
import (
4+
"github.com/docker/cli/cli/config"
5+
"github.com/docker/cli/cli/config/configfile"
6+
)
7+
8+
func Enabled() bool {
9+
configFile := getDockerConfigFile()
10+
if configFile != nil && configFile.Plugins != nil {
11+
if pluginConfig, ok := configFile.Plugins["-x-cli-hints"]; ok {
12+
if enabledValue, exists := pluginConfig["enabled"]; exists {
13+
return enabledValue == "true"
14+
}
15+
}
16+
}
17+
18+
return true
19+
}
20+
21+
func getDockerConfigFile() *configfile.ConfigFile {
22+
configFile, err := config.Load("")
23+
if err != nil {
24+
return nil
25+
}
26+
return configFile
27+
}

cmd/docker-mcp/server/enable.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"gopkg.in/yaml.v3"
99

10+
"github.com/docker/mcp-gateway/cmd/docker-mcp/hints"
1011
"github.com/docker/mcp-gateway/pkg/catalog"
1112
"github.com/docker/mcp-gateway/pkg/config"
1213
"github.com/docker/mcp-gateway/pkg/docker"
@@ -94,12 +95,12 @@ func update(ctx context.Context, docker docker.Client, add []string, remove []st
9495
return fmt.Errorf("writing registry config: %w", err)
9596
}
9697

97-
if len(add) > 0 {
98+
if len(add) > 0 && hints.Enabled() {
9899
fmt.Println("\033[36mTip: \033[32m✓\033[0m \033[36mServer enabled. Run \033[1;3m'docker mcp server ls'\033[0;36m to view all enabled servers\033[0m")
99100
fmt.Println()
100101
}
101102

102-
if len(remove) > 0 {
103+
if len(remove) > 0 && hints.Enabled() {
103104
fmt.Println("\033[36mTip: \033[32m✓\033[0m \033[36mServer disabled. Run \033[1;3m'docker mcp server ls'\033[0;36m to see remaining enabled servers\033[0m")
104105
fmt.Println()
105106
}

cmd/docker-mcp/tools/list.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"go.opentelemetry.io/otel"
1111
"go.opentelemetry.io/otel/attribute"
1212
"go.opentelemetry.io/otel/metric"
13+
14+
"github.com/docker/mcp-gateway/cmd/docker-mcp/hints"
1315
)
1416

1517
func List(ctx context.Context, version string, gatewayArgs []string, debug bool, show, tool, format string) error {
@@ -50,14 +52,18 @@ func List(ctx context.Context, version string, gatewayArgs []string, debug bool,
5052
for _, tool := range response.Tools {
5153
fmt.Println(" -", tool.Name, "-", toolDescription(tool))
5254
}
53-
fmt.Println("\033[36mTip: Use \033[1;3m'docker mcp tools inspect <tool-name>'\033[0;36m to see tool details, or \033[1;3m'docker mcp tools call <tool-name>'\033[0;36m to test it\033[0m")
55+
if hints.Enabled() {
56+
fmt.Println("\033[36mTip: Use \033[1;3m'docker mcp tools inspect <tool-name>'\033[0;36m to see tool details, or \033[1;3m'docker mcp tools call <tool-name>'\033[0;36m to test it\033[0m")
57+
}
5458
}
5559
case "count":
5660
if format == "json" {
5761
fmt.Printf("{\"count\": %d}\n", len(response.Tools))
5862
} else {
5963
fmt.Println(len(response.Tools), "tools")
60-
fmt.Println("\033[36mTip: Run \033[1;3m'docker mcp tools ls'\033[0;36m to see all available tools\033[0m")
64+
if hints.Enabled() {
65+
fmt.Println("\033[36mTip: Run \033[1;3m'docker mcp tools ls'\033[0;36m to see all available tools\033[0m")
66+
}
6167
}
6268
case "inspect":
6369
var found *mcp.Tool

0 commit comments

Comments
 (0)