# How to Configure MCP Server to Connect to GitHub Enterprise Cloud

> Configure MCP Server to connect to GitHub Enterprise Cloud by setting the Host field using environment variables command-line flags or HTTP headers. Get started with your ghe.com subdomain.

- Repository: [GitHub/github-mcp-server](https://github.com/github/github-mcp-server)
- Tags: how-to-guide
- Published: 2026-02-16

---

**Configure the GitHub MCP Server to connect to GitHub Enterprise Cloud by setting the `Host` field in `MCPServerConfig` to your `ghe.com` subdomain using either the `GITHUB_HOST` environment variable, the `--gh-host` command-line flag, or the `X-MCP-Host` HTTP header.**

The GitHub MCP Server enables AI assistants to interact with GitHub repositories through the Model Context Protocol (MCP). When you need to configure the MCP server to connect to GitHub Enterprise Cloud—particularly for data-residency deployments using the `ghe.com` domain—you must explicitly specify the host endpoint so the server routes API requests correctly.

## Understanding the Host Configuration Architecture

### The MCPServerConfig.Host Field

In [`pkg/github/server.go`](https://github.com/github/github-mcp-server/blob/main/pkg/github/server.go), the server defines a configuration struct that controls all GitHub API interactions:

```go
type MCPServerConfig struct {
    Host  string
    Token string
    // ... other fields
}

```

The `Host` field determines whether the server connects to `github.com` or your private GitHub Enterprise Cloud instance. When left empty, the server defaults to the public GitHub.com API endpoints.

### How the Server Builds API Clients

The [`pkg/github/dependencies.go`](https://github.com/github/github-mcp-server/blob/main/pkg/github/dependencies.go) file (lines 82-90) handles the construction of REST, GraphQL, and raw HTTP clients using your configured host. The server calls `githubv4.NewEnterpriseClient` unconditionally, passing the parsed host value to ensure all subsequent API calls—whether for issues, pull requests, or repository data—target your Enterprise Cloud installation.

## Three Methods to Configure GitHub Enterprise Cloud Connection

### Environment Variable GITHUB_HOST (STDIO Mode)

For local STDIO-based MCP servers, set the `GITHUB_HOST` environment variable before launching the server. This method is documented in [`README.md`](https://github.com/github/github-mcp-server/blob/main/README.md) under the section "GitHub Enterprise Server and Enterprise Cloud with data residency (ghe.com)" and in [`.github/copilot-instructions.md`](https://github.com/github/github-mcp-server/blob/main/.github/copilot-instructions.md).

The server reads this variable at startup and assigns it to `MCPServerConfig.Host`.

### Command-Line Flag --gh-host

When running the server binary directly, use the `--gh-host` flag to specify your Enterprise Cloud domain:

```bash
go run ./cmd/github-mcp-server stdio \
  --gh-host https://mycompany.ghe.com \
  --token $GITHUB_PAT

```

This flag is parsed by the CLI and passed directly to the configuration struct in [`pkg/github/server.go`](https://github.com/github/github-mcp-server/blob/main/pkg/github/server.go).

### HTTP Header X-MCP-Host (Remote Mode)

For remote HTTP deployments where the MCP server runs as a service, you can override the host per-request using the `X-MCP-Host` header. This is handled in [`pkg/http/middleware/request_config.go`](https://github.com/github/github-mcp-server/blob/main/pkg/http/middleware/request_config.go), which applies request-level configuration overrides.

This approach allows a single MCP server instance to serve multiple GitHub Enterprise Cloud organizations by routing requests based on the header value.

## Configuration Examples for GitHub Enterprise Cloud

### Local STDIO Server with Environment Variable

Configure your MCP client (such as Claude Desktop or Copilot) to pass the host via environment variables:

```json
{
  "type": "stdio",
  "command": "go",
  "args": [
    "run",
    "./cmd/github-mcp-server",
    "stdio",
    "--toolsets=issues,pull_requests"
  ],
  "env": {
    "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here",
    "GITHUB_HOST": "https://mycompany.ghe.com"
  }
}

```

### Local STDIO Server with CLI Flag

Alternatively, pass the host directly as a command-line argument:

```bash
go run ./cmd/github-mcp-server stdio \
  --gh-host https://mycompany.ghe.com \
  --toolsets=issues,pull_requests \
  --token $GITHUB_PAT

```

### Remote HTTP Server with Per-Request Headers

For HTTP-based MCP servers, configure your client to send the host header:

```json
{
  "type": "http",
  "url": "https://api.githubcopilot.com/mcp/",
  "headers": {
    "X-MCP-Host": "https://mycompany.ghe.com",
    "X-MCP-Toolsets": "issues,repo",
    "Authorization": "Bearer $COPILOT_TOKEN"
  }
}

```

### Docker Deployment with Environment Variable

When running the official container image, pass the host as an environment variable:

```bash
export GITHUB_HOST=https://mycompany.ghe.com
export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_your_token_here

docker run -e GITHUB_HOST -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server

```

## Summary

- The GitHub MCP Server uses `MCPServerConfig.Host` in [`pkg/github/server.go`](https://github.com/github/github-mcp-server/blob/main/pkg/github/server.go) to determine which GitHub instance to target.
- You can configure GitHub Enterprise Cloud connectivity through three methods: the `GITHUB_HOST` environment variable, the `--gh-host` command-line flag, or the `X-MCP-Host` HTTP header for remote deployments.
- The host value must include the `https://` scheme and follow the format `https://YOURSUBDOMAIN.ghe.com` for data-residency Enterprise Cloud instances.
- All API clients (REST, GraphQL, and raw HTTP) are constructed in [`pkg/github/dependencies.go`](https://github.com/github/github-mcp-server/blob/main/pkg/github/dependencies.go) using the configured host, ensuring consistent routing for all tool operations.

## Frequently Asked Questions

### What URL format should I use for GitHub Enterprise Cloud?

You must include the full URL scheme and subdomain. For GitHub Enterprise Cloud with data residency, use `https://YOURSUBDOMAIN.ghe.com`. Omitting the `https://` prefix causes the server to default to `http://`, which GitHub Enterprise Cloud does not accept.

### Can I switch between GitHub.com and Enterprise Cloud dynamically?

Yes, but the method depends on your deployment mode. For local STDIO servers, you must restart the server with a different `GITHUB_HOST` value or `--gh-host` flag. For remote HTTP servers, you can switch dynamically by sending different `X-MCP-Host` header values per request, as handled by [`pkg/http/middleware/request_config.go`](https://github.com/github/github-mcp-server/blob/main/pkg/http/middleware/request_config.go).

### Where is the host configuration stored internally?

The host value is stored in the `Host` field of the `MCPServerConfig` struct defined in [`pkg/github/server.go`](https://github.com/github/github-mcp-server/blob/main/pkg/github/server.go). This configuration object is passed to `github.NewMCPServer` and subsequently used by [`pkg/github/dependencies.go`](https://github.com/github/github-mcp-server/blob/main/pkg/github/dependencies.go) to instantiate API clients. The value is also logged at server startup for verification.

### Do I need different authentication for Enterprise Cloud?

No, the authentication mechanism remains the same. You still use a GitHub Personal Access Token (PAT) passed via the `GITHUB_PERSONAL_ACCESS_TOKEN` environment variable or `--token` flag. However, ensure your token has the appropriate scopes for your Enterprise Cloud organization and that the token was generated on the specific Enterprise Cloud instance you are targeting.