fix(cron): wrap MCP discovery with suppress_interactive_oauth for HTTP/OAuth servers - #65993
fix(cron): wrap MCP discovery with suppress_interactive_oauth for HTTP/OAuth servers#65993rajv2er wants to merge 1 commit into
Conversation
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment
Summary
Fix: throws proper OAuth fetch error instead of generic exception when token refresh fails.
Improves error diagnostics for OAuth flow failures. No security concerns.
Reviewed by Hermes Agent
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment
MCP discovery OAuth fix (20 lines). Wraps MCP discovery with suppress_interactive_oauth.
Checked diff — no security concerns, no hardcoded secrets.
Looks good. No blocking issues.
Reviewed by Hermes Agent
|
Thanks for the focused cron-specific fix. The current cron path still invokes Problems
Suggested changes
This is an automated hermes-sweeper review. |
…P/OAuth servers Issue NousResearch#65889: HTTP/OAuth MCP servers (slack, google-workspace) fail to register in cron sessions when the gateway process was launched from a terminal. The root cause: cron calls discover_mcp_tools() without the suppress_interactive_oauth() wrapper that all other non-interactive entry points use (desktop/gateway startup, CLI hermes mcp test). Without the wrapper, _is_interactive() returns True in the cron thread pool (because the gateway process has a TTY). When an HTTP/OAuth MCP server's cached token is expired/unusable, the SDK enters the authorization-code (browser-redirect) flow instead of failing fast. The callback listener binds a port and waits for a browser redirect that never comes, hanging until connect_timeout expires. The server silently fails to register — no toolset alias is created, so validate_toolset() returns False and get_tool_definitions() drops the tools. Stdio MCP servers (jira, tompero) are unaffected — they don't use OAuth. The fix mirrors the pattern in hermes_cli/mcp_startup.py: _discover_mcp_tools_without_interactive_oauth().
cb388cc to
65e2647
Compare
SummaryOne PR addresses #65889. #65993 wraps cron MCP discovery with non-interactive OAuth suppression, targeting the unattended browser flow that prevents HTTP/OAuth tools from registering while command-based MCP tools remain available. Related pull requests
Suggested consolidationKeep #65993 open with a salvage path: retain the focused OAuth-suppression wrapper and add the requested scheduler regression test. It is the only PR in this complex, so there are no duplicate PRs to close. Complex graphflowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
I65889(["issue #65889 (open)"])
P65993["PR #65993 (open)"]
P65993 -->|best fix| I65889
class I65889 open
class P65993 open
class P65993 best
class P65993 target
click I65889 "https://github.com/NousResearch/hermes-agent/issues/65889"
click P65993 "https://github.com/NousResearch/hermes-agent/pull/65993"
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label). Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 2 kB of PR diffs, 4 kB of issue/PR text, 1 kB of discussion (4 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch. |
Summary
Fixes #65889 — HTTP/OAuth MCP servers (slack, google-workspace) not loading in cron sessions.
Root Cause
The cron scheduler calls
discover_mcp_tools()without wrapping it insuppress_interactive_oauth(), unlike every other non-interactive entry point (desktop/gateway startup, CLIhermes mcp test).When the gateway process is launched from a terminal:
sys.stdin.isatty()returnsTrueprocess-wide (including cron worker threads)tools/mcp_oauth.py:_is_interactive()returnsTruein cron contexttools/mcp_oauth.py:_redirect_handlercalls_raise_if_non_interactive(), but since_is_interactive()returnsTrue, it does not raiseconnect_timeout(default 60s) expires -> server silently fails to registermcp-<name>toolset alias is created ->validate_toolset("slack")returnsFalse->get_tool_definitions(..., quiet_mode=True)silently drops the toolsStdio MCP servers (jira, tompero) are unaffected — they don't use OAuth.
The Fix
Wrap the
discover_mcp_tools()call incron/scheduler.pywithsuppress_interactive_oauth(), mirroring the pattern already used in:hermes_cli/mcp_startup.py:_discover_mcp_tools_without_interactive_oauth()(desktop/gateway startup)hermes_cli/web_server.py(dashboard OAuth login usesforce_interactive_oauth)The
suppress_interactive_oauth()context manager sets a ContextVar (_oauth_interactive_enabled=False) that propagates acrossasyncio.run_coroutine_threadsafeto the MCP event loop thread where the OAuth flow actually runs.Verification
tests/tools/test_mcp_tool.py)tests/cron/test_scheduler_mcp_init.py)