Add --auto-restart option to automatically recover expired sessions#79
Open
Add --auto-restart option to automatically recover expired sessions#79
Conversation
Allow users to disable automatic bridge restart on crash via `mcpc connect --no-auto-restart <server> @session`. When set, crashed bridges require manual restart with `mcpc @session restart`. The flag is stored in session data and checked in both ensureBridgeReady() (initial health check) and SessionClient.withRetry() (mid-operation crash). https://claude.ai/code/session_01JguVLhdg3mmrejPXf9RehX
Auto-restart can silently lose session state (MCP session ID, subscriptions, in-flight requests), which is confusing. Flip the default so crashed bridges stay crashed with a clear error message, and users opt in with `mcpc connect --auto-restart` when they explicitly accept potential state loss. https://claude.ai/code/session_01JguVLhdg3mmrejPXf9RehX
Auto-restart should only handle expired sessions (server rejected session ID), not crashed bridges. Crashed bridges already have their own recovery logic that always restarts on next command. Move auto-restart logic into ensureBridgeReady's expired-session handling and classifyAndThrowSessionError, revert all changes to SessionClient (crash recovery stays unchanged). https://claude.ai/code/session_01JguVLhdg3mmrejPXf9RehX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an
--auto-restartoption to theconnectcommand that enables automatic recovery when MCP server sessions expire, eliminating the need for manualmcpc @session restartcommands.Key Changes
--auto-restartflag to theconnectcommand that persists the setting in session configurationclassifyAndThrowSessionError()to return'expired'whenautoRestartis enabled, allowing callers to handle recovery instead of throwing immediatelyensureBridgeReady()to detect expired sessions and automatically:ensureBridgeReady())classifyAndThrowSessionError())autoRestart=falseequivalent to error classification on retry--auto-restartoption for enabling automatic recoveryImplementation Details
autoRestartflag is stored inSessionDataand passed through the session configurationhttps://claude.ai/code/session_01JguVLhdg3mmrejPXf9RehX