Skip to content

Commit e92a38c

Browse files
committed
wip
1 parent 6b5f185 commit e92a38c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

cmd/docker-mcp/commands/gateway.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/spf13/cobra"
1111

1212
"github.com/docker/mcp-gateway/cmd/docker-mcp/catalog"
13+
workingset "github.com/docker/mcp-gateway/cmd/docker-mcp/working-set"
1314
catalogTypes "github.com/docker/mcp-gateway/pkg/catalog"
1415
"github.com/docker/mcp-gateway/pkg/docker"
1516
"github.com/docker/mcp-gateway/pkg/gateway"
@@ -29,6 +30,7 @@ func gatewayCommand(docker docker.Client, dockerCli command.Cli) *cobra.Command
2930
var additionalToolsConfig []string
3031
var mcpRegistryUrls []string
3132
var enableAllServers bool
33+
var workingSetName string
3234
if os.Getenv("DOCKER_MCP_IN_CONTAINER") == "1" {
3335
// In-container.
3436
// Note: The catalog URL will be updated after checking the feature flag in RunE
@@ -125,6 +127,31 @@ func gatewayCommand(docker docker.Client, dockerCli command.Cli) *cobra.Command
125127
options.MCPRegistryServers = mcpServers
126128
}
127129

130+
// Handle --working-set flag
131+
if workingSetName != "" {
132+
if len(options.ServerNames) > 0 {
133+
return fmt.Errorf("cannot use --working-set with --servers flag")
134+
}
135+
if enableAllServers {
136+
return fmt.Errorf("cannot use --working-set with --enable-all-servers flag")
137+
}
138+
139+
// Read working-set config
140+
wsCfg, err := workingset.ReadConfig()
141+
if err != nil {
142+
return fmt.Errorf("failed to read working-sets config: %w", err)
143+
}
144+
145+
// Get the working-set
146+
ws, exists := wsCfg.WorkingSets[workingSetName]
147+
if !exists {
148+
return fmt.Errorf("working-set %q not found", workingSetName)
149+
}
150+
151+
// Set server names from the working-set
152+
options.ServerNames = ws.Servers
153+
}
154+
128155
// Handle --enable-all-servers flag
129156
if enableAllServers {
130157
if len(options.ServerNames) > 0 {
@@ -150,6 +177,7 @@ func gatewayCommand(docker docker.Client, dockerCli command.Cli) *cobra.Command
150177
}
151178

152179
runCmd.Flags().StringSliceVar(&options.ServerNames, "servers", nil, "Names of the servers to enable (if non empty, ignore --registry flag)")
180+
runCmd.Flags().StringVar(&workingSetName, "working-set", "", "Name of the working-set to use (mutually exclusive with --servers and --enable-all-servers)")
153181
runCmd.Flags().BoolVar(&enableAllServers, "enable-all-servers", false, "Enable all servers in the catalog (instead of using individual --servers options)")
154182
runCmd.Flags().StringSliceVar(&options.CatalogPath, "catalog", options.CatalogPath, "Paths to docker catalogs (absolute or relative to ~/.docker/mcp/catalogs/)")
155183
runCmd.Flags().StringSliceVar(&additionalCatalogs, "additional-catalog", nil, "Additional catalog paths to append to the default catalogs")

0 commit comments

Comments
 (0)