Pass MCP configuration inline via --additional-mcp-config flag using environment variable#14810
Pass MCP configuration inline via --additional-mcp-config flag using environment variable#14810
Conversation
- Modified convert_gateway_config_copilot.sh to output JSON to stdout instead of writing to file - Updated start_mcp_gateway.sh to save converted config to /tmp/gh-aw/mcp-config/copilot-mcp-config.json - Added --additional-mcp-config flag to copilot CLI invocation with inline JSON from file - Removed GH_AW_MCP_CONFIG environment variable as config is now passed inline - Config is no longer written to ~/.copilot/mcp-config.json Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Updated playwright_allowed_domains_secrets_test.go to check MCP gateway input instead of mcp-config.json - Recompiled all 148 workflows successfully - All Copilot workflows now use --additional-mcp-config flag instead of writing to ~/.copilot/mcp-config.json - Verified no Copilot workflows have GH_AW_MCP_CONFIG environment variable anymore - All unit tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Per @pelikhan's feedback, the MCP configuration is now stored as an environment variable instead of writing to a file, making it truly in-memory only. Changes: - start_mcp_gateway.sh: Store JSON in GH_AW_COPILOT_MCP_CONFIG env var and output to step - copilot_engine_execution.go: Use env var GH_AW_COPILOT_MCP_CONFIG from step output - Eliminates intermediate file /tmp/gh-aw/mcp-config/copilot-mcp-config.json - Uses GitHub Actions multiline string syntax for step output - Passes config via env var to prevent template injection Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| if hasMCPServers { | ||
| // The JSON is passed via GH_AW_COPILOT_MCP_CONFIG environment variable | ||
| // which is set from the step output to prevent template injection | ||
| copilotArgs = append(copilotArgs, "--additional-mcp-config", "\"$GH_AW_COPILOT_MCP_CONFIG\"") |
There was a problem hiding this comment.
@copilot you need to add the argument in a way that handles the case where the JSON payload contains quotes " and single quotes '
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot keep working |
The JSON payload in GH_AW_COPILOT_MCP_CONFIG can contain both single and double quotes. Using printf %q ensures the JSON is properly quoted for shell reuse, handling all special characters including quotes. Changes: - Add --additional-mcp-config after base command is built - Use printf %q "$GH_AW_COPILOT_MCP_CONFIG" for safe shell quoting - Works correctly when wrapped in AWF's single quotes via shellEscapeArg - All 148 workflows recompiled with proper quote handling Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Completed in 5e863bc. The --additional-mcp-config "$(printf %q "$GH_AW_COPILOT_MCP_CONFIG")"This handles both single quotes (') and double quotes (") in the JSON payload correctly. The |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
🧪 Smoke Project is now testing project operations... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✅ Changeset Generator completed successfully! |
|
❌ Smoke Project encountered failures. Check the logs for details. |
|
📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident... |
|
Smoke test (Codex)
|
Copilot CLI now receives MCP configuration via
--additional-mcp-configflag instead of reading from~/.copilot/mcp-config.json. All configuration remains in memory with no file writes.Changes
Shell Scripts
convert_gateway_config_copilot.sh: Output compact JSON to stdout (jq -c) instead of writing to filestart_mcp_gateway.sh: Store converted JSON inGH_AW_COPILOT_MCP_CONFIGenvironment variable and output to GitHub Actions step output using multiline string syntaxGo Code
copilot_engine_execution.go: SetGH_AW_COPILOT_MCP_CONFIGenvironment variable from step output and pass to copilot via--additional-mcp-config "$(printf %q "$GH_AW_COPILOT_MCP_CONFIG")"with proper quote escapingGH_AW_MCP_CONFIGenvironment variable (no longer needed)Tests
playwright_allowed_domains_secrets_test.go: Update to check MCP gateway input instead of file writesCompiled Output
Before:
After:
Security & Encoding Safety
jq -cand stored in environment variableprintf %qproperly escapes JSON containing both single quotes (') and double quotes (")Impact: Copilot engine only. Claude/Codex/Custom engines unchanged.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Changeset
--additional-mcp-configso the setup stays in memory instead of writingmcp-config.json.