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

  1. Set the full origin: GITHUB_HOST=https://github.mycompany.com
  2. For local development use http://localhost:PORT - loopback http is allowed
  3. 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

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


AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15). Data as JSON: /api/errors/a527fe2bfc96cd64. Report an issue: GitHub.