The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): a saved disabled MCP server no longer enables every other one
Teknium96eae3542ea3
diff --git a/hermes_cli/tools_config.py b/hermes_cli/tools_config.pyindex bdf7c7c805e..5421d10ec2b 100644--- a/hermes_cli/tools_config.py+++ b/hermes_cli/tools_config.py@@ -685,15 +685,19 @@ def _merge_mcp_servers("""Explicit passthrough entries plus this platform's MCP servers: listed names form an allowlist, else everyglobally enabled server (when ``include_default_mcp_servers``); the ``no_mcp`` sentinel disables all."""enabled_mcp_servers = enabled_mcp_server_names(config)+ configured = config.get("mcp_servers") if isinstance(config.get("mcp_servers"), dict) else {}+ known = enabled_mcp_servers | {str(name) for name in configured}# ``mcp-<server>`` names the same server as its bare alias: either spelling selects only that server# (unless a server is literally named ``mcp-<server>``).- explicit_passthrough = {ts[4:] if ts.startswith("mcp-") and ts not in enabled_mcp_servers- and ts[4:] in enabled_mcp_servers else ts for ts in explicit_passthrough}- result = explicit_passthrough - enabled_mcp_servers+ explicit_passthrough = {ts[4:] if ts.startswith("mcp-") and ts not in known+ and ts[4:] in known else ts for ts in explicit_passthrough}+ result = explicit_passthrough - knownif "no_mcp" in toolset_names:return result - {"no_mcp"}explicit_mcp_servers = explicit_passthrough & enabled_mcp_servers- if include_default_mcp_servers and not explicit_mcp_servers:+ # A listed server that is configured but disabled is still the user's server selection: it stays+ # off, and it must not fall through to every enabled server.+ if include_default_mcp_servers and not explicit_passthrough & known:return result | enabled_mcp_serversreturn result | explicit_mcp_serversdiff --git a/tests/hermes_cli/test_tools_config.py b/tests/hermes_cli/test_tools_config.pyindex 3067b784226..e51ddee21cd 100644--- a/tests/hermes_cli/test_tools_config.py+++ b/tests/hermes_cli/test_tools_config.py@@ -387,6 +387,24 @@ def test_numeric_mcp_server_name_does_not_crash_sorted():sorted(enabled)[email protected]("listed", ["dead", "mcp-dead"])+def test_a_saved_disabled_mcp_server_does_not_enable_every_other_server(listed):+ """A disabled server in a saved list matched nothing and fell through to ALL enabled servers.+ It is still the user's explicit server selection: it stays off, and no other server is added."""+ config = {+ "platform_toolsets": {"cli": ["terminal", listed]},+ "mcp_servers": {+ "dead": {"url": "https://example.com/dead", "enabled": False},+ "live": {"url": "https://example.com/live"},+ },+ }++ enabled = _get_platform_tools(config, "cli")++ assert "terminal" in enabled+ assert not {"dead", "mcp-dead", "live"} & enabled, enabled++# ─── Imagegen Backend Picker Wiring ────────────────────────────────────────