Skip to content

Add GITHUB_HOST environment variable support for GitHub Enterprise Server and GitHub Enterprise Cloud#852

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-0470e061-75ae-42b0-ad6f-12c1f13cbe84
Closed

Add GITHUB_HOST environment variable support for GitHub Enterprise Server and GitHub Enterprise Cloud#852
Copilot wants to merge 3 commits intomainfrom
copilot/fix-0470e061-75ae-42b0-ad6f-12c1f13cbe84

Conversation

Copy link
Contributor

Copilot AI commented Sep 16, 2025

This PR adds support for GitHub Enterprise Server (GHES) and GitHub Enterprise Cloud with data residency by passing the GITHUB_HOST environment variable to the GitHub MCP server Docker container.

Problem

The GitHub MCP server configuration was missing the GITHUB_HOST environment variable, which is required for connecting to GitHub Enterprise Server or GitHub Enterprise Cloud with data residency (ghe.com). Without this variable, the MCP server defaults to connecting to github.com, preventing workflows from working with enterprise GitHub instances.

Solution

Updated all three AI engines (Claude, Custom, and Codex) to include the GITHUB_HOST environment variable in their GitHub MCP server configurations:

  • Docker args: Added -e GITHUB_HOST to pass the environment variable to the container
  • Environment: Set GITHUB_HOST to ${{ env.GITHUB_SERVER_URL }} (GitHub Actions' built-in environment variable)

Example Configuration

The generated GitHub MCP configuration now includes:

{
  "mcpServers": {
    "github": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
        "-e", "GITHUB_HOST",
        "ghcr.io/github/github-mcp-server:sha-09deac4"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
        "GITHUB_HOST": "${{ env.GITHUB_SERVER_URL }}"
      }
    }
  }
}

This enables the GitHub MCP server to automatically connect to the correct GitHub instance based on where the workflow is running:

  • GitHub.com: GITHUB_SERVER_URL = https://github.com
  • GitHub Enterprise Server: GITHUB_SERVER_URL = https://your-ghes-instance.com
  • GitHub Enterprise Cloud with data residency: GITHUB_SERVER_URL = https://yoursubdomain.ghe.com

Testing

  • Added comprehensive test coverage for all three engines
  • Verified all existing workflows recompile successfully
  • Manually tested workflow compilation to confirm GITHUB_HOST is included in generated configurations
  • All existing tests continue to pass

Files Changed

  • pkg/workflow/claude_engine.go: Updated renderGitHubClaudeMCPConfig
  • pkg/workflow/custom_engine.go: Updated renderGitHubMCPConfig
  • pkg/workflow/codex_engine.go: Updated renderGitHubCodexMCPConfig
  • pkg/workflow/codex_engine_test.go: Updated test expectations
  • pkg/workflow/mcp_config_test.go: Added validation test for GITHUB_HOST

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build527290485/b279/cli.test -test.testlogfile=/tmp/go-build527290485/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build1584658749/b279/cli.test -test.testlogfile=/tmp/go-build1584658749/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build4114491301/b279/cli.test -test.testlogfile=/tmp/go-build4114491301/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 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 2 commits September 16, 2025 13:25
…ss all engines

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

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update compiler so that the github host is passed along in the github MCP configuration. Use the github action host environment variable. --- GitHub Enterprise Server and Enterprise Cloud with data residency (ghe.com) The flag --gh-host and the en... Add GITHUB_HOST environment variable support for GitHub Enterprise Server and GitHub Enterprise Cloud Sep 16, 2025
Copilot AI requested a review from pelikhan September 16, 2025 13:30
@pelikhan pelikhan marked this pull request as ready for review September 16, 2025 13:33
@pelikhan pelikhan closed this Sep 16, 2025
@pelikhan pelikhan deleted the copilot/fix-0470e061-75ae-42b0-ad6f-12c1f13cbe84 branch September 16, 2025 13:35
@kbreit
Copy link

kbreit commented Feb 24, 2026

Why was this closed without merging? I'm running into this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants