The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): /reload-mcp reloads in the gateway (reload.mcp), not on the CLI's stand-in agent
Teknium4741cffe2746
diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.pyindex 42ea3d90753..4e87791a148 100644--- a/hermes_cli/cli_info_mixin.py+++ b/hermes_cli/cli_info_mixin.py@@ -910,9 +910,33 @@ class CLIInfoMixin:with self._busy_command(self._slow_command_status(cmd_original)):self._reload_mcp()+ def _reload_gateway_mcp(self, connection):+ """``/reload-mcp`` on the shared gateway: the gateway owns the MCP servers and the session's+ agent, so it reconciles them with config and refreshes its agents (``reload.mcp``); main's+ "Agent updated" line then counts the tools the gateway session now loads."""+ from hermes_cli.gateway_client import GatewayClientError+ if not self._command_running:+ print(t("cli.reload_mcp.reloading"))+ try:+ result = connection.call("reload.mcp", session_id=self.session_id, confirm=True)+ snapshot = connection.call("session.resume", session_id=self.session_id) or {}+ except GatewayClientError as e:+ print(f" {t('gateway.reload_mcp.failed', error=str(e))}")+ return+ print(f" {result.get('message') or ''}".rstrip())+ connection.state(self.session_id).adopt_snapshot(snapshot)+ info = snapshot.get("info") or {}+ count = info.get("tool_count")+ if not isinstance(count, int):+ count = sum(len(names or []) for names in (info.get("tools") or {}).values())+ print(f" {t('cli.reload_mcp.agent_updated', count=str(count))}")+def _reload_mcp(self):"""Reload MCP servers: disconnect all, re-read config.yaml, reconnect, then refresh theagent's tool list so the model sees the updated tools on the next turn."""+ from hermes_cli.gateway_side import connection_for+ if (connection := connection_for(self)) is not None:+ return self._reload_gateway_mcp(connection)try:from tools.mcp_tool_lifecycle import shutdown_mcp_serversfrom tools.mcp_tool_discovery import discover_mcp_toolsdiff --git a/tests/hermes_cli/test_gateway_reload_mcp.py b/tests/hermes_cli/test_gateway_reload_mcp.pynew file mode 100644index 00000000000..b7d3e17468a--- /dev/null+++ b/tests/hermes_cli/test_gateway_reload_mcp.py@@ -0,0 +1,39 @@+"""/reload-mcp on the shared gateway: the gateway reconciles its MCP servers and refreshes its+agents (``reload.mcp``); the CLI never touches its GatewayAgent stand-in's tools."""+import asyncio+from contextlib import asynccontextmanager++from cli import HermesCLI+from hermes_cli.gateway_connection import GatewayConnection+++class _Client:+ def __init__(self):+ self.events = asyncio.Queue()+ self.calls = []++ async def rpc(self, method, *, _timeout=None, **params):+ self.calls.append((method, params))+ if method == "reload.mcp":+ return {"status": "reloaded", "message": "MCP servers reconciled (no server changes)"}+ return {"revision": 2, "execution_generation": 1, "messages": [], "info": {"tool_count": 20}}+++def test_reload_mcp_runs_on_the_gateway(capsys):+ client = _Client()++ @asynccontextmanager+ async def connect():+ yield client+ conn = GatewayConnection(connect=connect)+ conn.start(5)+ cli = HermesCLI.__new__(HermesCLI)+ cli.session_id = "local-mcp"+ cli._command_running = False+ try:+ cli._reload_gateway_mcp(conn)+ finally:+ conn.close()+ assert client.calls[0] == ("reload.mcp", {"session_id": "local-mcp", "confirm": True})+ out = capsys.readouterr().out+ assert "20 tool(s) available" in out and "MCP reload failed" not in out, out