claude-code - 💡(How to fix) Fix MCP OAuth: auto-resume model turn after authentication completes [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51678Fetched 2026-04-22 07:55:48
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Root Cause

RAW_BUFFERClick to expand / collapse

Problem

When an MCP server requires OAuth authentication, Claude calls mcp__<server>__authenticate, gets back an auth URL, and presents it to the user. The browser opens (either natively or via a PostToolUse hook), the user completes Okta/SSO login, and the MCP SDK's localhost callback receives the token silently.

However, Claude's turn has already ended. The user must manually re-type their original request (e.g., "list data stores") even though auth succeeded and the tools are now available. This is a poor UX — the user already told Claude what they wanted.

Expected Behavior

After MCP OAuth completes (localhost callback receives the auth code), Claude Code should automatically resume the model's turn so it can retry the original tool call without user intervention.

Proposed Solutions (in order of preference)

  1. Auto-resume: When the MCP SDK receives the OAuth callback, emit an internal event that resumes the model's turn with context about the original request. Claude continues as if the tool call succeeded.

  2. PostToolUse hook with auth-completion signal: Provide a hook event (e.g., McpAuthComplete) that fires when OAuth finishes, allowing plugins to trigger continuation.

  3. Built-in retry: After mcp__<server>__authenticate returns an auth URL, Claude Code could internally poll or wait for the callback, then automatically re-invoke the model with the original context.

Context

extent analysis

TL;DR

Implement an auto-resume mechanism that resumes the model's turn with the original request context after the MCP SDK receives the OAuth callback.

Guidance

  • Investigate the feasibility of emitting an internal event from the MCP SDK when it receives the OAuth callback, as proposed in the Auto-resume solution.
  • Explore the possibility of using a PostToolUse hook with an auth-completion signal, such as McpAuthComplete, to trigger the continuation of the model's turn.
  • Consider implementing a built-in retry mechanism in Claude Code that polls or waits for the OAuth callback and then re-invokes the model with the original context.
  • Review the code changes in the Grafana MCP OAuth hook pull request (twilio-internal/claude-marketplace#759) for potential insights into addressing this issue.

Example

No code snippet is provided as the issue does not contain sufficient code details.

Notes

The proposed solutions may require modifications to the MCP SDK, Claude Code, or both. It is essential to evaluate the trade-offs and feasibility of each approach before implementing a solution.

Recommendation

Apply the Auto-resume workaround, as it seems to be the most straightforward and user-friendly solution, allowing the model to resume its turn seamlessly after OAuth authentication completes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING