fix(dashboard): avoid eager MCP discovery at startup - #60602
Conversation
Competing fix for #60572 (dashboard over-spawns MCP servers). Two OPEN PRs, different mechanisms:
Related, not duplicate. Flagging for a maintainer to pick the preferred approach. |
|
Thanks for the focused fix. The premise remains present on current main: The PR's deletion therefore removes the startup-side duplicate without removing MCP discovery for actual dashboard or desktop chat sessions. The updated dashboard regression is aligned with that contract. Automated hermes-sweeper review. |
cffb94c to
ede7136
Compare
|
Rebased onto current main and revalidated the Dashboard/WebSocket MCP lifecycle. I also updated the stale lifecycle documentation to reflect that discovery is now initiated by the chat WebSocket rather than Dashboard startup.
Ready for review. |
What does this PR do?
Stops
hermes dashboard/hermes servefrom starting MCP discovery eagerly during process startup. MCP discovery remains available through the real Desktop/Dashboard chat path and begins lazily when/api/wsaccepts a connection.This avoids launching configured MCP server processes when a user only opens the Dashboard for non-chat UI, while preserving MCP tools for actual Dashboard and Desktop conversations.
Related Issue
Fixes #60572.
Type of Change
Root Cause and Intent
Dashboard-level discovery was added before the WebSocket sidecar had its own startup hook. Current main now has both paths:
cmd_dashboard()startsdashboard-mcp-discoveryimmediately.tui_gateway.ws.handle_ws()starts the shared, idempotent discovery after a real chat WebSocket is accepted and beforegateway.ready.The second path is the correct lifecycle boundary.
_make_agent()already performs a bounded wait before taking its first tool snapshot, and the existing late-refresh path handles slow MCP servers before the first turn. Removing the process-start call therefore avoids eager work without removing MCP from Desktop or Dashboard chat.The shared guard is process-local, so it prevents two discovery threads inside one Dashboard process but cannot prevent a separate gateway process and an otherwise-idle Dashboard process from each launching their own MCP servers. Deferring Dashboard discovery until chat is actually used addresses that case without disabling the chat feature.
Changes Made
start_background_mcp_discovery()fromcmd_dashboard().--open-profile./api/wsregression that starts discovery after WebSocket acceptance.mcp_startup.pylifecycle documentation so it no longer listshermes dashboardas a direct startup caller.How to Test
Validation after rebasing onto current
main(659d1123c):git diff --check: clean.mainproduces the expected failure becausecmd_dashboard()callsdashboard-mcp-discovery; the rebased fix removes that call.Behavior Contract
Risk Assessment
Low. The change removes one obsolete caller and retains the tested WebSocket caller, bounded agent wait, late refresh, and process-wide idempotence. No tool schema or mid-conversation toolset changes are introduced.