Handle MCP transport timeouts and disconnects - #452
Open
anthonyivn2 wants to merge 2 commits into
Open
Conversation
anthonyivn2
force-pushed
the
fix/allow-longer-timeout-limit
branch
from
September 2, 2026 13:52
4f55378 to
fea8136
Compare
anthonyivn2
marked this pull request as ready for review
September 2, 2026 14:10
added 2 commits
September 3, 2026 01:00
Signed-off-by: Anthony Ivan <anthony.ivan@databricks.com>
Signed-off-by: Anthony Ivan <anthony.ivan@databricks.com>
anthonyivn2
force-pushed
the
fix/allow-longer-timeout-limit
branch
from
September 2, 2026 17:01
82b0168 to
b985ada
Compare
sunishsheth2009
approved these changes
Sep 2, 2026
Collaborator
|
Approved the PR, can we confirm that this PR will resolve this issue? |
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
Issues the PR resolves
Align the custom HTTP client with MCP SDK timeouts
Problem: ucode supplies its own HTTPX client to attach Databricks per-request authentication. This bypasses the SDK client factory and its timeout configuration, leaving HTTPX’s 5-second read-inactivity default in effect. A slow GitHub MCP response can therefore disconnect while the operation is still valid.
The MCP protocol does not mandate timeout values. The 30-second connect/write/pool timeout and 300-second read timeout come from the MCP Python SDK implementation in v2.1.1.
Fix: explicitly configure these values on ucode’s authenticated client so it retains the SDK-recommended timeout behavior.
Code:
src/ucode/mcp_proxy.py—_run()Propagate errors yielded by MCP streams
Problem: MCP read streams can yield an
Exceptioninstead of a protocol message. The proxy previously forwarded every yielded value to stdio, so it did not recognize this value as a transport failure.Fix: detect and raise yielded exceptions. The bridge terminates with the original error, allowing the client to observe that the MCP connection failed.
Code:
src/ucode/mcp_proxy.py—_pump()Fail when the upstream stream closes unexpectedly
Problem: some transport failures surface to the proxy only as upstream EOF. Both proxy directions previously treated EOF as normal completion. The upstream pump could therefore finish successfully while the client-input pump continued waiting on stdin, leaving the proxy alive but unable to receive tool responses. Claude would continue showing the tool call as running.
Fix: treat completion of the upstream pump as an error. The error cancels the client-input pump and terminates the proxy. The client-input pump remains the normal control path, so Claude closing stdin still cancels the upstream task and shuts down cleanly.
Code:
src/ucode/mcp_proxy.py—_pump_upstream()and_run()Testing
uv run --frozen pytest tests/test_mcp_proxy.py -q— 27 passeduv run --frozen ruff check .git diff --check