github/github-mcp-server · error
failed to get GitHub client: %w
Error message
failed to get GitHub client: %w
What it means
uiGetLabels failed in deps.GetGQLClient(ctx): the GraphQL client (githubv4) could not be constructed from the configured auth/transport before any query ran. Same failure family as the REST GetClient error, but for the GraphQL endpoint.
Source
Thrown at pkg/github/ui_tools.go:114
case "reviewers":
return uiGetReviewers(ctx, deps, args, owner)
default:
return utils.NewToolResultError(fmt.Sprintf("unknown method: %s", method)), nil, nil
}
})
st.FeatureFlagEnable = MCPAppsFeatureFlag
return st
}
func uiGetLabels(ctx context.Context, deps ToolDependencies, args map[string]any, owner string) (*mcp.CallToolResult, any, error) {
repo, err := RequiredParam[string](args, "repo")
if err != nil {
return utils.NewToolResultError(err.Error()), nil, nil
}
client, err := deps.GetGQLClient(ctx)
if err != nil {
return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
}
var query struct {
Repository struct {
Labels struct {
Nodes []struct {
ID githubv4.ID
Name githubv4.String
Color githubv4.String
Description githubv4.String
}
TotalCount githubv4.Int
PageInfo struct {
HasNextPage githubv4.Boolean
EndCursor githubv4.String
}
} `graphql:"labels(first: 100, after: $cursor)"`
} `graphql:"repository(owner: $owner, name: $repo)"`View on GitHub (pinned to 0ea1f775a7)
Solutions
- Verify token configuration for the configured host
- Check the GraphQL endpoint availability (curl https://<host>/api/graphql)
- Inspect server logs for auth/transport initialization errors
Defensive patterns
Strategy: validation
Validate before calling
token := os.Getenv("GITHUB_MCP_BACKEND_GITHUB_TOKEN")
if token == "" {
log.Fatal("GraphQL tools need a configured token")
}
if resp, err := http.Head(graphqlURL()); err != nil || resp.StatusCode >= 500 {
log.Fatal("GraphQL endpoint unavailable")
} Prevention
- Verify the GraphQL endpoint is enabled and reachable on GHES hosts (/api/graphql)
- Construct the GraphQL client once at startup and fail fast
- Keep REST and GraphQL credential configuration in sync
When it happens
Trigger: No or invalid token; OAuth token exchange failure; GHES host where the GraphQL endpoint (/api/graphql) is disabled or unreachable; host URL configuration resolving to an invalid GraphQL URL.
Common situations: Remote server deployments missing token env vars; GHES instances without GraphQL enabled; proxies blocking the graphql path.
Related errors
- owner is required
- failed to get GitHub client: %w
- GitHub App authentication and OAuth login (--oauth-client-id
- GitHub App installation ID is required (GITHUB_APP_INSTALLAT
- GitHub App REST base URL is required
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/1b401a77a7873a6e.
Report an issue: GitHub.