Skip to content

fix(mcp): reset dead sign-in state after auth errors - #1740

Merged
dcramer merged 4 commits into
mainfrom
fix/mcp-oauth-stale-dcr-reset
Aug 31, 2026
Merged

fix(mcp): reset dead sign-in state after auth errors#1740
dcramer merged 4 commits into
mainfrom
fix/mcp-oauth-stale-dcr-reset

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #1739.

After an MCP provider's auth server is replaced, Junior kept the old client registration and kept sending the same broken sign-in link. Users also could not unlink MCP accounts that never finished connecting.

This change:

  • clears the stored client registration on a failed auth callback for the current attempt only
  • lets /unlink work for MCP providers
  • shows App Home Unlink when any MCP auth state exists, not only when tokens exist

Requested by David Cramer.

--

View Junior Session [Sentry]

Provider error callbacks left dead client/discovery credentials in place, and users could not unlink MCP plugins without tokens. Clear DCR state on error, allow MCP unlink, and surface incomplete MCP auth in App Home.

Co-Authored-By: David Cramer <david@sentry.io>
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Aug 31, 2026 12:31am

Request Review

Typecheck failed because test fixtures used authorization_server instead of authorizationServerUrl.
Comment thread packages/junior/src/handlers/mcp-oauth-callback.ts
Superseded OAuth error callbacks could wipe live client/discovery state. Only clear durable DCR metadata when the session still owns the pending auth attempt.
@sentry-junior sentry-junior Bot changed the title fix(mcp): clear stale DCR state after OAuth errors fix(mcp): reset dead sign-in state after auth errors Aug 31, 2026
@dcramer
dcramer marked this pull request as ready for review August 31, 2026 00:22
@github-actions github-actions Bot added the risk: high PR risk score: high label Aug 31, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6cbd6a0. Configure here.

Comment thread packages/junior/src/handlers/mcp-oauth-callback.ts
Error-callback DCR clears used a one-shot current-attempt check without the conversation lock, so a newer attempt could write credentials in between. Route cleanup through the same locked mutation path as success writes.
@dcramer
dcramer merged commit 6c6b90e into main Aug 31, 2026
38 checks passed
@dcramer
dcramer deleted the fix/mcp-oauth-stale-dcr-reset branch August 31, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP OAuth: stale DCR client/discovery state cannot be cleared after an error callback

1 participant