{"record":{"id":"d9d04f0f2894ad33","repo":"github/github-mcp-server","slug":"failed-to-get-github-client-w-d9d04f","errorCode":null,"errorMessage":"failed to get GitHub client: %w","messagePattern":"failed to get GitHub client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/labels.go","lineNumber":91,"sourceCode":"\t\t\t\tRepository struct {\n\t\t\t\t\tLabel struct {\n\t\t\t\t\t\tID          githubv4.ID\n\t\t\t\t\t\tName        githubv4.String\n\t\t\t\t\t\tColor       githubv4.String\n\t\t\t\t\t\tDescription githubv4.String\n\t\t\t\t\t} `graphql:\"label(name: $name)\"`\n\t\t\t\t} `graphql:\"repository(owner: $owner, name: $repo)\"`\n\t\t\t}\n\n\t\t\tvars := map[string]any{\n\t\t\t\t\"owner\": githubv4.String(owner),\n\t\t\t\t\"repo\":  githubv4.String(repo),\n\t\t\t\t\"name\":  githubv4.String(name),\n\t\t\t}\n\n\t\t\tclient, err := deps.GetGQLClient(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to get GitHub client: %w\", err)\n\t\t\t}\n\n\t\t\tif err := client.Query(ctx, &query, vars); err != nil {\n\t\t\t\treturn ghErrors.NewGitHubGraphQLErrorResponse(ctx, \"Failed to find label\", err), nil, nil\n\t\t\t}\n\n\t\t\tif query.Repository.Label.Name == \"\" {\n\t\t\t\treturn utils.NewToolResultError(fmt.Sprintf(\"label '%s' not found in %s/%s\", name, owner, repo)), nil, nil\n\t\t\t}\n\n\t\t\tlabel := map[string]any{\n\t\t\t\t\"id\":          fmt.Sprintf(\"%v\", query.Repository.Label.ID),\n\t\t\t\t\"name\":        string(query.Repository.Label.Name),\n\t\t\t\t\"color\":       string(query.Repository.Label.Color),\n\t\t\t\t\"description\": string(query.Repository.Label.Description),\n\t\t\t}\n\n\t\t\tout, err := json.Marshal(label)","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/labels.go#L73-L109","documentation":"The get_label tool could not construct a GraphQL client via deps.GetGQLClient before querying the label. Underlying causes are 'no token info in context' (the request context carries no auth token) or 'failed to get GraphQL URL' (the configured API host could not be resolved). The wrapped error text identifies which.","triggerScenarios":"Invoking get_label when the server has no GitHub token configured, the token was not propagated into the request context (per-request auth missing), or the GH_HOST/GITHUB_API_URL host configuration is invalid.","commonSituations":"Forgetting to set GITHUB_TOKEN (or --read-only-token) when starting the server; remote/streamable HTTP deployments where the Authorization header is absent; a misconfigured enterprise API host (GITHUB_API_URL) that cannot yield a GraphQL endpoint.","solutions":["Check the wrapped message: 'no token info in context' means supply a token (GITHUB_TOKEN env or Authorization header for remote mode)","'failed to get GraphQL URL' means fixing the host config — verify GITHUB_API_URL/GH_HOST points at a valid GitHub or GHES host","Restart the server with a valid token and retry the get_label call"],"exampleFix":"# before\ndocker run ghcr.io/github/github-mcp-server\n# after\ndocker run -e GITHUB_TOKEN=ghp_xxx ghcr.io/github/github-mcp-server","handlingStrategy":"validation","validationCode":"func preflightAuth() error {\n\tif os.Getenv(\"GITHUB_TOKEN\") == \"\" {\n\t\treturn fmt.Errorf(\"GITHUB_TOKEN not set; get_label will fail to build a client\")\n\t}\n\tif host := os.Getenv(\"GITHUB_API_URL\"); host != \"\" {\n\t\tu, err := url.Parse(host)\n\t\tif err != nil || u.Host == \"\" {\n\t\t\treturn fmt.Errorf(\"GITHUB_API_URL is not a valid host\")\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to get GitHub client\") {\n    // Auth/host config problem, not transient. Fix token or API host; do not retry unchanged.\n}","preventionTips":["Set GITHUB_TOKEN (or forward Authorization headers in remote mode) before startup","Health-check auth with a cheap call (get_label on a known repo) after deployment"],"tags":["auth","configuration","graphql-client","labels"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}