feat: reconnect with backoff and session re-establishment #2

Merged
w33ble merged 1 commit from feat/reconnect into main 2026-09-29 07:27:26 -06:00
Collaborator

Summary

  • Reconnect loop around probe/Connect and the message pumps: initial-connect failures and post-connect drops retry with backoff (1x/2x/4x/8x of --initial-retry-interval, capped) until --max-disconnected-time elapses (unset = retry forever).
  • Session re-establishment on each reconnect: replays the last-seen initialize on the fresh transport, discards the response, sends notifications/initialized, then flushes stdin lines buffered while down (64-line cap, drop-oldest).
  • Per-call ErrRejected write failures no longer kill the connection; stdin EOF mid-backoff still exits 0.
  • New flags: --max-disconnected-time (default infinity) and --initial-retry-interval (default 5s), both with MCP_BRIDGE_* env fallbacks.
  • Fixes parseTrailingFlags no-op so flags after the positional URL are honored.
  • Tests: backoff calc, flag/env parsing (incl. invalid values), rejection detection; existing smoke test untouched. Build, vet, lint, and tests all green.

Why

  • Previously any network hiccup or remote restart killed the bridge process and the MCP client saw a dead server until the client session was restarted manually. The proxy now rides out transient outages transparently.
Summary - Reconnect loop around probe/Connect and the message pumps: initial-connect failures and post-connect drops retry with backoff (1x/2x/4x/8x of --initial-retry-interval, capped) until --max-disconnected-time elapses (unset = retry forever). - Session re-establishment on each reconnect: replays the last-seen initialize on the fresh transport, discards the response, sends notifications/initialized, then flushes stdin lines buffered while down (64-line cap, drop-oldest). - Per-call ErrRejected write failures no longer kill the connection; stdin EOF mid-backoff still exits 0. - New flags: --max-disconnected-time (default infinity) and --initial-retry-interval (default 5s), both with MCP_BRIDGE_* env fallbacks. - Fixes parseTrailingFlags no-op so flags after the positional URL are honored. - Tests: backoff calc, flag/env parsing (incl. invalid values), rejection detection; existing smoke test untouched. Build, vet, lint, and tests all green. Why - Previously any network hiccup or remote restart killed the bridge process and the MCP client saw a dead server until the client session was restarted manually. The proxy now rides out transient outages transparently.
feat: reconnect with backoff and session re-establishment
All checks were successful
CI / Build, vet, test, lint (pull_request) Successful in 52s
CI / Build, vet, test, lint (push) Successful in 2m29s
76c5a8bf1d
Add --max-disconnected-time (default infinity) and
--initial-retry-interval (default 5s), with MCP_BRIDGE_* env
fallbacks. Retry initial connect and post-connect drops with
1x/2x/4x/8x backoff; replay stored initialize, send
notifications/initialized, then flush stdin buffered while down.
Per-call ErrRejected failures no longer kill the connection.

Also fix parseTrailingFlags no-op so flags after the positional
URL are honored.
w33ble merged commit 76c5a8bf1d into main 2026-09-29 07:27:26 -06:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
w33ble/mcp-ferryman!2
No description provided.