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
4 changes: 2 additions & 2 deletions .github/workflows/duplicate-code-detector.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions pkg/parser/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package parser
import (
"encoding/json"
"fmt"
"sort"
"strings"

"github.com/githubnext/gh-aw/pkg/constants"
Expand Down Expand Up @@ -480,8 +481,15 @@ func ParseMCPConfig(toolName string, mcpSection any, toolConfig map[string]any)
// Add environment variables
if env, hasEnv := mcpConfig["env"]; hasEnv {
if envMap, ok := env.(map[string]any); ok {
for key, value := range envMap {
if valueStr, ok := value.(string); ok {
// Sort environment variable keys to ensure deterministic arg order
var envKeys []string
for key := range envMap {
envKeys = append(envKeys, key)
}
sort.Strings(envKeys)

for _, key := range envKeys {
if valueStr, ok := envMap[key].(string); ok {
config.Args = append(config.Args, "-e", key)
config.Env[key] = valueStr
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/workflow/mcp-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,13 @@ func getMCPConfig(toolConfig map[string]any, toolName string) (*parser.MCPServer
result.Command = "docker"
result.Args = []string{"run", "--rm", "-i"}

// Add environment variables as -e flags
// Add environment variables as -e flags (sorted for deterministic output)
envKeys := make([]string, 0, len(result.Env))
for envKey := range result.Env {
envKeys = append(envKeys, envKey)
}
sort.Strings(envKeys)
for _, envKey := range envKeys {
result.Args = append(result.Args, "-e", envKey)
}

Expand Down
Loading