Skip to content

fix(mcp): apply timeout to initialize handshake and list_tools#2823

Merged
bug-ops merged 1 commit intomainfrom
2815-tui-mcp-handshake-timeout
Apr 8, 2026
Merged

fix(mcp): apply timeout to initialize handshake and list_tools#2823
bug-ops merged 1 commit intomainfrom
2815-tui-mcp-handshake-timeout

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 8, 2026

Summary

  • Wraps handler.serve(transport) in connect(), connect_url(), and connect_url_with_headers() with tokio::time::timeout(timeout, ...), returning McpError::Timeout on expiry
  • Applies the same guard to list_all_tools() in list_tools()
  • Adds 4 unit tests covering the new timeout error paths

Root Cause

Only call_tool applied a timeout; the initialize handshake and tools/list RPC were unbounded. A stalled MCP server (slow Docker pull, unresponsive process, network issue) blocked connect_all() indefinitely, causing TUI startup to hang at "Connecting tools..." with no recovery path.

Test Plan

  • cargo +nightly fmt --check -p zeph-mcp — clean
  • cargo clippy -p zeph-mcp --all-features -- -D warnings — 0 warnings
  • cargo nextest run -p zeph-mcp --lib — 418/418 passed (was 414; 4 new tests added)

Closes #2815

Wraps handler.serve(transport) in connect(), connect_url(), and
connect_url_with_headers() with tokio::time::timeout(timeout, ...),
returning McpError::Timeout on expiry. Applies the same guard to
list_all_tools() in list_tools().

Previously only call_tool had a timeout; a stalled MCP server during
the initialize handshake or tool listing blocked connect_all()
indefinitely, causing TUI startup to hang at "Connecting tools..."
with no recovery path.

Adds 4 unit tests covering the new timeout paths.

Closes #2815
@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Apr 8, 2026
@bug-ops bug-ops enabled auto-merge (squash) April 8, 2026 05:02
@bug-ops bug-ops merged commit efda2e2 into main Apr 8, 2026
27 checks passed
@bug-ops bug-ops deleted the 2815-tui-mcp-handshake-timeout branch April 8, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tui hangs on startup when mcp server stalls during initialize handshake

1 participant