Skip to content

Auto-detect auth profiles on session restart#70

Merged
jancurn merged 3 commits intomainfrom
claude/fix-session-reauth-CqBT3
Mar 13, 2026
Merged

Auto-detect auth profiles on session restart#70
jancurn merged 3 commits intomainfrom
claude/fix-session-reauth-CqBT3

Conversation

@jancurn
Copy link
Member

@jancurn jancurn commented Mar 13, 2026

Summary

Session restart now automatically detects and applies OAuth profiles that were created after the session was initially established. This fixes the workflow where a user creates a session without authentication, then runs mcpc login <server> to create a profile, and finally restarts the session.

Changes

  • Modified restartSession() to attempt profile auto-detection when:
    • No profile is currently stored in the session
    • The server URL is available
    • No explicit Authorization header is provided
  • Profile resolution uses the existing resolveAuthProfile() function with the server URL
  • If a profile is discovered, the session is updated to persist the profile name for future restarts
  • Gracefully handles profile resolution failures (e.g., when multiple profiles exist with no default) by logging and continuing without a profile
  • Added debug logging to track profile discovery and resolution failures

Implementation Details

  • The auto-detection only runs when conditions indicate the session may benefit from a newly-created profile
  • Errors during profile resolution are caught and logged but don't interrupt the restart flow, preserving backward compatibility with sessions intentionally created without profiles
  • The discovered profile is persisted via updateSession() to avoid repeated resolution attempts on subsequent restarts

https://claude.ai/code/session_01TRdQzrv6aVfpXsbJMhzRob

claude and others added 3 commits March 13, 2026 08:48
When a session was created without authentication and the user later ran
`mcpc login <server> && mcpc @session restart`, the restart would not
detect the newly created OAuth profile because it only checked the stored
profileName (which was undefined). Now restartSession() calls
resolveAuthProfile() to auto-detect default profiles, matching the
behavior of connectSession().

https://claude.ai/code/session_01TRdQzrv6aVfpXsbJMhzRob
When --profile is not explicitly provided, resolveAuthProfile now only
looks for the "default" profile. Previously it would error if non-default
profiles existed without a default, which was confusing. Non-default
profiles now require an explicit --profile flag.

Also simplifies the restart auth resolution by removing the try/catch
that was needed to handle the now-removed error case.

https://claude.ai/code/session_01TRdQzrv6aVfpXsbJMhzRob
@jancurn jancurn merged commit 3ba75da into main Mar 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants