Skip to content

Move MCP gateway volume mounts from shell script to compiler generation#9469

Merged
pelikhan merged 6 commits into
mainfrom
copilot/refactor-docker-mounts-setup
Jan 9, 2026
Merged

Move MCP gateway volume mounts from shell script to compiler generation#9469
pelikhan merged 6 commits into
mainfrom
copilot/refactor-docker-mounts-setup

Conversation

Copilot AI commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Move MCP Gateway Mounts from Shell Script to Compiler

Completed Tasks

  • Understand the current implementation

    • Hardcoded mounts in actions/setup/sh/start_mcp_gateway.sh lines 105-106
    • Three mounts: /opt:/opt:ro, /tmp:/tmp:rw, and ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw
  • Add Mounts field to MCPGatewayRuntimeConfig struct

    • Updated pkg/workflow/tools_types.go to add Mounts []string field
  • Update compiler to generate mounts in MCP_GATEWAY_DOCKER_COMMAND

    • Modified pkg/workflow/mcp_servers.go to include mounts when building containerCmd
    • Updated ensureDefaultMCPGatewayConfig to set default mounts if not provided
    • Fixed quoting issue: mounts are not individually quoted since entire command is wrapped in quotes
  • Update shell script to use mounts from docker command

    • Removed hardcoded mounts from actions/setup/sh/start_mcp_gateway.sh
    • Mounts are now passed through in MCP_GATEWAY_DOCKER_COMMAND
  • Add/update tests

    • Created pkg/workflow/mcp_gateway_mounts_test.go with comprehensive tests
    • Tests for default mounts, custom mounts, and docker command generation
    • All tests pass successfully
  • Fix docker command format issue (nested quoting)

    • Removed nested quoting that caused docker: Error response from daemon: invalid mode: rw'
    • Command now correctly formatted without double quoting
  • Fix GITHUB_WORKSPACE variable expansion

    • Changed quoting format to allow ${GITHUB_WORKSPACE} to be expanded at runtime
    • New format: 'docker run ... -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ...'
    • This closes the single quote before the variable, adds it in double quotes, then reopens the quote
    • Added buildDockerCommandWithExpandableVars() function to handle special variable quoting
  • Manual verification

    • Recompiled all 117 workflows successfully
    • All workflows now include properly formatted mounts with expandable GITHUB_WORKSPACE variable
    • Example: export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host -e DEBUG="*" -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ghcr.io/githubnext/gh-aw-mcpg:v0.0.10'

Summary

Successfully moved MCP gateway volume mounts from hardcoded shell script to compiler-generated docker command. The mounts are now:

  • Configurable via sandbox.mcp.mounts in workflow frontmatter
  • Set to sensible defaults if not configured
  • Properly formatted with correct quoting that allows variable expansion
  • ${GITHUB_WORKSPACE} is properly expanded at runtime in the shell
  • Consistently applied across all 117 workflows
Original prompt

Review the hard coded mounts at https://github.com/githubnext/gh-aw/blob/57dda28757fae3e03b5a68cf068e2869384e10c8/actions/setup/sh/start_mcp_gateway.sh#L105-L106 and instead have the compiler generate them as part of creating the call to the docker run command.


💡 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.

Copilot AI and others added 3 commits January 9, 2026 18:45
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add Mounts field to MCPGatewayRuntimeConfig struct
- Update ensureDefaultMCPGatewayConfig to set default mounts
- Update container command generation to include volume mounts
- Remove hardcoded mounts from start_mcp_gateway.sh
- Add comprehensive tests for mount generation
- Default mounts: /opt:/opt:ro, /tmp:/tmp:rw, ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw
- Supports custom mount configuration via sandbox.mcp.mounts

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
All lock files now include volume mounts in MCP_GATEWAY_DOCKER_COMMAND:
- -v /opt:/opt:ro
- -v /tmp:/tmp:rw
- -v '${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw'

This completes the migration from hardcoded mounts in the shell script
to compiler-generated mounts in the docker command.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor hard coded mounts in Docker run command Move MCP gateway volume mounts from shell script to compiler generation Jan 9, 2026
Copilot AI requested a review from pelikhan January 9, 2026 18:58
@pelikhan pelikhan added the smoke label Jan 9, 2026
@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

