The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(mcp): propagate an extended connect_timeout into config for OAuth probes
chelsealongd968db3c4b9f
diff --git a/hermes_cli/mcp_config.py b/hermes_cli/mcp_config.pyindex 2216a45bd02..d5955cb708a 100644--- a/hermes_cli/mcp_config.py+++ b/hermes_cli/mcp_config.py@@ -434,6 +434,13 @@ def _probe_single_server(connect_timeout = max(1.0, float(config.get("connect_timeout", 30)))except (TypeError, ValueError):connect_timeout = 30.0+ # Deep transport code (tools/mcp_tool_transport.py::_negotiate_session) reads its OWN+ # session.initialize() bound straight off config["connect_timeout"], independent of the+ # `connect_timeout` param above. Callers that extend the param to give a user time to finish+ # an OAuth browser flow (e.g. `hermes mcp login`'s 315s) left that inner bound at the+ # (unrelated) 60s default, so the still-pending OAuth callback wait got cancelled mid-flow —+ # surfacing as a retry that re-opens a second authorization against the same callback port.+ config["connect_timeout"] = connect_timeout_ensure_mcp_loop()tools_found: List[Tuple[str, str]] = []diff --git a/tests/hermes_cli/test_mcp_config.py b/tests/hermes_cli/test_mcp_config.pyindex 3a291d849d9..2f868e50789 100644--- a/tests/hermes_cli/test_mcp_config.py+++ b/tests/hermes_cli/test_mcp_config.py@@ -562,6 +562,34 @@ class TestProbeEnvResolution:assert tools == [("do_thing", "a tool")]assert seen["config"]["headers"]["Authorization"] == "Bearer jwt-token-xyz"+ def test_probe_propagates_explicit_connect_timeout_to_config(self, monkeypatch):+ """An explicit `connect_timeout=` override (e.g. `hermes mcp login`'s 315s, extended so a+ user has time to finish an OAuth browser flow) must reach `config["connect_timeout"]` —+ that's what tools/mcp_tool_transport.py::_negotiate_session bounds session.initialize()+ with. Left stale at its unrelated 60s default, the still-pending OAuth callback wait gets+ cancelled mid-flow well before the caller's intended deadline."""+ import hermes_cli.mcp_config as mc++ seen = {}++ class _FakeServer:+ _tools = []++ async def shutdown(self):+ return None++ async def _fake_connect(name, config):+ seen["config"] = config+ return _FakeServer()++ monkeypatch.setattr("tools.mcp_tool_discovery._connect_server", _fake_connect)++ mc._probe_single_server(+ "travelermd", {"url": "https://mcp.traveler.md/mcp", "auth": "oauth"}, connect_timeout=315.0+ )++ assert seen["config"]["connect_timeout"] == 315.0+class TestProbeCapabilityGating:"""The ``details`` probe must not fire prompts/list or resources/list at