github/github-mcp-server · error
failed to get GitHub client: %w
Error message
failed to get GitHub client: %w
What it means
The list_global_security_advisories tool failed to construct a go-github client. Global advisories need no repo, but the tool still requires a working client: with RequestDeps this error means the request context has no token info or the REST/upload URL derivation from configured hosts failed. It is a configuration/auth failure that happens before any Advisory Database call.
Source
Thrown at pkg/github/security_advisories.go:92
Type: "string",
Description: "Filter by publish date or date range (ISO 8601 date or range).",
},
"updated": {
Type: "string",
Description: "Filter by update date or date range (ISO 8601 date or range).",
},
"modified": {
Type: "string",
Description: "Filter by publish or update date or date range (ISO 8601 date or range).",
},
},
},
},
[]scopes.Scope{scopes.SecurityEvents},
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
client, err := deps.GetClient(ctx)
if err != nil {
return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
}
ghsaID, err := OptionalParam[string](args, "ghsaId")
if err != nil {
return utils.NewToolResultError(fmt.Sprintf("invalid ghsaId: %v", err)), nil, nil
}
typ, err := OptionalParam[string](args, "type")
if err != nil {
return utils.NewToolResultError(fmt.Sprintf("invalid type: %v", err)), nil, nil
}
cveID, err := OptionalParam[string](args, "cveId")
if err != nil {
return utils.NewToolResultError(fmt.Sprintf("invalid cveId: %v", err)), nil, nil
}
eco, err := OptionalParam[string](args, "ecosystem")View on GitHub (pinned to 0ea1f775a7)
Solutions
- Ensure every request carries a valid token or run stdio mode with GITHUB_PERSONAL_ACCESS_TOKEN set
- Verify host-related env vars parse (full scheme + host) and point at the intended GitHub instance
- Prefer BaseDeps with a pre-built client when embedding without per-request tokens
Defensive patterns
Strategy: validation
Validate before calling
// Verify token + host wiring before exposing advisory tools
if os.Getenv("GITHUB_PERSONAL_ACCESS_TOKEN") == "" && !remoteAuthConfigured {
return errors.New("no GitHub token configured for advisory tools")
}
u, err := url.Parse(getEnvOr("GITHUB_API_URL", "https://api.github.com/"))
if err != nil || u.Host == "" {
return errors.New("GITHUB_API_URL is not a valid absolute URL")
} Type guard
func isClientSetupErr(err error) bool {
return err != nil && (strings.Contains(err.Error(), "no token info in context") ||
strings.Contains(err.Error(), "failed to get base REST URL"))
} Try / catch
client, err := deps.GetClient(ctx)
if err != nil {
if isClientSetupErr(err) {
return nil, nil, utils.NewToolResultError("server auth/host misconfiguration: " + err.Error())
}
return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
} Prevention
- Construct a client once at startup to validate config before serving tools
- Reject tokenless requests in remote mode before tool dispatch
- Document which env vars each deployment mode actually reads
When it happens
Trigger: Remote mode without Authorization on the request; GITHUB_HOST/GITHUB_ENTERPRISE_URL/GITHUB_UPLOAD_URL misconfigured so apiHosts.BaseRESTURL() or UploadURL() errors; go-github.NewClient failure.
Common situations: Unauthenticated HTTP transport pointed at the server; env vars set in one shell but not in the service unit/container; mixed stdio/remote configuration.
Related errors
- failed to get GitHub client: %w
- failed to get GitHub client: %w
- failed to get repo access cache: %w
- lockdown cache is not configured
- failed to get GitHub client: %w
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/f32d79638509e4b4.
Report an issue: GitHub.