💀 Blimey! Changeset Generator failed and walked the plank! No treasure today, matey! ☠️

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident...

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@pelikhan

pelikhan commented Jan 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot fix the docker command format

Validating gateway configuration...
Configuration validated successfully

Starting gateway with container: docker run -i --rm --network host -e DEBUG="*" -v /opt:/opt:ro -v /tmp:/tmp:rw -v '${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw' ghcr.io/githubnext/gh-aw-mcpg:latest
Gateway started with PID: 3754

Waiting for gateway to be ready...
Attempt 1/30: Gateway not ready yet, waiting 1 second...

ERROR: Gateway failed to become ready after 30 attempts

Gateway stdout (errors are written here per MCP Gateway Specification):

Gateway stderr logs (debug output):
docker: Error response from daemon: invalid mode: rw'

Run 'docker run --help' for more information

The issue was that mounts were being quoted individually with shellQuote()
and then the entire command was quoted again, causing malformed syntax like:
-v '\''${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw'\''

Fixed by not quoting individual mounts since the entire command is wrapped
in quotes. Now generates correct format:
-v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw

Updated test to match the new behavior.

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

Copilot AI commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the docker command format

Validating gateway configuration...
...

Fixed in dd5ed16. The issue was nested quoting - mounts were being quoted individually and then the entire command was quoted again, causing malformed syntax. Now mounts are not individually quoted since the entire command is wrapped in quotes, resulting in correct format:

export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host -e DEBUG="*" -v /opt:/opt:ro -v /tmp:/tmp:rw -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw ghcr.io/githubnext/gh-aw-mcpg:latest'

@pelikhan pelikhan added smoke and removed smoke labels Jan 9, 2026
@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident...

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

💀 Blimey! Changeset Generator failed and walked the plank! No treasure today, matey! ☠️

@pelikhan

pelikhan commented Jan 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot you need fix the inclusion of ${GITHUB_WORKSPACE} --> $GITHUB_WORKSPACE so it gets rendered

Starting gateway with container: docker run -i --rm --network host -e DEBUG="*" -v /opt:/opt:ro -v /tmp:/tmp:rw -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw ghcr.io/githubnext/gh-aw-mcpg:latest
Gateway started with PID: 3709

Changed the docker command export format to allow ${GITHUB_WORKSPACE}
to be expanded at runtime. Previously it was wrapped in single quotes
which prevented expansion.

New format: 'docker run ... -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ...'

This closes the single quote before the variable, adds it in double quotes
for expansion, then reopens the single quote. When executed with
$MCP_GATEWAY_DOCKER_COMMAND, ${GITHUB_WORKSPACE} will now be properly
expanded to the actual workspace path.

Added buildDockerCommandWithExpandableVars() function to handle this
special quoting for variables that need runtime expansion.

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

Copilot AI commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot you need fix the inclusion of ${GITHUB_WORKSPACE} --> $GITHUB_WORKSPACE so it gets rendered

...

Fixed in 8176f16. Changed the docker command format to allow ${GITHUB_WORKSPACE} variable expansion at runtime. The command now uses:

export MCP_GATEWAY_DOCKER_COMMAND='docker run ... -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ...'

This closes the single quote before the variable, adds it in double quotes for expansion, then reopens the single quote. When the shell executes $MCP_GATEWAY_DOCKER_COMMAND, ${GITHUB_WORKSPACE} will be properly expanded to the actual workspace path.

@pelikhan pelikhan added smoke and removed smoke labels Jan 9, 2026
@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident...

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

💀 Blimey! Changeset Generator failed and walked the plank! No treasure today, matey! ☠️

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@pelikhan pelikhan marked this pull request as ready for review January 9, 2026 20:30
@pelikhan pelikhan merged commit 86d844e into main Jan 9, 2026
32 of 36 checks passed
@pelikhan pelikhan deleted the copilot/refactor-docker-mounts-setup branch January 9, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants