Skip to content

fix(tui): start MCP discovery for websocket sessions - #38301

Closed
sweetcornna wants to merge 1 commit into
NousResearch:mainfrom
sweetcornna:codex/fix-37589-desktop-mcp-discovery
Closed

fix(tui): start MCP discovery for websocket sessions#38301
sweetcornna wants to merge 1 commit into
NousResearch:mainfrom
sweetcornna:codex/fix-37589-desktop-mcp-discovery

Conversation

@sweetcornna

@sweetcornna sweetcornna commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • start shared background MCP discovery for TUI WebSocket sessions before gateway.ready
  • make TUI agent construction wait on the shared MCP startup state instead of the stdio-only entry module state
  • reuse the same MCP startup helper from stdio TUI and WebSocket TUI paths

Root cause

The stdio TUI path started MCP discovery inside tui_gateway.entry.main(), but Desktop/dashboard WebSocket sessions enter through tui_gateway.ws.handle_ws() and never execute that startup path. _make_agent() also waited on tui_gateway.entry.wait_for_mcp_discovery(), so WebSocket-created agents had no discovery thread to wait for before snapshotting tools. Manual /reload-mcp worked because it explicitly re-ran discovery and refreshed the session's tool list.

Scope

This addresses the Desktop/WebSocket startup-discovery half of #37589 and the duplicate report #38271. It intentionally does not include the separate uvx/GUI PATH fallback from #37589; that should be a smaller follow-up if still needed.

Validation

  • .venv\\Scripts\\python.exe -m pytest tests/tui_gateway/test_mcp_discovery_startup.py tests/tui_gateway/test_wait_for_mcp_discovery.py tests/test_tui_gateway_server.py::test_make_agent_waits_for_shared_mcp_discovery_before_tool_snapshot tests/hermes_cli/test_mcp_startup.py -q --timeout-method=thread -> 10 passed
  • .venv\\Scripts\\python.exe -m ruff check tui_gateway/entry.py tui_gateway/server.py tui_gateway/ws.py tests/tui_gateway/test_mcp_discovery_startup.py tests/tui_gateway/test_wait_for_mcp_discovery.py tests/test_tui_gateway_server.py -> All checks passed!
  • .venv\\Scripts\\python.exe -m py_compile tui_gateway/entry.py tui_gateway/server.py tui_gateway/ws.py hermes_cli/mcp_startup.py -> passed
  • git diff --check -> passed

Addresses #37589
Addresses #38271

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tui Terminal UI (ui-tui/ + tui_gateway/) tool/mcp MCP client and OAuth labels Jun 3, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #54161 (commit 5c2c85c on main) — your handle_ws discovery fix was cherry-picked with your authorship preserved in git log. You were the earliest of the cluster to spot that the WS sidecar (tui_gateway/ws.py) never starts MCP discovery, so the desktop/dashboard agent snapshots an MCP-less tool list. The rest of this PR (migrating the discovery thread slot from entry.pyhermes_cli/mcp_startup.py) had already landed on main, so only the ws.py start call remained relevant. Thanks!

#54161

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

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists 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.

3 participants