Forward OIDC env vars to MCP Gateway docker command#25773
Conversation
Add hasGitHubOIDCAuthInTools() to detect HTTP MCP servers using auth.type: github-oidc, and conditionally append -e ACTIONS_ID_TOKEN_REQUEST_URL and -e ACTIONS_ID_TOKEN_REQUEST_TOKEN to the MCP gateway docker run command. Includes unit tests for the detection helper, integration tests for the compiled workflow output, and an ADR documenting the decision. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/2ccca16b-146d-4364-be62-f3d38ccede86 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes missing forwarding of GitHub Actions OIDC environment variables into the MCP Gateway container so HTTP MCP servers configured with auth.type: "github-oidc" can mint tokens.
Changes:
- Add
hasGitHubOIDCAuthInTools()helper to detectgithub-oidcauth usage in configured HTTP MCP servers. - Conditionally append
-e ACTIONS_ID_TOKEN_REQUEST_URLand-e ACTIONS_ID_TOKEN_REQUEST_TOKENto the gatewaydocker runcommand (and dedup tracking) when OIDC auth is detected. - Add unit + integration tests covering detection and generated YAML behavior; add an ADR documenting the least-privilege rationale.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/mcp_environment.go | Adds helper to detect OIDC-auth HTTP MCP servers. |
| pkg/workflow/mcp_setup_generator.go | Conditionally forwards OIDC env vars into the gateway container docker run command. |
| pkg/workflow/mcp_environment_test.go | Unit tests for OIDC auth detection helper. |
| pkg/workflow/mcp_setup_generator_test.go | Integration tests asserting OIDC env vars appear (or not) in compiled YAML. |
| docs/adr/0001-conditional-oidc-env-var-forwarding-to-mcp-gateway.md | ADR documenting conditional forwarding approach. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 2
| func hasGitHubOIDCAuthInTools(tools map[string]any) bool { | ||
| for toolName, toolValue := range tools { | ||
| // Skip standard tools that don't support auth config | ||
| if toolName == "github" || toolName == "playwright" || | ||
| toolName == "cache-memory" || toolName == "agentic-workflows" || | ||
| toolName == "safe-outputs" || toolName == "mcp-scripts" { | ||
| continue | ||
| } |
There was a problem hiding this comment.
The built-in tool skip list is duplicated (it already exists in this file’s earlier HTTP MCP env-var scan). To avoid the two lists drifting over time, consider extracting a shared helper/const (e.g., isStandardMCPTool(toolName)) and using it in both places.
| } | ||
|
|
||
| mcpConfig, err := getMCPConfig(toolConfig, toolName) | ||
| if err != nil { |
There was a problem hiding this comment.
When getMCPConfig returns an error, the function silently skips the tool. Since this decision controls whether OIDC env vars get forwarded, it would be helpful to log the parse error (similar to collectMCPEnvironmentVariables above) so misconfigurations or future schema changes don’t fail silently.
| if err != nil { | |
| if err != nil { | |
| mcpEnvironmentLog.Printf("Error parsing MCP config for tool '%s' while checking github-oidc auth: %v", toolName, err) |
✅ Design Decision Gate — ADR VerifiedThe implementation in this PR aligns with the stated Architecture Decision Record. ADR reviewed: ADR-0001: Conditional OIDC Environment Variable Forwarding to MCP Gateway Container Verification SummaryAll normative requirements from the ADR are satisfied by the implementation:
Both unit tests ( The design decision has been recorded and the implementation follows it. 🏗️
|
There was a problem hiding this comment.
Implementation verified: code aligns with the linked Architecture Decision Record (ADR-0001: Conditional OIDC Environment Variable Forwarding to MCP Gateway Container). All MUST and MUST NOT requirements are satisfied. See the inline comment for the full verification matrix.
🧪 Test Quality Sentinel ReportTest Quality Score: 90/100✅ Excellent test quality
Test Classification Details
Flagged Tests — Requires ReviewNo tests require review. All three tests are high-value behavioral contracts. Test Inflation NoteBoth test files exceed the 2:1 line-ratio threshold (test lines vs. production lines):
This triggers a mechanical -10 point deduction per the rubric, but the inflation is structurally justified here:
No remediation is needed. Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 90/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). All 3 new tests are behavioral contracts: a 7-case table-driven unit test for OIDC detection, and two integration tests verifying presence/absence of OIDC env var flags in compiled docker commands.
The compiler omits
ACTIONS_ID_TOKEN_REQUEST_URLandACTIONS_ID_TOKEN_REQUEST_TOKENfrom the MCP Gatewaydocker run-eflags. The firewall forwards these into the agent container, but the second hop (agent → gateway container) was never wired up, so HTTP MCP servers withauth.type: "github-oidc"cannot mint tokens.Changes
pkg/workflow/mcp_environment.go— AddhasGitHubOIDCAuthInTools()helper that scans the tools map for any HTTP MCP server usingauth.type: "github-oidc", skipping built-in tools that don't support auth configpkg/workflow/mcp_setup_generator.go— Conditionally append-e ACTIONS_ID_TOKEN_REQUEST_URL -e ACTIONS_ID_TOKEN_REQUEST_TOKENto the gateway docker command and register both in the dedup map, following the existing OTEL env var patternpkg/workflow/mcp_environment_test.go— Unit tests for detection helper (empty tools, standard-only, HTTP without auth, HTTP with OIDC, mixed, stdio)pkg/workflow/mcp_setup_generator_test.go— Integration tests compiling real workflows to verify env vars appear/don't appear in generated YAMLdocs/adr/0001-conditional-oidc-env-var-forwarding-to-mcp-gateway.md— ADR documenting the least-privilege approach over unconditional forwardingExample workflow that triggers forwarding