Skip to content

fix(mcp): respect HERMES_MCP_DISCOVERY_TIMEOUT env var for slow-connecting servers - #37393

Closed
arimu1 wants to merge 1 commit into
NousResearch:mainfrom
arimu1:fix/mcp-discovery-timeout-env-var
Closed

fix(mcp): respect HERMES_MCP_DISCOVERY_TIMEOUT env var for slow-connecting servers#37393
arimu1 wants to merge 1 commit into
NousResearch:mainfrom
arimu1:fix/mcp-discovery-timeout-env-var

Conversation

@arimu1

@arimu1 arimu1 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • hermes -z (headless oneshot) snapshots its MCP tool list once after only 0.75 s, so any MCP server with a real process startup (Docker, stdio) is silently absent for the entire session — no error, no warning.
  • This PR adds a HERMES_MCP_DISCOVERY_TIMEOUT environment variable that overrides the discovery wait, giving users with slow servers a zero-config-schema escape hatch.

Root Cause

wait_for_mcp_discovery(timeout: float = 0.75) in hermes_cli/mcp_startup.py is called with no argument at both cli.py:793 and cli.py:4937. The 0.75 s default predates process-backed MCP servers. In headless mode the tool list is snapshotted once at startup and never refreshed.

Fix

wait_for_mcp_discovery now reads HERMES_MCP_DISCOVERY_TIMEOUT (float seconds) from the environment and uses it as the effective timeout when present. The existing 0.75 s default is preserved as the fallback — no call sites change, no config schema changes.

HERMES_MCP_DISCOVERY_TIMEOUT=10 hermes -z "call my-docker-tool and summarise the result"

Test Plan

Closes #37013

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard tool/mcp MCP client and OAuth labels Jun 2, 2026
@arimu1
arimu1 force-pushed the fix/mcp-discovery-timeout-env-var branch from ae00bb1 to c701dde Compare July 11, 2026 03:06
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for isolating the slow-MCP startup case and adding focused resolver tests.

This automated hermes-sweeper review is closing this as not_planned under the env-var-for-config policy.

  • The proposed HERMES_MCP_DISCOVERY_TIMEOUT is a new user-facing, non-secret behavioral timeout override. AGENTS.md:102-105 requires behavioral settings such as timeouts to live in config.yaml, not a HERMES_* environment variable.
  • Current main already provides the supported mechanism: mcp_discovery_timeout in hermes_cli/config.py:1359-1372, resolved by hermes_cli/mcp_startup.py:53-71 for the CLI and TUI paths.
  • Current main also performs cache-safe between-turn MCP refresh in agent/turn_context.py:176-202 for servers that miss the bounded startup wait.

For a longer initial wait, configure mcp_discovery_timeout in config.yaml; no new environment-variable surface is needed.


Closed as not-planned per standing maintainer policy (env-var-for-config). This is a design-direction decision, not a code-quality judgment — see the Contribution Rubric in AGENTS.md for what the project is looking for. If you believe this policy was misapplied to your change, comment here and a maintainer will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) 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.

[Bug]: -z/headless oneshots silently drop slow-connecting MCP servers (0.75 s discovery wait too short for container/stdio-backed servers)

3 participants