Fix #29726 — MCP server startup hang fix#29853
Open
zombi3butt wants to merge 1 commit into
Open
Conversation
…and improving error visibility (issue NousResearch#29726)
This was referenced May 26, 2026
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.
Fix #29726 — One unhealthy optional MCP integration should not make the whole Hermes session unavailable
Problem
When an MCP server is configured under
mcp_servers, Hermes attempts to connect and discover tools during startup. If that MCP server is down, slow, misconfigured, or fails duringinitialize/list_tools, Hermes startup could hang indefinitely before the normal chat session becomes usable.Root Cause
The
MCPServerTask.start()method calledawait self._ready.wait()with no timeout wrapper. If the server's internalrun()loop never fires_ready.set()(e.g., due to a silently swallowed exception in a nested transport handler),start()blocks forever — and since MCP discovery runs serially per-server, one dead server freezes the entire startup.Fix
MCPServerTask.start()— wrappedawait self._ready.wait()inasyncio.wait_for(timeout=connect_timeout). On timeout: cancels the orphaned run-task to prevent resource leaks, then raisesTimeoutError.hermes_cli/main.py— changed MCP startup error log fromlogger.debug→logger.warningso users see a clear "MCP tool discovery failed" message instead of silently losing tools.Behavior Change
connect_timeout) limits wait time. Failed servers log a visible warning. The rest of Hermes starts normally with available servers only.Notes
discover_mcp_tools()already usedasyncio.gather(return_exceptions=True)and logged warnings for per-server failures — this just adds the missing timeout guard at the lowest level (start()).