fix: MCP toolset resolution for runtime and config (#3252)

Gateway sessions had their own inline toolset resolution that only read
platform_toolsets from config, which never includes MCP server names.
MCP tools were discovered and registered but invisible to the model.

- Replace duplicated gateway toolset resolution in _run_agent() and
  _run_background_task() with calls to the shared _get_platform_tools()
- Extend _get_platform_tools() to include globally enabled MCP servers
  at runtime (include_default_mcp_servers=True), while config-editing
  flows use include_default_mcp_servers=False to avoid persisting
  implicit MCP defaults into platform_toolsets
- Add homeassistant to PLATFORMS dict (was missing, caused KeyError)
- Fix CLI entry point to use _get_platform_tools() as well, so MCP
  tools are visible in CLI mode too
- Remove redundant platform_key reassignment in _run_background_task

Co-authored-by: kshitijk4poor <kshitijk4poor@users.noreply.github.com>
This commit is contained in:
Teknium 2026-03-26 13:39:41 -07:00 committed by GitHub
parent 2c719f0701
commit 62f8aa9b03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 262 additions and 132 deletions

View file

@ -134,6 +134,23 @@ class TestToolsMixedTargets:
assert "web" not in saved["platform_toolsets"]["cli"]
assert "create_issue" in saved["mcp_servers"]["github"]["tools"]["exclude"]
def test_builtin_toggle_does_not_persist_implicit_mcp_defaults(self):
config = {
"platform_toolsets": {"cli": ["web", "memory"]},
"mcp_servers": {"exa": {"url": "https://mcp.exa.ai/mcp"}},
}
with patch("hermes_cli.tools_config.load_config", return_value=config), \
patch("hermes_cli.tools_config.save_config") as mock_save:
tools_disable_enable_command(Namespace(
tools_action="disable",
names=["web"],
platform="cli",
))
saved = mock_save.call_args[0][0]
assert "web" not in saved["platform_toolsets"]["cli"]
assert "memory" in saved["platform_toolsets"]["cli"]
assert "exa" not in saved["platform_toolsets"]["cli"]
# ── List output ──────────────────────────────────────────────────────────────