Repository navigation
fix(mcp): back off before respawning a failed server - #100
Merged
Merged
Conversation
Port of genkit-ai/genkit#6957. A connection that fails before completing a request, including one that never finishes its handshake, now waits before the server is started again: 1s, doubling with each failure in a row, up to 30s. Meanwhile listings and tool calls fail at once with UNAVAILABLE. A server that answered and then died is still replaced on next use, and restart()/host.reconnect() skip the wait. On top of upstream: the waiting error passes its cause so the message and Dev UI say why the server failed, the timed-out-then-died test uses an 8s timeout like the host stall tests, and the host docs say reconnect() skips the wait. Upstream-Commit: genkit-ai/genkit@b01ef02 Upstream-PR: genkit-ai/genkit#6957
hilariie
force-pushed
the
fix/mcp-respawn-backoff
branch
from
December 2, 2026 13:39
a28cdbd to
2be7286
Compare
Merged
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.
Ports genkit-ai/genkit#6957.
Why
A server that can't start was started again on every tool listing. In a host it was worse: all servers share one listing, so the broken server got a new process every time the healthy ones were listed, and every time a tool call on any of them failed.
Changes
UNAVAILABLEand an error saying how long is left. A timed-out request does not count as completed.restart()/host.reconnect()start the server straight away and reset the wait.Differences from upstream
_client.py: kept this repo'sMcpConnection(self._name, ..., host=self._host)call.cause=instead of only setting__cause__, so its message and Dev UI entry say why the server failed, like the package's other errors.test_a_server_that_timed_out_and_then_died_waits_toouses an 8sSTALL_TIMEOUT_MILLISinstead of 3s, matching the host tests, since the timeout also bounds the handshake and 3s flaked under heavy load.restart()andhost.reconnect()docstrings and the README say they skip the wait.Part of genkit-ai/genkit#6194.
Fixes #192.