{"record":{"id":"9dad54a5bc130587","repo":"github/github-mcp-server","slug":"failed-to-get-github-client-w-9dad54","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/copilot.go","lineNumber":218,"sourceCode":"\t\t\t\tRequired: []string{\"owner\", \"repo\", \"issue_number\"},\n\t\t\t},\n\t\t},\n\t\t[]scopes.Scope{scopes.Repo},\n\t\tfunc(ctx context.Context, deps ToolDependencies, request *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {\n\t\t\tvar params struct {\n\t\t\t\tOwner              string `mapstructure:\"owner\"`\n\t\t\t\tRepo               string `mapstructure:\"repo\"`\n\t\t\t\tIssueNumber        int32  `mapstructure:\"issue_number\"`\n\t\t\t\tBaseRef            string `mapstructure:\"base_ref\"`\n\t\t\t\tCustomInstructions string `mapstructure:\"custom_instructions\"`\n\t\t\t}\n\t\t\tif err := mapstructure.WeakDecode(args, &params); err != nil {\n\t\t\t\treturn utils.NewToolResultError(err.Error()), nil, nil\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\t// Firstly, we try to find the copilot bot in the suggested actors for the repository.\n\t\t\t// Although as I write this, we would expect copilot to be at the top of the list, in future, maybe\n\t\t\t// it will not be on the first page of responses, thus we will keep paginating until we find it.\n\t\t\ttype botAssignee struct {\n\t\t\t\tID       githubv4.ID\n\t\t\t\tLogin    string\n\t\t\t\tTypeName string `graphql:\"__typename\"`\n\t\t\t}\n\n\t\t\ttype suggestedActorsQuery struct {\n\t\t\t\tRepository struct {\n\t\t\t\t\tSuggestedActors struct {\n\t\t\t\t\t\tNodes []struct {\n\t\t\t\t\t\t\tBot botAssignee `graphql:\"... on Bot\"`\n\t\t\t\t\t\t}\n\t\t\t\t\t\tPageInfo struct {","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/copilot.go#L200-L236","documentation":"deps.GetGQLClient(ctx) failed while starting the assign_copilot_to_issue tool. RequestDeps.GetGQLClient reads TokenInfo from the request context and resolves the GraphQL endpoint from the configured API host; it returns an error when the token is missing from the context (auth middleware did not attach it) or when the GraphQL URL cannot be derived (misconfigured GHES host / GITHUB_API_URL). The Copilot assignment never starts — no GraphQL query is sent.","triggerScenarios":"Invoking assign_copilot_to_issue when the server was started without a usable token source (no GITHUB_PERSONAL_ACCESS_TOKEN, GitHub App credentials failed to mint an installation token, OAuth exchange failure), or with an enterprise host whose GraphQL endpoint cannot be resolved (bad --gh-host / GITHUB_API_URL for GHES).","commonSituations":"Empty or missing GITHUB_PERSONAL_ACCESS_TOKEN env var, expired GitHub App installation, GHES hostname without API endpoints configured, embedding the server and dispatching tools with a context that never went through the auth transport that calls ghcontext.WithTokenInfo.","solutions":["Set a valid token: export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_... (or configure GitHub App / OAuth credentials) and restart the server","Verify the API host configuration — for GHES check --gh-host/GITHUB_API_URL resolve to a reachable instance with GraphQL enabled","If embedding, ensure the request context flows through the auth transport that attaches ghcontext.TokenInfo before tool handlers run","Confirm with a REST-based tool (e.g. get_me) that auth works at all; if every tool fails the same way it is server-level auth, not Copilot"],"exampleFix":"# before\n$ ./github-mcp-server stdio   # no token configured -> assign_copilot_to_issue fails with 'failed to get GitHub client: no token info in context'\n\n# after\n$ export GITHUB_PERSONAL_ACCESS_TOKEN=\"ghp_xxx\"\n$ ./github-mcp-server stdio","handlingStrategy":"validation","validationCode":"// before invoking Copilot tools, confirm the server has a token source configured\nfunc requireTokenEnv() error {\n\tif os.Getenv(\"GITHUB_PERSONAL_ACCESS_TOKEN\") == \"\" &&\n\t\tos.Getenv(\"GITHUB_APP_ID\") == \"\" {\n\t\treturn fmt.Errorf(\"no GitHub token configured: set GITHUB_PERSONAL_ACCESS_TOKEN or App credentials before using Copilot tools\")\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"client, err := deps.GetGQLClient(ctx)\nif err != nil {\n\tswitch {\n\tcase strings.Contains(err.Error(), \"no token info in context\"):\n\t\t// fix auth configuration/server startup, do not retry\n\tcase strings.Contains(err.Error(), \"failed to get GraphQL URL\"):\n\t\t// fix GHES host / GITHUB_API_URL configuration\n\tdefault:\n\t\treturn fmt.Errorf(\"failed to get GitHub client: %w\", err)\n\t}\n}","preventionTips":["Always start the server with a validated token source; fail startup fast when credentials are absent","For GHES, verify host configuration resolves both REST and GraphQL endpoints before deploying","Embedders must route every tool call through the auth transport that calls ghcontext.WithTokenInfo"],"tags":["go","authentication","graphql","copilot","configuration"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}