fix(mcp): bump default discovery wait from 0.75s to 3.0s for npx cold start - #43685
Closed
sj-unit72 wants to merge 1 commit into
Closed
fix(mcp): bump default discovery wait from 0.75s to 3.0s for npx cold start#43685sj-unit72 wants to merge 1 commit into
sj-unit72 wants to merge 1 commit into
Conversation
… start The MCP discovery wait_for_mcp_discovery helper has a 0.75s default timeout. npx-driven MCP servers (e.g. `npx -y @griches/apple-mail-mcp`) typically take 2-4s to install and spawn on first launch. The agent snapshots its tool list once at build time and never re-reads it, so any slow-but-reachable server that finishes connecting after 0.75s is silently dropped from the tool list for the entire session. Reproduction: register four npx-driven Apple MCPs (mail, contacts, reminders, calendar) in config.yaml and start a chat session. The mail server is loaded (it happened to land first), but the other three are missing from the agent's tool list. They appear in 'hermes mcp test' standalone output and in the mcp-stderr.log as 'running on stdio', so the processes are healthy -- they're just invisible to the agent. Fix: bump the default wait to 3.0s in both implementations (hermes_cli/mcp_startup.py and tui_gateway/entry.py). This catches npx cold starts while still bounding the worst case: a dead/never-resolving server still gets cut off at 3.0s, so the startup-hang protection that the original 0.75s default was guarding against is preserved. Add regression tests that pin the default to >= 2.0s in both test files so future refactors can't silently regress this.
Collaborator
1 task
Contributor
|
Thanks for documenting the MCP discovery race. This is now implemented on current
This is an automated hermes-sweeper review. |
This was referenced Aug 3, 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.
What
Bump the default
wait_for_mcp_discoverytimeout from 0.75s to 3.0s in both implementations (hermes_cli/mcp_startup.pyandtui_gateway/entry.py). Add regression tests in both test files.Why
The agent snapshots its tool list once at build time and never re-reads it. npx-driven MCP servers (
npx -y @griches/apple-mail-mcpand similar) typically take 2-4s to install and spawn on first launch. The previous 0.75s default was a race: any slow-but-reachable server that finished connecting after 0.75s was silently dropped from the agent's tool list for the entire session, even though the process was alive and healthy.Reproduction
config.yaml:hermes mcp test apple-contacts→ shows 11 tools. Healthy.hermes chat -q "call mcp_apple_contacts_list_groups"→ "that tool isn't available in my current toolset".~/.hermes/logs/mcp-stderr.logshows all four servers reporting "running on stdio". The processes are alive, but only the mail server is in the agent's tool list. The other three are invisible.The fix: switch to local node paths in the config (works around the bug), or land this PR (fixes it for everyone).
Why 3.0s
hermes mcp testshows 0.3-3.8s startup for npx-driven servers on a warm cache. Cold cache is 2-4s.test_hung_thread_is_bounded_by_timeout) still passes against the new default — the bound is the timeout, not the value of the default.Tests
tests/tui_gateway/tests pass.tests/hermes_cli/test_mcp_startup.py+tests/tui_gateway/test_wait_for_mcp_discovery.pytests pass.Diff