SEP: MCP Client Silent Refresh on 401 Invalid Token#2702
Open
waddah12alhajar wants to merge 2 commits into
Open
SEP: MCP Client Silent Refresh on 401 Invalid Token#2702waddah12alhajar wants to merge 2 commits into
waddah12alhajar wants to merge 2 commits into
Conversation
Builds on SEP-2207 (OIDC-Flavored Refresh Token Guidance) which standardized how clients request refresh tokens via offline_access. SEP-2207 stops at issuance; this proposal specifies how clients should USE the refresh token when receiving 401 invalid_token from a remote MCP server — silent refresh + single retry, structured needs_reauth fallback when the refresh token is itself invalid. Filed alongside typescript-sdk#2031 which tracks the SDK-side reference implementation. The two are complementary: SDK fix lands transparently for TS SDK consumers; this SEP makes the behavior normative across MCP clients. Filename uses placeholder 0000 — to be renamed to the assigned PR number per SEP-1850.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a draft SEP that specifies expected MCP HTTP client behavior when receiving
HTTP 401 Bearer error="invalid_token"from a remote MCP server while a refresh token is available locally. Builds directly on SEP-2207 (OIDC-Flavored Refresh Token Guidance).Motivation
SEP-2207 closed the issuance side of refresh tokens (
offline_accessrequest, AS metadata, capability advertising). It deliberately did not specify what clients should do with refresh tokens when an access token expires mid-session. As a result, current MCP clients (Cursor, Claude Code/Desktop, VS Code) handle 401 inconsistently — some refresh transparently, some surface the error to the model, some prompt the user.I maintain a remote MCP connector for Power BI / Azure Data Factory analytics. The connector is fully spec-compliant on the resource-server side (RFC 6750 §3 challenge, RFC 9728 metadata, SEP-2207
offline_accessrequest). Despite this, in some Claude client sessions the 401 surfaces to the model as a tool error, even though the prerequisites for silent refresh are all met. Manual reauthentication mid-session is the only recovery, which is jarring for B2B / multi-hour analytics workflows.This SEP makes the silent-refresh-on-401 client behavior normative and clarifies the failure-to-
needs_reauthfallback when the refresh token itself is invalid.Highlights
offline_accessrequested at sign-in).SHOULDrather thanMUST— leaves room for clients with legitimate reasons to opt out (e.g. step-up-on-every-request security policies).tool_use_idso the model sees a coherent retry, not a synthetic side-effect.needs_reauthfailure path when refresh fails — clients route to UI prompts, not silent failures.Filename
Used placeholder
seps/0000-mcp-client-silent-refresh-on-401.mdper SEP-1850 (PR-based SEP workflow). Happy to rename to the assigned PR number once you confirm.Sponsor
Looking for a sponsor. SEP-2207 was sponsored by @pcarleton with @wdawson as author — given the topical overlap they're the natural asks. Tagging both for visibility.
Cross-references
Asks of reviewers