Skip to content

Commit 939d174

Browse files
Copilotgh-aw-bot
andauthored
Address blocking review comments for MCP gateway agent ID migration
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
1 parent 25b796b commit 939d174

6 files changed

Lines changed: 72 additions & 15 deletions

File tree

actions/setup/sh/check_mcp_servers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ print_timing() {
3737
# 1 - Invalid arguments, configuration file issues, no successful connections, or required server failures
3838

3939
if [ "$#" -ne 3 ]; then
40-
echo "Usage: $0 GATEWAY_CONFIG_PATH GATEWAY_URL GATEWAY_API_KEY" >&2
40+
echo "Usage: $0 GATEWAY_CONFIG_PATH GATEWAY_URL GATEWAY_AGENT_ID" >&2
4141
exit 1
4242
fi
4343

docs/public/editor/autocomplete-data.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,11 @@
905905
"enum": [true, false],
906906
"leaf": true
907907
},
908+
"ca-cert": {
909+
"type": "string",
910+
"desc": "Host path to an additional CA certificate for API proxy upstream TLS verification.",
911+
"leaf": true
912+
},
908913
"runtime": {
909914
"type": "string",
910915
"desc": "Sandbox runtime profile for the agent container.",
@@ -1042,9 +1047,9 @@
10421047
"desc": "Port number for the MCP gateway HTTP server (default: 8080)",
10431048
"leaf": true
10441049
},
1045-
"api-key": {
1050+
"agent-id": {
10461051
"type": "string",
1047-
"desc": "API key for authenticating with the MCP gateway (supports ${{ secrets.* }} syntax)",
1052+
"desc": "Agent/session identifier for authenticating with the MCP gateway (supports ${{ secrets.* }} syntax)",
10481053
"leaf": true
10491054
},
10501055
"domain": {

docs/src/content/docs/reference/frontmatter-full.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,18 @@ on:
566566
branches-ignore: []
567567
# Array of strings
568568

569+
# Filter by workflow run conclusion (for example, failure). Compiled into a
570+
# guarded if: condition.
571+
# (optional)
572+
# Accepted formats:
573+
574+
# Format 1: string
575+
conclusion: "success"
576+
577+
# Format 2: array
578+
conclusion: []
579+
# Array items: string
580+
569581
# Release event trigger
570582
# (optional)
571583
release:
@@ -1547,10 +1559,11 @@ on:
15471559

15481560
# ⚠️ Experimental. Agent Plugins to install after the agentic engine. Each GitHub
15491561
# repository reference must include a ref that the compiler resolves to a commit
1550-
# SHA. Using this field emits a compile-time warning.
1562+
# SHA. Using this field emits a compile-time warning. Entries may also be objects
1563+
# to configure per-plugin authentication via github-token or github-app, for
1564+
# installing plugins from private repositories.
15511565
# (optional)
15521566
plugins: []
1553-
# Array of A plugin repository reference in owner/repository[/path]@ref format
15541567

15551568
# GitHub token permissions for the workflow. Controls what the GITHUB_TOKEN can
15561569
# access during execution. Use the principle of least privilege - only grant the
@@ -2260,6 +2273,12 @@ sandbox:
22602273
# (optional)
22612274
token-steering: true
22622275

2276+
# Host path to an additional CA certificate for API proxy upstream TLS
2277+
# verification. The file is bind-mounted read-only into the API proxy sidecar.
2278+
# Maps to apiProxy.caCert; requires AWF v0.28.10 or later.
2279+
# (optional)
2280+
ca-cert: "example-value"
2281+
22632282
# Sandbox runtime profile for the agent container. Each value selects one
22642283
# supported security and topology profile: 'docker' (default) runs the agent under
22652284
# Docker with a rootless AWF and network isolation; 'docker-sudo-iptables' runs
@@ -2434,10 +2453,10 @@ sandbox:
24342453
# (optional)
24352454
port: 1
24362455

2437-
# API key for authenticating with the MCP gateway (supports ${{ secrets.* }}
2438-
# syntax)
2456+
# Agent/session identifier for authenticating with the MCP gateway (supports ${{
2457+
# secrets.* }} syntax)
24392458
# (optional)
2440-
api-key: "example-value"
2459+
agent-id: "example-value"
24412460

24422461
# Gateway domain for URL generation (default: 'host.docker.internal' when agent is
24432462
# enabled, 'localhost' when disabled)
@@ -4072,10 +4091,17 @@ tools:
40724091
# Integration mode: 'cli' (recommended) installs @playwright/cli via npm for
40734092
# token-efficient CLI invocations — use playwright-cli commands in bash and
40744093
# localhost to reach local servers; 'mcp' (deprecated) runs a Docker-based MCP
4075-
# server.
4094+
# server. Must be a literal value; GitHub Actions expressions are rejected.
40764095
# (optional)
4096+
# Accepted formats:
4097+
4098+
# Format 1: string
40774099
mode: "cli"
40784100

4101+
# Format 2: Not allowed at runtime: mode must be a literal 'cli' or 'mcp' value,
4102+
# not a GitHub Actions expression.
4103+
mode: "example-value"
4104+
40794105
# GitHub Agentic Workflows MCP server for workflow introspection and analysis.
40804106
# Provides tools for checking status, compiling workflows, downloading logs, and
40814107
# auditing runs.

pkg/workflow/codex_engine_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ func TestCodexEngineRenderMCPConfig(t *testing.T) {
455455
"\"gateway\": {",
456456
"\"port\": $MCP_GATEWAY_PORT,",
457457
"\"domain\": \"${MCP_GATEWAY_DOMAIN}\",",
458-
"\"apiKey\": \"${MCP_GATEWAY_AGENT_ID}\",",
458+
"\"agentId\": \"${MCP_GATEWAY_AGENT_ID}\",",
459459
"\"payloadDir\": \"${MCP_GATEWAY_PAYLOAD_DIR}\",",
460460
"\"startupTimeout\": 120",
461461
"}",

pkg/workflow/mcp_gateway_env_security_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func writeMCPGatewayStepEnvForTest(yaml *strings.Builder, mcpEnvVars map[string]string, safeOutputsInputEnvVars map[string]string, gatewayEnvVars map[string]string) {
15-
writeMCPGatewayStepEnvWithCustomGatewayEnvNames(yaml, mcpEnvVars, safeOutputsInputEnvVars, gatewayEnvVars, sanitizedGatewayEnvNames(gatewayEnvVars))
15+
writeMCPGatewayStepEnvWithCustomGatewayEnvNames(yaml, mcpEnvVars, safeOutputsInputEnvVars, gatewayEnvVars, sanitizedGatewayEnvNames(gatewayEnvVars), "")
1616
}
1717

1818
func appendMCPGatewayCustomAndHTTPEnvFlagsForTest(containerCmd *strings.Builder, workflowData *WorkflowData, gatewayConfig *MCPGatewayRuntimeConfig, mcpEnvVars map[string]string, hasGitHub bool, githubTool map[string]any, tools map[string]any, engine CodingAgentEngine) {
@@ -233,3 +233,25 @@ func TestMCPGatewayFilteredCustomEnvDoesNotSuppressHTTPMCPEnvForwarding(t *testi
233233

234234
assert.Equal(t, " -e GH_AW_MCP_GATEWAY_ENV_0", containerCommand.String())
235235
}
236+
237+
func TestMCPGatewayConfiguredAgentIDPassedViaStepEnv(t *testing.T) {
238+
configuredAgentID := `my-agent-id"; touch /tmp/pwned; #`
239+
240+
var stepEnv strings.Builder
241+
writeMCPGatewayStepEnvWithCustomGatewayEnvNames(&stepEnv, nil, nil, nil, nil, configuredAgentID)
242+
243+
assert.Contains(t, stepEnv.String(), `GH_AW_MCP_GATEWAY_CONFIGURED_AGENT_ID: "my-agent-id\"; touch /tmp/pwned; #"`)
244+
245+
var runScript strings.Builder
246+
writeMCPGatewayExports(&runScript, writeMCPGatewayExportsOptions{
247+
engine: NewCopilotEngine(),
248+
workflowData: &WorkflowData{},
249+
gatewayConfig: &MCPGatewayRuntimeConfig{AgentID: configuredAgentID},
250+
port: 8080,
251+
domain: "localhost",
252+
payloadDir: "/tmp/payloads",
253+
})
254+
255+
assert.Contains(t, runScript.String(), `export MCP_GATEWAY_AGENT_ID="${GH_AW_MCP_GATEWAY_CONFIGURED_AGENT_ID}"`)
256+
assert.NotContains(t, runScript.String(), `export MCP_GATEWAY_AGENT_ID="my-agent-id`)
257+
}

pkg/workflow/mcp_setup_gateway.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const mcpGatewayCustomEnvNamesVar = "GH_AW_MCP_GATEWAY_CUSTOM_ENV_NAMES"
1818
const mcpGatewayCustomEnvTransportPrefix = "GH_AW_MCP_GATEWAY_ENV_"
1919
const mcpGatewayReservedEnvPrefix = "GH_AW_MCP_GATEWAY_"
2020
const mcpGatewayCustomEnvMarker = "__GH_AW_MCP_GATEWAY_CUSTOM_ENV__"
21+
const mcpGatewayConfiguredAgentIDVar = "GH_AW_MCP_GATEWAY_CONFIGURED_AGENT_ID"
2122

2223
var optionalPRHeadEnvVars = []string{
2324
"GH_AW_PR_HEAD_BASE_BRANCH",
@@ -46,7 +47,7 @@ func generateMCPGatewaySetup(yaml *strings.Builder, tools map[string]any, mcpToo
4647
gatewayConfig := workflowData.SandboxConfig.MCP
4748
mcpEnvVars := collectMCPEnvironmentVariables(tools, mcpTools, workflowData, hasAgenticWorkflows)
4849
customGatewayEnvNames := sanitizedGatewayEnvNames(gatewayConfig.Env)
49-
writeMCPGatewayStepEnvWithCustomGatewayEnvNames(yaml, mcpEnvVars, safeOutputsInputEnvVars, gatewayConfig.Env, customGatewayEnvNames)
50+
writeMCPGatewayStepEnvWithCustomGatewayEnvNames(yaml, mcpEnvVars, safeOutputsInputEnvVars, gatewayConfig.Env, customGatewayEnvNames, gatewayConfig.AgentID)
5051
yaml.WriteString(" run: |\n")
5152
yaml.WriteString(" set -eo pipefail\n")
5253
yaml.WriteString(" mkdir -p \"${RUNNER_TEMP}/gh-aw/mcp-config\"\n")
@@ -101,8 +102,8 @@ func generateMCPGatewaySetup(yaml *strings.Builder, tools map[string]any, mcpToo
101102
return engine.RenderMCPConfig(yaml, tools, mcpTools, workflowData)
102103
}
103104

104-
func writeMCPGatewayStepEnvWithCustomGatewayEnvNames(yaml *strings.Builder, mcpEnvVars map[string]string, safeOutputsInputEnvVars map[string]string, gatewayEnvVars map[string]string, customEnvVarNames []string) {
105-
if len(mcpEnvVars) == 0 && len(safeOutputsInputEnvVars) == 0 && len(customEnvVarNames) == 0 {
105+
func writeMCPGatewayStepEnvWithCustomGatewayEnvNames(yaml *strings.Builder, mcpEnvVars map[string]string, safeOutputsInputEnvVars map[string]string, gatewayEnvVars map[string]string, customEnvVarNames []string, configuredAgentID string) {
106+
if len(mcpEnvVars) == 0 && len(safeOutputsInputEnvVars) == 0 && len(customEnvVarNames) == 0 && configuredAgentID == "" {
106107
return
107108
}
108109
yaml.WriteString(" env:\n")
@@ -148,6 +149,9 @@ func writeMCPGatewayStepEnvWithCustomGatewayEnvNames(yaml *strings.Builder, mcpE
148149
yaml.WriteString(formatYAMLEnv(" ", mcpGatewayCustomEnvTransportName(i), gatewayEnvVars[envVarName]))
149150
}
150151
}
152+
if configuredAgentID != "" {
153+
yaml.WriteString(formatYAMLEnv(" ", mcpGatewayConfiguredAgentIDVar, configuredAgentID))
154+
}
151155
}
152156

153157
// sanitizedGatewayEnvNames returns the sorted subset of user-supplied gateway
@@ -272,7 +276,7 @@ func writeMCPGatewayExports(yaml *strings.Builder, opts writeMCPGatewayExportsOp
272276
yaml.WriteString(" echo \"::add-mask::${MCP_GATEWAY_AGENT_ID}\"\n")
273277
yaml.WriteString(" export MCP_GATEWAY_AGENT_ID\n")
274278
} else {
275-
yaml.WriteString(" export MCP_GATEWAY_AGENT_ID=\"" + gatewayConfig.AgentID + "\"\n")
279+
yaml.WriteString(" export MCP_GATEWAY_AGENT_ID=\"${" + mcpGatewayConfiguredAgentIDVar + "}\"\n")
276280
yaml.WriteString(" echo \"::add-mask::${MCP_GATEWAY_AGENT_ID}\"\n")
277281
}
278282
yaml.WriteString(" export MCP_GATEWAY_PAYLOAD_DIR=\"" + payloadDir + "\"\n")

0 commit comments

Comments
 (0)