How to Configure the GitHub MCP Server to Connect to GitHub Enterprise Server

To connect the GitHub MCP server to GitHub Enterprise Server, set the --gh-host CLI flag or GITHUB_HOST environment variable to your GHES URL, provide a valid GITHUB_TOKEN, and run the server locally since the remote hosted version only supports GitHub.com.

The github/github-mcp-server repository provides a local MCP (Model Context Protocol) server that exposes GitHub tools to AI assistants. When your organization uses GitHub Enterprise Server (GHES) instead of GitHub.com, you must explicitly configure the server to target your private instance's API endpoints.

Prerequisites for GitHub Enterprise Server Connectivity

Local Server Requirement

You must run the GitHub MCP server locally or self-host it. The remote hosted server at api.githubcopilot.com only works with GitHub.com and GitHub Enterprise Cloud (GHEC), and cannot proxy requests to private GHES instances. Download and run the binary from the github/github-mcp-server releases or build from source.

Authentication Token

Generate a Personal Access Token (PAT) or GitHub App token on your GHES instance with scopes matching the tools you plan to enable. Common scopes include repo, read:org, and workflow. The server reads this token from the GITHUB_TOKEN environment variable or the --token CLI flag defined in cmd/github-mcp-server/main.go at line 156.

Configuration Methods for GHES Connection

Using the --gh-host CLI Flag

The most explicit method is passing the --gh-host flag when starting the server. This flag is defined in cmd/github-mcp-server/main.go at line 135 and overrides the default github.com host with your GHES URL.

github-mcp-server \
  --gh-host https://ghe.mycompany.com \
  --token ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
  --toolsets repos,issues,pull_requests \
  --read-only=false

Using the GITHUB_HOST Environment Variable

For containerized deployments or when you prefer environment-based configuration, set GITHUB_HOST. The server uses Viper to bind this environment variable to the same internal configuration as the --gh-host flag.

export GITHUB_HOST="https://ghe.mycompany.com"
export GITHUB_TOKEN="ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

github-mcp-server \
  --toolsets repos,issues \
  --read-only=true

Using a JSON Configuration File

For complex deployments, create a JSON configuration file that specifies the host, token, and toolsets. The server reads this via the --config flag. The schema is documented in docs/server-configuration.md.

{
  "host": "https://ghe.mycompany.com",
  "token": "ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "toolsets": ["repos", "issues", "pull_requests"],
  "tools": [],
  "read_only": false,
  "log_file": "/var/log/github-mcp-server.log"
}

Start the server with:

github-mcp-server --config ./config.json

Complete Configuration Examples

Docker Deployment

When running the official container image, pass the GHES configuration as environment variables:

docker run -it --rm \
  -e GITHUB_HOST=https://ghe.mycompany.com \
  -e GITHUB_TOKEN=ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
  -p 8080:8080 \
  ghcr.io/github/github-mcp-server:latest \
  --toolsets repos,issues

VS Code Settings

Configure your editor to connect to the locally running MCP server. Since the server already knows the GHES host, the client configuration only needs the server address:

{
  "github.copilot.mcp.server": "http://localhost:8080",
  "github.copilot.mcp.enabled": true
}

Troubleshooting GHES Connectivity

HTTPS Requirement

GitHub Enterprise Server requires HTTPS for all API communication. The GITHUB_HOST value must start with https://. Plain HTTP connections are rejected by the GHES API as documented in the repository README.

Self-Signed Certificates

If your GHES instance uses a self-signed certificate or an internal CA not trusted by your system, the connection will fail with TLS errors. You have two resolution paths:

  1. Add the internal CA certificate to your system's trust store.
  2. Set the environment variable GITHUB_INSECURE_SKIP_VERIFY=true to bypass TLS verification (documented in docs/server-configuration.md).

Warning: Only use GITHUB_INSECURE_SKIP_VERIFY in development environments, as it disables protection against man-in-the-middle attacks.

Summary

  • Run locally: The remote api.githubcopilot.com MCP server cannot connect to GHES; you must run the github/github-mcp-server binary locally.
  • Set the host: Use --gh-host or GITHUB_HOST to point to your GHES URL (e.g., https://ghe.mycompany.com).
  • Authenticate: Provide a GITHUB_TOKEN with appropriate scopes for your enabled toolsets.
  • Use HTTPS: GHES requires HTTPS connections; configure TLS trust for self-signed certs if necessary.

Frequently Asked Questions

Can I use the hosted GitHub Copilot MCP server with GitHub Enterprise Server?

No. The hosted server at api.githubcopilot.com only supports GitHub.com and GitHub Enterprise Cloud. For GitHub Enterprise Server, you must download and run the github/github-mcp-server binary locally or self-host it in your infrastructure.

What authentication token do I need for GitHub Enterprise Server?

You need a Personal Access Token (PAT) or GitHub App token generated directly on your GHES instance. The token must include scopes corresponding to the MCP tools you enable—for example, repo for repository operations, read:org for organization data, and workflow for Actions-related tools.

How do I handle self-signed certificates on my GHES instance?

If your GHES uses a self-signed certificate or an internal Certificate Authority, either add the CA to your system's trust store or set the GITHUB_INSECURE_SKIP_VERIFY=true environment variable. Note that skipping verification reduces security and should only be used in controlled development environments.

Where is the GitHub Enterprise Server host configuration stored in the code?

The host configuration is defined in cmd/github-mcp-server/main.go at line 135 for the --gh-host flag, and the GITHUB_HOST environment variable binding is handled via Viper in the same file. The resolved host is then used in internal/ghmcp/server.go to initialize the GitHub API client with the correct base URL for your GHES instance.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →