diff --git a/hermes_cli/mcp_config.py b/hermes_cli/mcp_config.py index 6c6db1bdc83..9997b1edd1c 100644 --- a/hermes_cli/mcp_config.py +++ b/hermes_cli/mcp_config.py @@ -786,14 +786,16 @@ def _reauth_oauth_server(name: str, server_config: dict) -> bool: # Probe triggers the OAuth flow (browser redirect + callback capture). # Honor the server's configured connect_timeout so a human has enough # time to complete the browser sign-in; the 30s default is too tight for - # an interactive OAuth round-trip. Give at least 180s for the login path. + # an interactive OAuth round-trip. Floor at 315s — the OAuth callback + # window (300s in mcp_oauth) plus headroom — matching the GUI re-auth + # path in web_server.py so CLI and dashboard behave identically. try: _login_connect_timeout = server_config.get("connect_timeout") try: _login_connect_timeout = float(_login_connect_timeout) except (TypeError, ValueError): _login_connect_timeout = 0.0 - _login_connect_timeout = max(_login_connect_timeout, 180.0) + _login_connect_timeout = max(_login_connect_timeout, 315.0) tools = _probe_single_server( name, server_config, connect_timeout=_login_connect_timeout ) diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py index 45e5d7b8496..564c9d00f41 100644 --- a/hermes_cli/web_server.py +++ b/hermes_cli/web_server.py @@ -9152,8 +9152,15 @@ async def auth_mcp_server(name: str, profile: Optional[str] = None): # The default 30s connect timeout would kill the flow while the # user is still on the consent screen — give the browser # round-trip the full callback window (300s in mcp_oauth) plus - # headroom so the connect wrapper can't pre-empt it. - tools = _probe_single_server(name, cfg, connect_timeout=315) + # headroom so the connect wrapper can't pre-empt it. Honor a + # larger configured connect_timeout when the user set one. + try: + _cfg_timeout = float(cfg.get("connect_timeout", 0)) + except (TypeError, ValueError): + _cfg_timeout = 0.0 + tools = _probe_single_server( + name, cfg, connect_timeout=max(_cfg_timeout, 315) + ) except Exception: storage.restore(backup) raise