Skip to content

[WIP] Fix environment variable expansion for safeinputs MCP server#5801

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-safeinputs-mcp-configuration
Closed

[WIP] Fix environment variable expansion for safeinputs MCP server#5801
Copilot wants to merge 2 commits intomainfrom
copilot/fix-safeinputs-mcp-configuration

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Plan: Fix Environment Variable Expansion in Safe-Inputs MCP Server Configuration

The generated MCP configuration for the safeinputs server using Copilot contains unexpanded environment variables (${GH_AW_SAFE_INPUTS_PORT} instead of the actual port value), causing connection failures.

Root Cause

When the MCP config JSON file is created with heredoc (cat > file << EOF), environment variable placeholders like \${GH_AW_SAFE_INPUTS_PORT} are written literally. JSON doesn't expand shell variables, so when Copilot reads the config, it sees the literal string ${GH_AW_SAFE_INPUTS_PORT} instead of the actual port value.

Solution

  • Understand the current code flow
  • Add sed commands in PostEOFCommands to replace variable placeholders with actual values
  • Update safe_inputs.go to use consistent placeholder format
  • Add/update tests to verify the fix
  • Run full test suite and build
  • Manual verification
Original prompt

The generated configuration for the safeinputs mcp server using copilot is incorrect. The environment variables are not expanded (GH_AW_SAFE_INPUTS_PORT)

2025-12-08T02:33:20.103Z [LOG] Starting remote MCP client for safeinputs with url: http://host.docker.internal:${GH_AW_SAFE_INPUTS_PORT}
2025-12-08T02:33:20.104Z [LOG] Starting MCP client for safeoutputs with
command: node
args: /tmp/gh-aw/safeoutputs/mcp-server.cjs
cwd: /home/runner/work/gh-aw/gh-aw
2025-12-08T02:33:20.104Z [LOG] Starting MCP client for safeoutputs with command: node and args: /tmp/gh-aw/safeoutputs/mcp-server.cjs
2025-12-08T02:33:20.104Z [LOG] Creating MCP client for safeoutputs...
2025-12-08T02:33:20.109Z [LOG] Connecting MCP client for safeoutputs...
2025-12-08T02:33:20.113Z [ERROR] Failed to start MCP client for remote server safeinputs: TypeError: Invalid URL


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…rver configuration

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Contributor

pelikhan commented Dec 8, 2025

@copilot look how it is done for github mcp server "remote" mode

@pelikhan pelikhan closed this Dec 8, 2025
Copilot AI requested a review from pelikhan December 8, 2025 02:56
@pelikhan pelikhan deleted the copilot/fix-safeinputs-mcp-configuration branch December 11, 2025 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants