@@ -7,10 +7,12 @@ import (
77 "github.com/docker/cli/cli/command"
88 "github.com/docker/cli/cli/config/configfile"
99 "github.com/spf13/cobra"
10+
11+ "github.com/docker/mcp-gateway/pkg/features"
1012)
1113
1214// featureCommand creates the `feature` command and its subcommands
13- func featureCommand (dockerCli command.Cli ) * cobra.Command {
15+ func featureCommand (dockerCli command.Cli , features features. Features ) * cobra.Command {
1416 cmd := & cobra.Command {
1517 Use : "feature" ,
1618 Short : "Manage experimental features" ,
@@ -21,16 +23,16 @@ and control optional functionality that may change in future versions.`,
2123 }
2224
2325 cmd .AddCommand (
24- featureEnableCommand (dockerCli ),
25- featureDisableCommand (dockerCli ),
26- featureListCommand (dockerCli ),
26+ featureEnableCommand (dockerCli , features ),
27+ featureDisableCommand (dockerCli , features ),
28+ featureListCommand (dockerCli , features ),
2729 )
2830
2931 return cmd
3032}
3133
3234// featureEnableCommand creates the `feature enable` command
33- func featureEnableCommand (dockerCli command.Cli ) * cobra.Command {
35+ func featureEnableCommand (dockerCli command.Cli , features features. Features ) * cobra.Command {
3436 return & cobra.Command {
3537 Use : "enable <feature-name>" ,
3638 Short : "Enable an experimental feature" ,
@@ -40,15 +42,15 @@ Available features:
4042 oauth-interceptor Enable GitHub OAuth flow interception for automatic authentication
4143 mcp-oauth-dcr Enable Dynamic Client Registration (DCR) for automatic OAuth client setup
4244 dynamic-tools Enable internal MCP management tools (mcp-find, mcp-add, mcp-remove)
43- profiles Enable profile management (docker mcp profile <subcommand>)
44- tool-name-prefix Prefix all tool names with server name to avoid conflicts` ,
45+ ` + notDockerDesktop ( features , ` profiles Enable profile management (docker mcp profile <subcommand>)
46+ ` ) + ` tool-name-prefix Prefix all tool names with server name to avoid conflicts` ,
4547 Args : cobra .ExactArgs (1 ),
4648 RunE : func (_ * cobra.Command , args []string ) error {
4749 featureName := args [0 ]
4850
4951 // Validate feature name
50- if ! isKnownFeature (featureName ) {
51- return fmt .Errorf ("unknown feature: %s\n \n Available features:\n oauth-interceptor Enable GitHub OAuth flow interception\n mcp-oauth-dcr Enable Dynamic Client Registration for automatic OAuth setup\n dynamic-tools Enable internal MCP management tools\n profiles Enable profile management (docker mcp profile <subcommand>)\n tool-name-prefix Prefix all tool names with server name" , featureName )
52+ if ! isKnownFeature (featureName , features ) {
53+ return fmt .Errorf ("unknown feature: %s\n \n Available features:\n oauth-interceptor Enable GitHub OAuth flow interception\n mcp-oauth-dcr Enable Dynamic Client Registration for automatic OAuth setup\n dynamic-tools Enable internal MCP management tools\n " + notDockerDesktop ( features , " profiles Enable profile management (docker mcp profile <subcommand>)\n " ) + " tool-name-prefix Prefix all tool names with server name" , featureName )
5254 }
5355
5456 // Enable the feature
@@ -105,7 +107,7 @@ Available features:
105107}
106108
107109// featureDisableCommand creates the `feature disable` command
108- func featureDisableCommand (dockerCli command.Cli ) * cobra.Command {
110+ func featureDisableCommand (dockerCli command.Cli , features features. Features ) * cobra.Command {
109111 return & cobra.Command {
110112 Use : "disable <feature-name>" ,
111113 Short : "Disable an experimental feature" ,
@@ -115,7 +117,7 @@ func featureDisableCommand(dockerCli command.Cli) *cobra.Command {
115117 featureName := args [0 ]
116118
117119 // Validate feature name
118- if ! isKnownFeature (featureName ) {
120+ if ! isKnownFeature (featureName , features ) {
119121 return fmt .Errorf ("unknown feature: %s" , featureName )
120122 }
121123
@@ -138,7 +140,7 @@ func featureDisableCommand(dockerCli command.Cli) *cobra.Command {
138140}
139141
140142// featureListCommand creates the `feature list` command
141- func featureListCommand (dockerCli command.Cli ) * cobra.Command {
143+ func featureListCommand (dockerCli command.Cli , features features. Features ) * cobra.Command {
142144 return & cobra.Command {
143145 Use : "ls" ,
144146 Aliases : []string {"list" },
@@ -151,7 +153,10 @@ func featureListCommand(dockerCli command.Cli) *cobra.Command {
151153 fmt .Println ()
152154
153155 // Show all known features
154- knownFeatures := []string {"oauth-interceptor" , "mcp-oauth-dcr" , "dynamic-tools" , "profiles" , "tool-name-prefix" }
156+ knownFeatures := []string {"oauth-interceptor" , "mcp-oauth-dcr" , "dynamic-tools" , "tool-name-prefix" }
157+ if ! features .IsRunningInDockerDesktop () {
158+ knownFeatures = append (knownFeatures , "profiles" )
159+ }
155160 for _ , feature := range knownFeatures {
156161 status := "disabled"
157162 if isFeatureEnabledFromCli (dockerCli , feature ) {
@@ -180,7 +185,7 @@ func featureListCommand(dockerCli command.Cli) *cobra.Command {
180185 if configFile .Features != nil {
181186 unknownFeatures := make ([]string , 0 )
182187 for feature := range configFile .Features {
183- if ! isKnownFeature (feature ) {
188+ if ! isKnownFeature (feature , features ) {
184189 unknownFeatures = append (unknownFeatures , feature )
185190 }
186191 }
@@ -235,14 +240,16 @@ func isFeatureEnabledFromConfig(configFile *configfile.ConfigFile, feature strin
235240}
236241
237242// isKnownFeature checks if the feature name is valid
238- func isKnownFeature (feature string ) bool {
243+ func isKnownFeature (feature string , features features. Features ) bool {
239244 knownFeatures := []string {
240245 "oauth-interceptor" ,
241246 "mcp-oauth-dcr" ,
242247 "dynamic-tools" ,
243- "profiles" ,
244248 "tool-name-prefix" ,
245249 }
250+ if ! features .IsRunningInDockerDesktop () {
251+ knownFeatures = append (knownFeatures , "profiles" )
252+ }
246253
247254 for _ , known := range knownFeatures {
248255 if feature == known {
@@ -251,3 +258,10 @@ func isKnownFeature(feature string) bool {
251258 }
252259 return false
253260}
261+
262+ func notDockerDesktop (features features.Features , msg string ) string {
263+ if features .IsRunningInDockerDesktop () {
264+ return ""
265+ }
266+ return msg
267+ }
0 commit comments