fix(mcp): coordinate OAuth token refresh and authorization polling

Prevent concurrent refresh-token rotation across instances, distinguish
expired-but-refreshable tokens from active authorization, and bind OAuth
popup polling to a per-attempt ID so stale tokens cannot satisfy new consent.
This commit is contained in:
wizardchen
2026-07-23 15:33:20 +08:00
committed by lyingbug
parent c74b0caa35
commit 8ae82573ab
31 changed files with 1418 additions and 109 deletions
+5
View File
@@ -2,6 +2,7 @@ package tools
import (
"context"
"errors"
"fmt"
"strings"
"time"
@@ -271,6 +272,10 @@ func isAuthorizationRequired(err error) bool {
if mcpclient.IsOAuthAuthorizationRequiredError(err) || mcpclient.IsAuthorizationRequiredError(err) {
return true
}
var reauth *mcp.OAuthReauthorizationRequiredError
if errors.As(err, &reauth) {
return true
}
msg := err.Error()
return strings.Contains(msg, "authorization required") ||
strings.Contains(msg, "no valid token") ||