Auto-reconnect crashed bridge processes in the background#103
Open
Auto-reconnect crashed bridge processes in the background#103
Conversation
Adds a new grep command that searches tools, resources, and prompts by name and description across all active MCP sessions. Supports regex matching (-E), case-sensitive mode (-s), and type filters (--tools, --resources, --prompts). Available as both a top-level command (all sessions) and session command (single session). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add recovery hints for crashed and expired sessions in session list Show actionable hints under crashed and expired sessions in `mcpc` output, similar to the existing hint for unauthorized sessions. https://claude.ai/code/session_01D6ovkixxWohRHXaJP7Hh3g * Remove extra text from crashed session hint https://claude.ai/code/session_01D6ovkixxWohRHXaJP7Hh3g --------- Co-authored-by: Claude <noreply@anthropic.com>
When enumerating sessions (e.g. `mcpc` or `mcpc grep`), crashed bridges are now automatically restarted in the background without blocking the command. A 10-second cooldown (connect timeout + 5s buffer) between restart attempts prevents rapid retries. The lastRestartAttemptAt timestamp is persisted in sessions.json and checked inside the file lock to avoid concurrent restart races. https://claude.ai/code/session_01FJXX4xys8aMoF4iVZbkC86
Avoid restarting a bridge that just crashed — wait for the cooldown period after lastSeenAt to give the old process time to fully clean up and prevent socket conflicts in shared-home environments. https://claude.ai/code/session_01FJXX4xys8aMoF4iVZbkC86
Introduce two new transient session states that give users visibility into bridge lifecycle transitions: - 'connecting': shown during initial `mcpc connect` before bridge is ready - 'reconnecting': shown when a crashed bridge is being auto-reconnected Both display as yellow filled dots (●) in human output and as string values in JSON output. Stale transient states (>10s with no PID) automatically fall back to 'crashed'. Also rename lastRestartAttemptAt → lastConnectionAttemptAt and autoRestartCrashedSessions → reconnectCrashedSessions to better reflect that this is a bridge reconnection, not a full session restart. https://claude.ai/code/session_01FJXX4xys8aMoF4iVZbkC86
Resolve conflicts with PR #100 (grep command) and PR #105 (help fix): - Take main's grep.ts (more features: --instructions, -m, capability-aware) and re-apply reconnectCrashedSessions call - Take main's index.ts grep options - Export DisplayStatus/getBridgeStatus (used by grep.ts) with new states - Merge changelog entries https://claude.ai/code/session_01FJXX4xys8aMoF4iVZbkC86
Sessions with dead bridges may show as 'reconnecting' (auto-reconnect in progress) instead of 'crashed', depending on timing. Update the expired and failover tests to accept both states. https://claude.ai/code/session_01FJXX4xys8aMoF4iVZbkC86
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
mcpcormcpc grep)lastRestartAttemptAtinsessions.jsonImplementation
lastRestartAttemptAtfield toSessionDatafor cooldown trackingconsolidateSessions()now identifies crashed sessions eligible for restart (inside the file lock to prevent concurrent races) and returns them insessionsToRestartautoRestartCrashedSessions()inbridge-manager.tsfires offrestartBridge()calls without awaiting themlistSessionsAndAuthProfilesandgrepAllSessionscallautoRestartCrashedSessionsafter consolidationTest plan
mcpctwice (first marks crashed + triggers restart, second should show live)mcpctwice rapidly — second run should not trigger another restart attemptmcpc grepalso triggers auto-restart of crashed sessionshttps://claude.ai/code/session_01FJXX4xys8aMoF4iVZbkC86