github/github-mcp-server · error
host must have a scheme (http or https): %s
Error message
host must have a scheme (http or https): %s
What it means
The configured host parsed as a URL but had an empty scheme. parseAPIHost requires a full origin like https://github.example.com and rejects bare hostnames such as github.example.com or localhost:8443. This is the most common GHES onboarding mistake; an empty value is fine and means github.com.
Source
Thrown at pkg/utils/api.go:243
}
defer resp.Body.Close()
return resp.StatusCode == http.StatusOK
}
// Note that this does not handle ports yet, so development environments are out.
func parseAPIHost(s string) (APIHost, error) {
if s == "" {
return newDotcomHost()
}
u, err := url.Parse(s)
if err != nil {
return APIHost{}, fmt.Errorf("could not parse host as URL: %s", s)
}
if u.Scheme == "" {
return APIHost{}, fmt.Errorf("host must have a scheme (http or https): %s", s)
}
// Enforce HTTPS centrally so no deployment (GHES in particular) can build
// authenticated REST/GraphQL/upload/raw URLs over cleartext http, which
// would leak the bearer token/PAT to anyone on the network.
if err := requireSecureScheme(u); err != nil {
return APIHost{}, err
}
switch classifyHost(u) {
case HostTypeDotcom:
return newDotcomHost()
case HostTypeGHEC:
return newGHECHost(s)
default:
return newGHESHost(s)
}
}View on GitHub (pinned to 0ea1f775a7)
Solutions
- Set the full origin: GITHUB_HOST=https://github.mycompany.com
- For local development use http://localhost:PORT - loopback http is allowed
- Inspect the live value: printenv GITHUB_HOST
Example fix
# before GITHUB_HOST=github.mycompany.com # after GITHUB_HOST=https://github.mycompany.com
Defensive patterns
Strategy: validation
Validate before calling
host := strings.TrimSpace(os.Getenv("GITHUB_HOST"))
if host != "" && !strings.Contains(host, "://") {
return fmt.Errorf("GITHUB_HOST %q must include a scheme, e.g. https://%s", host, host)
} Prevention
- Document GHES onboarding with the full https origin, never a bare hostname
- Fail fast at startup on scheme-less hosts
- Remember empty GITHUB_HOST means github.com - do not set it to a bare hostname for dotcom
When it happens
Trigger: Setting GITHUB_HOST=github.mycompany.com or --github-host github.mycompany.com without the https:// prefix.
Common situations: Operators pasting the appliance hostname from internal docs; CI configs assuming a scheme is prepended automatically.
Related errors
- failed to get GitHub client: %w
- failed to get GitHub client: %w
- could not parse host as URL: %s
- host must use https to avoid sending credentials over cleart
- authentication required: set GITHUB_PERSONAL_ACCESS_TOKEN, c
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/a527fe2bfc96cd64.
Report an issue: GitHub.