Skip to content

fix(mcp): reconnect after MCP call timeout - #24508

Closed
bitboarderlabs wants to merge 14 commits into
NousResearch:mainfrom
bitboarderlabs:upstream/mcp-timeout-reconnect
Closed

fix(mcp): reconnect after MCP call timeout#24508
bitboarderlabs wants to merge 14 commits into
NousResearch:mainfrom
bitboarderlabs:upstream/mcp-timeout-reconnect

Conversation

@bitboarderlabs

Copy link
Copy Markdown

Summary

  • cancel MCP loop work when a configured tool-call timeout elapses
  • treat MCP call timeouts as a stale transport signal: reconnect the long-lived MCP server task and retry once
  • reuse the session-expired reconnect path for timeout recovery so circuit breakers are reset on successful reconnect

Tests

  • /home/alex/.hermes/hermes-agent/venv/bin/python -m pytest tests/tools/test_mcp_tool_session_expired.py tests/tools/test_mcp_tool.py tests/tools/test_mcp_circuit_breaker.py tests/tools/test_mcp_reconnect_signal.py tests/tools/test_mcp_probe.py -q

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets tool/mcp MCP client and OAuth labels May 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related: #6665 (MCP timeout cancellation + session TOCTOU race). This PR extends the timeout handling to also reconnect the transport and retry, building on the same problem space.

@bitboarderlabs
bitboarderlabs force-pushed the upstream/mcp-timeout-reconnect branch from 3b080ba to 7242561 Compare May 16, 2026 16:00
@bitboarderlabs

Copy link
Copy Markdown
Author

Rebased this PR onto current upstream main (3034eee) and resolved the conflict in tools/mcp_tool.py by keeping the new parallel-safe server registry plus the timeout/session reconnect helpers.\n\nLocal MCP-focused test run passed:\n\n\n/home/alex/.hermes/hermes-agent/venv/bin/python -m pytest tests/tools/test_mcp_tool_session_expired.py tests/tools/test_mcp_tool.py tests/tools/test_mcp_circuit_breaker.py tests/tools/test_mcp_reconnect_signal.py tests/tools/test_mcp_probe.py -q\n230 passed in 17.26s\n

@bitboarderlabs
bitboarderlabs deleted the upstream/mcp-timeout-reconnect branch June 3, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists tool/mcp MCP client and OAuth type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants