Skip to content

Add --auto-restart option for automatic session recovery - #312

Open
jancurn wants to merge 2 commits into
mainfrom
claude/mcpc-connect-auto-restart-5h2253
Open

Add --auto-restart option for automatic session recovery#312
jancurn wants to merge 2 commits into
mainfrom
claude/mcpc-connect-auto-restart-5h2253

Conversation

@jancurn

@jancurn jancurn commented Jul 21, 2026

Copy link
Copy Markdown
Member

Adds a --auto-restart option to mcpc connect: sessions expired by the server are restarted automatically with a fresh MCP session (previous session state is lost), instead of failing every command until an explicit restart. Recovery is opt-in and uses the same machinery as crashed-bridge reconnection — on next use of the session, or in the background whenever sessions are probed (e.g. mcpc or mcpc grep), so things like mcpc grep keep working unattended.

  • --auto-restart on connect (single and bulk), persisted as autoRestart in sessions.json
  • ensureBridgeReady recovers expired auto-restart sessions with a fresh session; retries once fresh when resumption is rejected
  • consolidateSessions schedules expired auto-restart sessions for background reconnection (with the existing cooldown)
  • Fixes a related race: server-side failures reported by a live bridge no longer trigger a needless bridge restart that could overwrite the expired status with active
  • Unit tests + e2e suite (sessions/auto-restart) covering direct and grep-triggered background recovery

https://claude.ai/code/session_01AEszDHmhkTf8EhhXg2H8NV

Comment thread src/cli/commands/sessions.ts Outdated
jancurn pushed a commit that referenced this pull request Jul 21, 2026
…n list

The CLI already kicks off a background restart for these sessions when
listing them, so suggesting a manual command is pointless.

Refs #312

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AEszDHmhkTf8EhhXg2H8NV
claude added 2 commits July 23, 2026 08:48
…d sessions

Sessions created with `mcpc connect --auto-restart` no longer fail until an
explicit `restart` when the server rejects their MCP session id: the stored
session id is discarded and the session is restarted automatically with a
fresh MCP session — on next use, or in the background whenever sessions are
probed (e.g. `mcpc` or `mcpc grep`), the same way crashed bridges already
reconnect. Previous server-side session state is lost on such a restart.

Also fixes a related race: a server-side network failure (e.g. an expired
session) reported by the bridge over IPC no longer makes the CLI restart the
healthy bridge, which could overwrite the session's `expired`/`unauthorized`
status with `active` and hide the real state.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AEszDHmhkTf8EhhXg2H8NV
…n list

The CLI already kicks off a background restart for these sessions when
listing them, so suggesting a manual command is pointless.

Refs #312

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AEszDHmhkTf8EhhXg2H8NV
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