fix(tui): suppress MCP discovery in slash_worker to prevent duplicate serve children (#15275)#15440
Closed
Tranquil-Flow wants to merge 2 commits into
Closed
Conversation
… serve children (NousResearch#15275) The slash_worker creates a HermesCLI which imports model_tools, triggering discover_mcp_tools() at module scope. Meanwhile, the TUI server also calls MCP discovery independently. Both paths spawn ``hermes mcp serve`` child processes per session. Fix: defer the cli import in slash_worker to main() and set HERMES_MCP_DISCOVERY=0 beforehand. model_tools now checks this env var and skips MCP discovery when suppressed.
This was referenced Apr 25, 2026
Contributor
Author
|
Closing — the duplicate-MCP-child symptom can't reproduce on main: Verified by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The TUI spawns duplicate
hermes mcp servechild processes per session. Bothtui_gateway/server.py(agent creation path) andtui_gateway/slash_worker.py(slash command worker) independently bootstrap MCP tools, each triggeringdiscover_mcp_tools()and spawning its own set of MCP server processes. The slash worker only needs CLI command processing, not MCP-backed tools.Related Issue
Fixes #15275
Type of Change
Changes Made
tui_gateway/slash_worker.py: SetHERMES_MCP_DISCOVERY=0unconditionally before importing/constructingHermesCLI, suppressing MCP discovery in the worker process.tui_gateway/server.py: When spawning the slash worker subprocess, explicitly setHERMES_MCP_DISCOVERY=0in the subprocess environment to prevent parent env leakage (e.g., if parent hasHERMES_MCP_DISCOVERY=1).model_tools.py: Added a guard in the MCP discovery path that checksHERMES_MCP_DISCOVERYenv var — skipsdiscover_mcp_tools()when set to"0".How to Test
Tested on macOS (Python 3.11).
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs