-
Notifications
You must be signed in to change notification settings - Fork 2
bug(mcp): OAuth server blocks agent startup and auth URL invisible in TUI #2276
Description
Problem
When an MCP server with OAuth ([mcp.servers.oauth] enabled = true) is configured, the agent startup freezes for up to 300 seconds and the user never sees the authorization URL in TUI mode.
Root Cause
Two interrelated problems in the startup sequence (src/runner.rs / src/agent_setup.rs):
-
Blocking startup:
mcp_manager.connect_all().awaitis called insidebuild_tool_setup(), which runs viatokio::join!before the TUI is created (TUI is created at line 644, after the join completes). The OAuth phase callsawait_oauth_callback(listener, 300s, ...)which blocks the entire initialization for up to 5 minutes while waiting for a browser callback that will never arrive. -
Auth URL never shown: The OAuth auth URL is sent via
status_tx(as a status message) duringconnect_all(), but the TUI event loop has not started yet at that point. By the time TUI renders, the OAuth callback has already timed out. The URL is never displayed to the user. -
No browser open: There is no
open::that()or equivalent to auto-launch the browser with the auth URL.
Reproduction
Configure any HTTP MCP server with OAuth (e.g. todoist):
[[mcp.servers]]
id = "todoist"
url = "https://ai.todoist.net/mcp"
[mcp.servers.oauth]
enabled = true
token_storage = "vault"
callback_port = 18766Run cargo run --features full -- --tui. Agent startup freezes for 300s, then launches without todoist tools.
Expected Behavior
- OAuth flow must not block agent startup
- The auth URL should be prominently displayed in the TUI (e.g. a dedicated OAuth authorization dialog/prompt)
- Ideally, the browser is auto-opened with the auth URL
Suggested Fix Direction
- Move OAuth connection out of the startup critical path — connect OAuth servers after the TUI event loop has started
- OR make OAuth startup non-blocking: skip OAuth servers on first launch, connect them lazily via a background task after TUI is ready
- Add a TUI dialog or notification that shows the OAuth URL with a "Press Enter to open in browser" prompt
- Use
open::that()crate to auto-launch the browser
Files
src/agent_setup.rs:338-344—create_mcp_manager_with_vault+connect_all()src/runner.rs:552-562—tokio::join!that blocks startupsrc/runner.rs:642-644— TUI created AFTER tool setup completescrates/zeph-mcp/src/manager.rs:396—await_oauth_callback300s timeout