fix(tui-gateway): scope MCP discovery to the selected profile (Desktop/dashboard) - #72219
Merged
Merged
Conversation
…y owner; restore stdio startup + WSTransport tests Follow-up to @LionGateOS's #72135 salvage: - Route ensure_mcp_discovery_started through hermes_cli.mcp_startup's shared owner instead of a hand-rolled bare thread, keeping the start lock, retry-after-zero-connected allowance, and interactive-OAuth suppression. The shared owner now captures the caller's context-local HERMES_HOME override and re-installs it inside the discovery thread, so discovery reads the selected profile's mcp_servers (#67605). - Restore stdio TUI startup discovery in main() and the _mcp_discovery_enabled retry gate in wait_for_mcp_discovery, both dropped by the original branch. - Restore the 3 WSTransport regression tests (send serialization, cross-batch ordering, drained-token ordering) deleted by the PR. - Harden the profile-scoped discovery test against sibling-state leaks.
Contributor
૮ >ﻌ< ა ci reviewran on d55feae all good! |
Contributor
|
Thanks for the follow-up and for carrying this forward. I'm glad the
profile-scoped discovery issue was validated. The split between the
contributor changes and the shared discovery owner makes sense. Thanks for
preserving the original fix and hardening the remaining startup paths.
…On Sun, Jul 26, 2026 at 5:04 PM Teknium ***@***.***> wrote:
Summary
MCP tools now load for the *selected* profile in the Desktop app /
dashboard chat, instead of silently discovering the launch profile's (often
empty) mcp_servers. Fixes the MCP half of #67605
<#67605>; salvage of
#72135 <#72135> by
@LionGateOS <https://github.com/LionGateOS> with follow-up hardening.
Root cause: the WS sidecar started one process-global discovery thread
gated on the *process* home's config, and the ContextVar profile override
(set_hermes_home_override) never propagated into the bare discovery
thread — so a dashboard launched under a profile without mcp_servers
served zero MCP tools to every profile.
Changes
- tui_gateway/ws.py: WS transport no longer owns MCP discovery startup
(contributor).
- tui_gateway/server.py: _start_agent_build starts discovery AFTER
binding the session profile's HERMES_HOME; verification.status gains
@_profile_scoped (contributor).
- tui_gateway/entry.py: ensure_mcp_discovery_started() routes through
the shared owner in hermes_cli.mcp_startup (keeps start lock,
retry-after-zero-connected, OAuth suppression); stdio TUI main()
startup discovery and the _mcp_discovery_enabled retry gate are
restored (follow-up).
- hermes_cli/mcp_startup.py: the shared owner captures the caller's
context-local HERMES_HOME override and re-installs it inside the
discovery thread (follow-up).
- Tests: contributor's profile-scoped regression tests adapted to the
shared-owner path; 3 WSTransport regression tests the original branch
deleted are restored.
Known limitation (documented in-code): MCP registration is process-global,
so the first profile to build an agent wins the discovery slot. Full
per-profile registries stay tracked in #67605
<#67605>, which
remains open for the secrets/${VAR}/MoA halves.
Validation
Check Result
tests/test_tui_gateway_server.py (466) pass
tests/test_tui_gateway_ws.py, tests/hermes_cli/test_mcp_startup.py,
tests/tui_gateway/ (983 total) pass
Sabotage run (fix reverted) regression test fails as expected
E2E (real imports, temp HERMES_HOME, launch profile without / selected
profile with mcp_servers) 5/5 scenarios pass, incl.
caller-resets-override race and no-override CLI path unchanged Infographic
[image: Profile-scoped MCP discovery]
<https://camo.githubusercontent.com/9fe845b7202c43a1c408b6643d174f82db7d5c8e4006488b3ef79241d11c9987/68747470733a2f2f7633622e66616c2e6d656469612f66696c65732f622f30616133643839392f4c41425a565042733241744e6949446a6b34566c6a5f746535504441326a2e706e67>
------------------------------
You can view, comment on, or merge this pull request online at:
#72219
Commit Summary
- c24117f
<c24117f>
fix(tui-gateway): start MCP discovery for websocket sessions
- 5fa67c9
<5fa67c9>
fix(tui-gateway): scope MCP discovery to active profile
- 41ae05e
<41ae05e>
fix(tui-gateway): scope verification and MCP discovery to active profile
- d55feae
<d55feae>
fix(mcp): propagate profile HERMES_HOME override into shared discovery
owner; restore stdio startup + WSTransport tests
File Changes
(6 files <https://github.com/NousResearch/hermes-agent/pull/72219/files>)
- *M* hermes_cli/mcp_startup.py
<https://github.com/NousResearch/hermes-agent/pull/72219/files#diff-a1110ba7c2e42c71f999a78dcc0e4b5dec423f5f8750c3613ba74c2b3c90e679>
(28)
- *M* tests/test_tui_gateway_server.py
<https://github.com/NousResearch/hermes-agent/pull/72219/files#diff-ab3f7d42a3fbc9cacb07ddf894128d56247d26c071340ad6db9c7fc9bd0bad54>
(107)
- *M* tests/test_tui_gateway_ws.py
<https://github.com/NousResearch/hermes-agent/pull/72219/files#diff-2d447a046f3f86e6c2a75365d2affcb574c2a3fd1f8de10111b14f1e879c7866>
(46)
- *M* tui_gateway/entry.py
<https://github.com/NousResearch/hermes-agent/pull/72219/files#diff-59bc9d3d32cbe366a25d71877427e2cff38203a00fd57547d6566bacb922a5f6>
(154)
- *M* tui_gateway/server.py
<https://github.com/NousResearch/hermes-agent/pull/72219/files#diff-98eb2a99172373f82cbda4412b9f5d108a73acd5d0f46fb642009b9f331118c0>
(9)
- *M* tui_gateway/ws.py
<https://github.com/NousResearch/hermes-agent/pull/72219/files#diff-43a46540c4a2a22a03debc1a0c735bb68577ef84d5055f0efb8b11a06512e2bc>
(16)
Patch Links:
- https://github.com/NousResearch/hermes-agent/pull/72219.patch
- https://github.com/NousResearch/hermes-agent/pull/72219.diff
—
Reply to this email directly, view it on GitHub
<#72219?email_source=notifications&email_token=AXOQMVQH7G7WT76VJOOEUZT5GZW5XA5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF42DCMZXG44DMOJUG2THEZLBONXW5J3NMVXHI2LPN2SWK5TFNZ2KYZTPN52GK4S7MNWGSY3L>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXOQMVVJP4GCMUQYRMCDTIL5GZW5XAVCNFSNUABGKJSXA33TNF2G64TZHMYTAMRUGU2TIMRWG45US43TOVSTWNBZHAZDKMRQHA3TNILWAI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Contributor
|
Thank you for reviewing and merging this. I appreciate the help getting the
profile-scoped MCP discovery flow into main. Glad the issue is resolved.
…On Sun, Jul 26, 2026 at 5:14 PM Teknium ***@***.***> wrote:
Merged #72219 <#72219>
into main.
—
Reply to this email directly, view it on GitHub
<#72219?email_source=notifications&email_token=AXOQMVW2NUWFKMC4DYY6SPL5GZYDBA5CNFSNUABQM5UWIORPF5TWS5BNNB2WEL2JONZXKZKFOZSW45CON52GSZTJMNQXI2LPNYXTEOBVGA3TONBZGMYTJJTSMVQXG33OU5WWK3TUNFXW5JLFOZSW45FMMZXW65DFOJPWG3DJMNVQ#event-28507749314>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXOQMVXR5VN7EXNVH7J3MZD5GZYDBAVCNFSNUABGKJSXA33TNF2G64TZHMYTAMRUGU2TIMRWG45US43TOVSTWNBZHAZDKMRQHA3TNILWAI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Contributor
|
Thanks for the review and for carrying this through. I'm glad the profile-scoped MCP discovery fix made it into main. I appreciate preserving the original work and the additional hardening around the shared discovery owner, profile HERMES_HOME propagation, and regression coverage. I'll keep an eye on the remaining #67605 items as they progress. |
This was referenced Jul 26, 2026
Open
19 tasks
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.
Summary
MCP tools now load for the selected profile in the Desktop app / dashboard chat, instead of silently discovering the launch profile's (often empty)
mcp_servers. Fixes the MCP half of #67605; salvage of #72135 by @LionGateOS with follow-up hardening.Root cause: the WS sidecar started one process-global discovery thread gated on the process home's config, and the ContextVar profile override (
set_hermes_home_override) never propagated into the bare discovery thread — so a dashboard launched under a profile withoutmcp_serversserved zero MCP tools to every profile.Changes
tui_gateway/ws.py: WS transport no longer owns MCP discovery startup (contributor).tui_gateway/server.py:_start_agent_buildstarts discovery AFTER binding the session profile'sHERMES_HOME;verification.statusgains@_profile_scoped(contributor).tui_gateway/entry.py:ensure_mcp_discovery_started()routes through the shared owner inhermes_cli.mcp_startup(keeps start lock, retry-after-zero-connected, OAuth suppression); stdio TUImain()startup discovery and the_mcp_discovery_enabledretry gate are restored (follow-up).hermes_cli/mcp_startup.py: the shared owner captures the caller's context-localHERMES_HOMEoverride and re-installs it inside the discovery thread (follow-up).Known limitation (documented in-code): MCP registration is process-global, so the first profile to build an agent wins the discovery slot. Full per-profile registries stay tracked in #67605, which remains open for the secrets/
${VAR}/MoA halves.Validation
tests/test_tui_gateway_server.py(466)tests/test_tui_gateway_ws.py,tests/hermes_cli/test_mcp_startup.py,tests/tui_gateway/(983 total)mcp_servers)Infographic