The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Portable plugin MCP tools keep their names instead of a hash (64-char provider cap) (#119263)
Siddharth Balyan07610317671c
diff --git a/hermes_cli/plugins_loader.py b/hermes_cli/plugins_loader.pyindex a710a53e200..39656eacdae 100644--- a/hermes_cli/plugins_loader.py+++ b/hermes_cli/plugins_loader.py@@ -25,7 +25,7 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Mapping, Optional,from hermes_constants import get_hermes_home, reset_hermes_home_override, set_hermes_home_overridefrom registration_lifecycle import replacement_coordinatorfrom hermes_cli.plugins_discovery import ENTRY_POINTS_GROUP, _select_entry_point_group-from hermes_cli.plugins_manifest import PluginManifest, manifest_key, validate_config_schema+from hermes_cli.plugins_manifest import PluginManifest, manifest_key, portable_mcp_server_name, validate_config_schemafrom hermes_cli.plugins_state import _plugin_settings_entryif TYPE_CHECKING: # pragma: no cover@@ -528,9 +528,10 @@ class PluginLoaderMixin:registered: list[str] = []try:for server_name, config in package.mcp_servers.items():- internal_name = f"{manifest.skill_namespace}__{server_name}"+ internal_name = portable_mcp_server_name(lookup_key, server_name)if internal_name in self._portable_mcp_servers:- logger.warning("Agent Plugin '%s' MCP server collision: %s", lookup_key, internal_name)+ logger.warning("Agent Plugin '%s' MCP server '%s' skipped: name already taken by plugin '%s'; rename one server",+ lookup_key, internal_name, self._portable_mcp_server_plugins.get(internal_name, "?"))continueself._portable_mcp_servers[internal_name] = dict(config)self._portable_mcp_server_plugins[internal_name] = lookup_keydiff --git a/hermes_cli/plugins_manifest.py b/hermes_cli/plugins_manifest.pyindex dc49fbe6cdb..a927cc2c25f 100644--- a/hermes_cli/plugins_manifest.py+++ b/hermes_cli/plugins_manifest.py@@ -59,12 +59,27 @@ def _plugins_debug() -> bool:def _portable_skill_namespace(key: str) -> str:"""Return a readable, collision-resistant namespace for a portable plugin."""- slug = "".join(ch if ch.isascii() and (ch.isalnum() or ch in "_-") else "-" for ch in key.lower())- slug = slug.strip("-_") or "plugin"+ slug = _portable_slug(key)digest = hashlib.sha256(key.encode("utf-8")).hexdigest()[:8]return f"agent-plugin-{slug}-{digest}"+def _portable_slug(key: str) -> str:+ slug = "".join(ch if ch.isascii() and (ch.isalnum() or ch in "_-") else "-" for ch in key.lower())+ return slug.strip("-_") or "plugin"+++def portable_mcp_server_name(key: str, server: str) -> str:+ """Internal name of a portable plugin's MCP server: exactly the name its ``mcp.json`` gives it, the same+ rule a user's own ``mcp_servers`` block in config.yaml follows. The plugin's skill namespace+ (``agent-plugin-<slug>-<digest>``) is NOT prepended: it keeps plugin-data and skill names collision-free+ without coordination, but here it cost ~40 chars of every ``mcp__<server>__<tool>`` name, which providers+ cap at 64, so the tool verb was hash-clamped away. A duplicate is refused at load (native config first,+ then first-loaded plugin) with a warning naming both owners; that beats hiding it behind a digest."""+ del key # one signature for loader and card; the plugin identity is deliberately not part of the name+ return _portable_slug(server)++def _display_author(value: object) -> str:"""Normalize a manifest author value for the string PluginManifest field."""if isinstance(value, Mapping):diff --git a/tests/hermes_cli/test_plugins.py b/tests/hermes_cli/test_plugins.pyindex c577ce436b6..a78526ae5dc 100644--- a/tests/hermes_cli/test_plugins.py+++ b/tests/hermes_cli/test_plugins.py@@ -217,13 +217,17 @@ class TestPluginDiscovery:[qualified] = manager.list_plugin_skill_metadata()assert qualified["name"].endswith(":summarize")- assert set(manager.get_portable_mcp_servers()) == {- qualified["name"].split(":", 1)[0] + "__worker"- }+ # Skills keep the digest namespace (collision-free without coordination); the MCP server does+ # not: it is named what mcp.json calls it, like a config.yaml server, so ``mcp__<server>__<tool>``+ # fits the 64-char provider cap with the tool verb intact instead of being hash-clamped.+ [internal_name] = manager.get_portable_mcp_servers()+ assert internal_name == "worker"+ from tools.mcp_tool_schema import mcp_prefixed_tool_name+ wire = mcp_prefixed_tool_name(internal_name, "nvapp_client_get_driver_status")+ assert wire.endswith("__nvapp_client_get_driver_status") and len(wire) <= 64assert manager._plugins["portable.test"].enabled is Trueassert manager._plugins["native"].enabled is Trueassert manager._plugins["native"].module is not None- internal_name = next(iter(manager.get_portable_mcp_servers()))from hermes_cli.agent_plugins import liveness_forfrom hermes_platform import declaration@@ -233,6 +237,37 @@ class TestPluginDiscovery:assert declaration.lookup(internal_name) is Noneassert liveness_for(internal_name) is None+ def test_two_portable_plugins_with_the_same_server_name_do_not_both_load(self, tmp_path, monkeypatch):+ """Readable server names can clash where the old digest could not: the second plugin's server+ is skipped with a warning naming the first, and the first's config is the one served."""+ from hermes_cli.agent_plugins import MCP_SCHEMA_V1, PLUGIN_SCHEMA_V1+ from hermes_cli import plugins as plugins_mod++ home = tmp_path / ".hermes"+ # Two unrelated plugins both call their server "shared": one readable name, one owner.+ for plugin_name, command in (("alpha-tools", "python-a"), ("beta-tools", "python-b")):+ plugin = home / "plugins" / plugin_name+ plugin.mkdir(parents=True)+ (plugin / "plugin.json").write_text(json.dumps({"$schema": PLUGIN_SCHEMA_V1, "name": plugin_name}))+ (plugin / "mcp.json").write_text(json.dumps({+ "$schema": MCP_SCHEMA_V1,+ "mcpServers": {"shared": {"type": "stdio", "command": command}},+ }))+ (home / "config.yaml").write_text(+ yaml.safe_dump({"plugins": {"enabled": ["alpha-tools", "beta-tools"]}}))+ empty_bundled = tmp_path / "bundled"+ empty_bundled.mkdir()+ monkeypatch.setenv("HOME", str(tmp_path / "os-home"))+ monkeypatch.setenv("HERMES_HOME", str(home))+ monkeypatch.setattr(plugins_mod, "get_bundled_plugins_dir", lambda: empty_bundled)++ manager = PluginManager()+ manager.discover_and_load()++ servers = manager.get_portable_mcp_servers()+ assert list(servers) == ["shared"]+ assert servers["shared"]["command"] in {"python-a", "python-b"}+def test_disabled_portable_plugin_registers_nothing(self, tmp_path, monkeypatch):from hermes_cli.agent_plugins import PLUGIN_SCHEMA_V1from hermes_cli import plugins as plugins_moddiff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.pyindex e29953f10d6..6bc6b93f031 100644--- a/tui_gateway/methods_tools.py+++ b/tui_gateway/methods_tools.py@@ -1480,13 +1480,13 @@ def _plugin_server_rows(plugin_dir: Path | None, key: str, *, portable: bool) ->declared = namespace.get("servers", {})if not isinstance(declared, dict):return []- server_namespace = _tools_mod("hermes_cli.plugins_manifest")._portable_skill_namespace(key)+ server_name_for = _tools_mod("hermes_cli.plugins_manifest").portable_mcp_server_nameliveness = _tools_mod("tools.mcp_liveness")core = _tools_mod("tools.mcp_tool_common")._coreresolve_key = _tools_mod("tools.mcp_tool_scope")._resolve_server_keyrows = []for name in sorted(declared):- internal_name = f"{server_namespace}__{name}"+ internal_name = server_name_for(key, name)connection_key = resolve_key(internal_name)server = core._servers.get(connection_key)connected = server is not None and (server.session is not None or server._is_recycled_stdio())diff --git a/website/docs/developer-guide/plugins/index.md b/website/docs/developer-guide/plugins/index.mdindex 874e0666e59..812594637fd 100644--- a/website/docs/developer-guide/plugins/index.md+++ b/website/docs/developer-guide/plugins/index.md@@ -74,7 +74,13 @@ and loaded through `skills_list` plus `skill_view`. MCP commands are passed asone executable token with a separate argument list, never through a shell.Use `skills_list` to discover the full qualified skill name. Portable skillnamespaces have the deterministic form `agent-plugin-<slug>-<hash>`, derived-from the discovered plugin key so sanitized names cannot collide.+from the discovered plugin key so sanitized names cannot collide. A portable+package's MCP servers keep the names their `mcp.json` gives them, the same rule+as a user's own `mcp_servers` block, so the model-facing `mcp__<server>__<tool>`+name keeps the tool verb inside the 64-character provider cap. A duplicate server+name is a load-time conflict: a `config.yaml` server wins over a package, and the+first-loaded package wins over the next; the loser is skipped with a warning+naming both.Hermes validates `plugin.json`, Agent Skills frontmatter, fixed componentlocations, `mcp.json`, resolved paths, and symlink containment locally. It does