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
5 changes: 5 additions & 0 deletions .changeset/patch-github-token-secret-check.md

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

31 changes: 31 additions & 0 deletions pkg/cli/mcp_inspect_mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,37 @@ func validateServerSecrets(config parser.MCPServerConfig, verbose bool, useActio
// Extract secrets from the config
requiredSecrets := extractSecretsFromConfig(config)

// Special case: Check for GH_AW_GITHUB_TOKEN when GitHub tool is in remote mode
if config.Name == "github" && config.Type == "http" {
// GitHub remote mode requires GH_AW_GITHUB_TOKEN secret
// Check if a custom token is already specified in the env
hasCustomToken := false
for _, value := range config.Env {
if strings.Contains(value, "secrets.") && !strings.Contains(value, "GH_AW_GITHUB_TOKEN") {
// Custom token specified, no need to check GH_AW_GITHUB_TOKEN
hasCustomToken = true
break
}
}

if !hasCustomToken {
// Add GH_AW_GITHUB_TOKEN to required secrets if not already present
alreadyPresent := false
for _, secret := range requiredSecrets {
if secret.Name == "GH_AW_GITHUB_TOKEN" {
alreadyPresent = true
break
}
}
if !alreadyPresent {
requiredSecrets = append(requiredSecrets, SecretInfo{
Name: "GH_AW_GITHUB_TOKEN",
EnvKey: "GITHUB_TOKEN",
})
}
}
}

if len(requiredSecrets) == 0 {
// No secrets required, proceed with normal env var validation
for key, value := range config.Env {
Expand Down
34 changes: 34 additions & 0 deletions pkg/cli/mcp_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,40 @@ func TestValidateServerSecrets(t *testing.T) {
},
expectError: false,
},
{
name: "github remote mode requires GH_AW_GITHUB_TOKEN",
config: parser.MCPServerConfig{
Name: "github",
Type: "http",
URL: "https://api.githubcopilot.com/mcp/",
Env: map[string]string{},
},
envVars: map[string]string{
"GH_AW_GITHUB_TOKEN": "test_token",
},
expectError: false,
},
{
name: "github remote mode with custom token",
config: parser.MCPServerConfig{
Name: "github",
Type: "http",
URL: "https://api.githubcopilot.com/mcp/",
Env: map[string]string{
"GITHUB_TOKEN": "${{ secrets.CUSTOM_PAT }}",
},
},
expectError: false,
},
{
name: "github local mode does not require GH_AW_GITHUB_TOKEN",
config: parser.MCPServerConfig{
Name: "github",
Type: "docker",
Env: map[string]string{},
},
expectError: false,
},
}

for _, tt := range tests {
Expand Down
Loading