Skip to content

fix: lazily reconnect MCP tools on call - #23540

Closed
WittmannF wants to merge 1 commit into
NousResearch:mainfrom
WittmannF:fix/mcp-lazy-reconnect
Closed

fix: lazily reconnect MCP tools on call#23540
WittmannF wants to merge 1 commit into
NousResearch:mainfrom
WittmannF:fix/mcp-lazy-reconnect

Conversation

@WittmannF

Copy link
Copy Markdown

Summary

  • Adds a best-effort lazy reconnect path when an MCP tool schema exists but the in-process server/session is missing
  • Removes stale disconnected server entries before rediscovery so configured servers can reconnect without a manual gateway restart
  • Adds regression coverage for missing-server lazy reconnect on tool calls

Test Plan

  • python -m pytest tests/tools/test_mcp_tool_session_expired.py -o 'addopts=' -q
  • python -m pytest tests/tools/test_mcp_tool.py tests/tools/test_mcp_tool_session_expired.py tests/tools/test_mcp_oauth*.py tests/hermes_cli/test_mcp_config.py -o 'addopts=' -q

@teknium1

teknium1 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closing with credit — you were the earliest (May 11) to identify this bug class: a dead cached MCP server entry that a new session can't recover. The fix landed differently: the run task now never dies (parks + self-probes every 5 min, PR #59222), tools re-register on revival, and register_mcp_servers nudges any cached entry with a dead transport at session startup (PR #59331, merged). Your handler-side lazy reconnect would now race the always-alive task, so it wasn't taken directly, but the problem you flagged is fixed. Thanks!

@teknium1 teknium1 closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants