Skip to content

fix(mcp): preserve authorized sessions during login - #122129

Merged
obviyus merged 1 commit into
mainfrom
fix/mcp-login-authorized-session
Aug 11, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/mcp-login-authorized-session

Conversation

@obviyus

@obviyus obviyus commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

#122115 extracted the OAuth login dance into startMcpOAuthAuthorization, but set suppressStoredTokens: true unconditionally — so openclaw mcp login <server> with a valid stored session now forces a browser authorization instead of completing immediately. Default-path regression relative to pre-#122115 behavior (main suppressed stored tokens only when a recorded challenge required interactive auth).

Why This Change Was Made

Restores the exact pre-refactor condition: suppressStoredTokens only when the store's pendingAuthorizationChallenge records requiresAuthorization. startMcpOAuthAuthorization now returns a closed result — {status:"authorized"} (valid/refreshable session, no browser, store untouched) or {status:"redirect", authorizationUrl, redirectUrl, state} — and the CLI early-returns the already-logged-in outcome on authorized.

User Impact

openclaw mcp login with a valid session completes without opening a browser, as before #122115. Challenge-recorded and cold-login paths unchanged.

Evidence

  • Regression tests at both seams: coordinator (start returns authorized, store row unchanged) and CLI loopback (no browser flow for valid session); the coordinator test fails pre-fix (returns redirect).
  • Grouped run green: node scripts/run-vitest.mjs src/agents/mcp-oauth src/cli/mcp-cli — 61 passed.
  • Caught by local ClawSweeper review of refactor(mcp): single OAuth identity owner + resumable authorization session #122115 (finding + rank-up move); the PR auto-merged before the fix landed, hence this follow-up.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 11, 2026
@obviyus
obviyus marked this pull request as ready for review August 11, 2026 16:11
@obviyus
obviyus requested a review from a team as a code owner August 11, 2026 16:11
@obviyus
obviyus enabled auto-merge (squash) August 11, 2026 16:14
@obviyus
obviyus merged commit 93f686f into main Aug 11, 2026
182 checks passed
@obviyus
obviyus deleted the fix/mcp-login-authorized-session branch August 11, 2026 16:23
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
Follow-up to openclaw#122115: startMcpOAuthAuthorization suppressed stored tokens
unconditionally, forcing a browser authorization on every mcp login even with a
valid session. Suppression is again gated on a recorded authorization-required
challenge; start returns a closed authorized|redirect result and the CLI
early-returns the already-logged-in outcome.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant