Skip to content

Commit 4c1bf3a

Browse files
authored
Fix safe-inputs tool secrets not passed to MCP server process (#8255)
1 parent 3d6bff7 commit 4c1bf3a

File tree

7 files changed

+43
-21
lines changed

7 files changed

+43
-21
lines changed

.changeset/patch-fix-safe-inputs-secrets.md

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/copilot-pr-merged-report.lock.yml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/daily-performance-summary.lock.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-copilot-no-firewall.lock.yml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-copilot-playwright.lock.yml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-copilot-safe-inputs.lock.yml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/workflow/mcp_servers.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,30 @@ func (c *Compiler) generateMCPSetup(yaml *strings.Builder, tools map[string]any,
299299
// Step 4: Start the HTTP server in the background
300300
yaml.WriteString(" - name: Start Safe Inputs MCP HTTP Server\n")
301301
yaml.WriteString(" id: safe-inputs-start\n")
302+
303+
// Add env block with tool-specific secrets so they're available to the Node.js MCP server process
304+
safeInputsSecrets := collectSafeInputsSecrets(workflowData.SafeInputs)
305+
if len(safeInputsSecrets) > 0 {
306+
yaml.WriteString(" env:\n")
307+
// Sort env var names for consistent output
308+
envVarNames := make([]string, 0, len(safeInputsSecrets))
309+
for envVarName := range safeInputsSecrets {
310+
envVarNames = append(envVarNames, envVarName)
311+
}
312+
sort.Strings(envVarNames)
313+
314+
for _, envVarName := range envVarNames {
315+
secretExpr := safeInputsSecrets[envVarName]
316+
fmt.Fprintf(yaml, " %s: %s\n", envVarName, secretExpr)
317+
}
318+
}
319+
302320
yaml.WriteString(" run: |\n")
303321
yaml.WriteString(" # Set environment variables for the server\n")
304322
yaml.WriteString(" export GH_AW_SAFE_INPUTS_PORT=${{ steps.safe-inputs-config.outputs.safe_inputs_port }}\n")
305323
yaml.WriteString(" export GH_AW_SAFE_INPUTS_API_KEY=${{ steps.safe-inputs-config.outputs.safe_inputs_api_key }}\n")
306324
yaml.WriteString(" \n")
307325

308-
// Pass through environment variables from safe-inputs config
309-
envVars := getSafeInputsEnvVars(workflowData.SafeInputs)
310-
for _, envVar := range envVars {
311-
fmt.Fprintf(yaml, " export %s=\"${%s}\"\n", envVar, envVar)
312-
}
313-
yaml.WriteString(" \n")
314-
315326
// Call the bundled shell script to start the server
316327
yaml.WriteString(" bash /tmp/gh-aw/actions/start_safe_inputs_server.sh\n")
317328
yaml.WriteString(" \n")

0 commit comments

Comments
 (0)