Skip to content
Merged
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
1 change: 1 addition & 0 deletions cmd/docker-mcp/internal/gateway/clientpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func (cp *clientPool) argsAndEnv(serverConfig *catalog.ServerConfig, readOnly *b
if ok {
env = append(env, fmt.Sprintf("%s=%s", s.Env, secretValue))
} else {
logf("Warning: Secret '%s' not found for server '%s', setting %s=<UNKNOWN>", s.Name, serverConfig.Name, s.Env)
env = append(env, fmt.Sprintf("%s=%s", s.Env, "<UNKNOWN>"))
}
}
Expand Down
14 changes: 11 additions & 3 deletions cmd/docker-mcp/internal/gateway/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ func (c *FileBasedConfiguration) readToolsConfig(ctx context.Context) (config.To
}

func (c *FileBasedConfiguration) readDockerDesktopSecrets(ctx context.Context, servers map[string]catalog.Server, serverNames []string) (map[string]string, error) {
var secretNames []string
// Use a map to deduplicate secret names
uniqueSecretNames := make(map[string]struct{})

for _, serverName := range serverNames {
serverName := strings.TrimSpace(serverName)

Expand All @@ -402,14 +404,20 @@ func (c *FileBasedConfiguration) readDockerDesktopSecrets(ctx context.Context, s
}

for _, s := range serverSpec.Secrets {
secretNames = append(secretNames, s.Name)
uniqueSecretNames[s.Name] = struct{}{}
}
}

if len(secretNames) == 0 {
if len(uniqueSecretNames) == 0 {
return map[string]string{}, nil
}

// Convert map keys to slice
var secretNames []string
for name := range uniqueSecretNames {
secretNames = append(secretNames, name)
Comment on lines +417 to +418
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be just secretNames := maps.Keys(uniqueSecretNames)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comments. It has been updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, I think you missed this comment where we can replace the for-loop though secretNames := maps.Keys(uniqueSecretNames) or maybe forgot to push it

}

log(" - Reading secrets", secretNames)
secretsByName, err := c.docker.ReadSecrets(ctx, secretNames, true)
if err != nil {
Expand Down
Loading