github/github-mcp-server · error

github authorization failed: %w

Error message

github authorization failed: %w

What it means

Error "github authorization failed: %w" thrown in github/github-mcp-server.

Source

Thrown at internal/ghmcp/oauth.go:165

			if mgr.HasToken() {
				return next(ctx, req)
			}
			if serverMayInitiateElicitation(req.Session) {
				return authorizeViaServerElicitation(ctx, mgr, next, req, logger)
			}
			return startMultiRoundTripAuthorization(ctx, mgr, next, req, logger)
		}
	}
}

// authorizeViaServerElicitation drives authorization on legacy protocol versions
// (before 2026-07-28), where the server may present the prompt itself via
// server-initiated elicitation. It blocks until the token arrives, then proceeds.
func authorizeViaServerElicitation(ctx context.Context, mgr oauthAuthenticator, next mcp.ToolHandler, req *mcp.CallToolRequest, logger *slog.Logger) (*mcp.CallToolResult, error) {
	outcome, err := mgr.Authenticate(ctx, &sessionPrompter{session: req.Session})
	if err != nil {
		return nil, fmt.Errorf("github authorization failed: %w", err)
	}
	if outcome != nil && outcome.UserAction != nil {
		logger.Info("surfacing github authorization instructions to user")
		return &mcp.CallToolResult{
			Content: []mcp.Content{&mcp.TextContent{Text: outcome.UserAction.Message}},
		}, nil
	}
	return next(ctx, req)
}

// authorizationElicitResponse finds the authorization response and extracts the
// flow ID encoded in its input-request key.
func authorizationElicitResponse(responses mcp.InputResponseMap) (string, *mcp.ElicitResult, bool) {
	for id, response := range responses {
		flowID, ok := strings.CutPrefix(id, oauthElicitIDPrefix)
		if !ok || flowID == "" {
			continue
		}

View on GitHub (pinned to 0ea1f775a7)

When it happens

Trigger: Thrown at internal/ghmcp/oauth.go:165 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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