Skip to content

The agent that grows with you

feat(plugins): a portable package can ask Hermes to gate its MCP server

Teknium1e347ccf2a61
diff --git a/hermes_cli/agent_plugins.py b/hermes_cli/agent_plugins.py
index 88f2f9bf0c2..769f740ae6e 100644
--- a/hermes_cli/agent_plugins.py
+++ b/hermes_cli/agent_plugins.py
@@ -104,9 +104,11 @@ def _server_declarations(
raise AgentPluginError(f"server declaration '{name}' must be an object")
if "liveness" in raw and "app" not in raw and "requires" not in raw:
raise AgentPluginError(f"server declaration '{name}' has liveness without app or requires")
- unknown = set(raw) - {"app", "requires", "liveness"}
+ unknown = set(raw) - {"app", "requires", "liveness", "trust"}
if unknown:
raise AgentPluginError(f"server declaration '{name}' has unknown keys {sorted(unknown)}")
+ if set(raw) == {"trust"}:
+ continue # trust only (see _server_trust): no application to declare
try:
declaration = parse_declaration(
name, raw.get("app"), raw.get("requires"),
@@ -124,6 +126,27 @@ def _server_declarations(
return declarations
+def _server_trust(manifest: Mapping[str, Any], mcp_servers: Mapping[str, Dict[str, Any]]) -> Dict[str, str]:
+ """Servers the package asks Hermes to gate: ``extensions.com.nousresearch.hermes.servers.<name>.trust``.
+
+ The package may only narrow access. ``untrusted`` makes every write-capable call to that server
+ ask the user first (the native ``trust: untrusted`` gate); ``full`` is the default and so changes
+ nothing. A package can never widen a server the user configured: a ``config.yaml`` server with
+ the same name replaces the package's entry, trust included.
+ """
+ raw_servers = manifest.get("extensions", {}).get(_HERMES_EXTENSION, {}).get("servers", {})
+ trust: Dict[str, str] = {}
+ for name, raw in (raw_servers.items() if isinstance(raw_servers, dict) else ()):
+ if not isinstance(raw, dict) or "trust" not in raw or name not in mcp_servers:
+ continue # shape errors are raised by _server_declarations
+ value = raw["trust"]
+ if value not in ("full", "untrusted"):
+ raise AgentPluginError(f"server declaration '{name}' trust must be 'untrusted' or 'full', not {value!r}")
+ if value == "untrusted":
+ trust[name] = value
+ return trust
+
+
def _inside(path: Path, root: Path) -> bool:
try:
return path.resolve(strict=False).is_relative_to(root.resolve(strict=True))
@@ -426,6 +449,8 @@ def load_agent_plugin(plugin_root: Path, data_root: Path) -> AgentPluginPackage:
resolved_data = Path(data_root).resolve(strict=False)
skills = _discover_skills(root, diagnostics)
mcp_servers = _discover_mcp(root, resolved_data, diagnostics)
+ for name, tier in _server_trust(manifest, mcp_servers).items():
+ mcp_servers[name] = {**mcp_servers[name], "trust": tier}
return AgentPluginPackage(
name=manifest["name"], version=manifest.get("version", ""),
description=manifest.get("description", ""), root=root, data_root=resolved_data,
diff --git a/hermes_cli/plugin_validate.py b/hermes_cli/plugin_validate.py
index 3bd52fcfadf..defad76c77f 100644
--- a/hermes_cli/plugin_validate.py
+++ b/hermes_cli/plugin_validate.py
@@ -643,6 +643,10 @@ def _validate_portable_plugin(report: ValidationReport, plugin_dir: Path) -> Val
bool(name),
"name present" if name else "plugin.json missing required 'name'",
)
+ for server_name, config in package.mcp_servers.items():
+ if config.get("trust") == "untrusted":
+ report.add(f"server trust: {server_name}", True,
+ "untrusted (Hermes asks before every write-capable tool call)")
for server_name, server_decl in package.server_declarations.items():
result = availability(server_decl.declaration)
detail = result.state
diff --git a/tests/e2e/core/mcp_plugins/_plugin_helpers.py b/tests/e2e/core/mcp_plugins/_plugin_helpers.py
index 80a24508e4b..934332e9c3f 100644
--- a/tests/e2e/core/mcp_plugins/_plugin_helpers.py
+++ b/tests/e2e/core/mcp_plugins/_plugin_helpers.py
@@ -32,13 +32,16 @@ def portable_stdio(log: Path, tag: str, **env: str) -> dict[str, Any]:
def write_portable_plugin(eh: E2EHome, dirname: str, servers: dict[str, dict[str, Any]], *,
- name: str | None = None, version: str = "1.0.0") -> Path:
+ name: str | None = None, version: str = "1.0.0",
+ extensions: dict[str, Any] | None = None) -> Path:
"""``<HERMES_HOME>/plugins/<dirname>/`` with ``plugin.json`` (manifest ``name``), ``mcp.json`` and an
in-root launcher that execs the fixture MCP server with this interpreter."""
root = eh.hermes_home / "plugins" / dirname
root.mkdir(parents=True, exist_ok=True)
- (root / "plugin.json").write_text(json.dumps(
- {"$schema": PLUGIN_SCHEMA, "name": name or dirname, "version": version}), encoding="utf-8")
+ manifest = {"$schema": PLUGIN_SCHEMA, "name": name or dirname, "version": version}
+ if extensions:
+ manifest["extensions"] = extensions
+ (root / "plugin.json").write_text(json.dumps(manifest), encoding="utf-8")
(root / "mcp.json").write_text(json.dumps({"$schema": MCP_SCHEMA, "mcpServers": servers}), encoding="utf-8")
launcher = root / LAUNCHER
launcher.write_text(f"#!/bin/sh\nexec '{sys.executable}' '{FIXTURE_SERVER}' \"$@\"\n", encoding="utf-8")
diff --git a/tests/e2e/core/mcp_plugins/test_plugin_activation.py b/tests/e2e/core/mcp_plugins/test_plugin_activation.py
index cdc70e4be73..4b272f3ec4e 100644
--- a/tests/e2e/core/mcp_plugins/test_plugin_activation.py
+++ b/tests/e2e/core/mcp_plugins/test_plugin_activation.py
@@ -324,3 +324,30 @@ def test_same_name_plugin_collision_is_reported(name_collision: dict[str, Any],
with known_gate(KNOWN, request.node.name, raises=KnownSymptom):
symptom(named_both, f"two user plugin dirs declare the same name 'foo' ({live} and {backup}) but no "
f"user-visible surface names both: {', '.join(surfaces)}")
+
+
+# A portable package's own trust request ------------------------------------------------------------------
+
+
[email protected]("trust", ["untrusted", None])
+def test_portable_package_trust_request_gates_write_tools_before_the_rpc(tmp_path: Path, trust: str | None) -> None:
+ """A package that marks its server ``trust: untrusted`` (plugin.json Hermes extension) gets the same gate as a
+ config.yaml server: a destructive tool is refused BEFORE the RPC in an unattended ``chat -q`` turn, while a
+ read-only one still runs. Without the request the destructive call reaches the server (default trust)."""
+ servers_ext = {"com.nousresearch.hermes": {"servers": {"pkg": {"trust": trust}}}} if trust else None
+ log = tmp_path / "pkg.jsonl"
+ with provider(script((tool_name("pkg", "ro_probe"), {"nonce": "r"}),
+ (tool_name("pkg", "rw_probe"), {"nonce": "w"}))) as srv:
+ eh = _build_home(tmp_path, srv.base_url, extra={"plugins": {"enabled": ["trusty"]}})
+ write_portable_plugin(eh, "trusty", {"pkg": portable_stdio(log, eh.tag, MCPE2E_CANARY="CANARY-T")},
+ extensions=servers_ext)
+ try:
+ proc = run_chat_q(eh, "Use both pkg tools.")
+ finally:
+ reap_tagged(eh)
+ assert proc.returncode == 0 and FINAL in proc.stdout, (proc.returncode, proc.stdout[-800:], proc.stderr[-2000:])
+ assert calls_received(log, "ro_probe"), "the read-only tool never reached the package's server"
+ if trust:
+ assert not calls_received(log, "rw_probe"), "a destructive tool on a package marked untrusted ran unapproved"
+ else:
+ assert calls_received(log, "rw_probe"), "default-trust package server never received the destructive call"
diff --git a/tests/hermes_cli/test_agent_plugins.py b/tests/hermes_cli/test_agent_plugins.py
index 73c940a6ebb..6152e91862f 100644
--- a/tests/hermes_cli/test_agent_plugins.py
+++ b/tests/hermes_cli/test_agent_plugins.py
@@ -147,6 +147,31 @@ def test_liveness_without_declaration_disables_package(tmp_path: Path) -> None:
load_agent_plugin(tmp_path, tmp_path / "data")
+def _remote_package(root: Path, trust: object | None = None) -> None:
+ servers = {} if trust is None else {"trade": {"trust": trust}}
+ _write_json(root / "plugin.json", _manifest(extensions={"com.nousresearch.hermes": {"servers": servers}}))
+ _write_json(root / "mcp.json", {"$schema": MCP_SCHEMA_V1, "mcpServers": {
+ "trade": {"type": "streamable-http", "url": "https://mcp.example.com/mcp"}}})
+
+
[email protected]("declared,expected", [("untrusted", "untrusted"), ("full", None), (None, None)])
+def test_package_can_ask_for_its_server_to_be_gated_but_never_widened(
+ tmp_path: Path, declared: object, expected: object
+) -> None:
+ # A trading/payments package can make Hermes ask before every write-capable call; "full" is the default, so
+ # declaring it grants nothing a config.yaml entry would not already have.
+ _remote_package(tmp_path, declared)
+ package = load_agent_plugin(tmp_path, tmp_path / "data")
+ assert package.mcp_servers["trade"].get("trust") == expected
+ assert "trade" not in package.server_declarations # trust alone declares no application
+
+
+def test_unknown_trust_value_disables_package(tmp_path: Path) -> None:
+ _remote_package(tmp_path, "trusted")
+ with pytest.raises(AgentPluginError, match="trust must be 'untrusted' or 'full'"):
+ load_agent_plugin(tmp_path, tmp_path / "data")
+
+
def test_unknown_fields_and_non_object_extensions_are_nonfatal(tmp_path: Path) -> None:
_write_json(
tmp_path / "plugin.json",
diff --git a/website/docs/developer-guide/plugins/index.md b/website/docs/developer-guide/plugins/index.md
index d85ff3e3fcd..f69cc4180f3 100644
--- a/website/docs/developer-guide/plugins/index.md
+++ b/website/docs/developer-guide/plugins/index.md
@@ -103,6 +103,32 @@ skipped. Agent Plugins v1 does not define trust, permissions, provenance, or a
sandbox. Enabling a package grants its instructions and local executable the
same full-trust posture as other installed Hermes plugins.
+A package can ask Hermes to gate one of its MCP servers, the same way a user's
+`trust: untrusted` does in `config.yaml`. Use it for servers whose tools spend
+money, trade, send messages or change accounts, so the user approves each
+write-capable call instead of relying on the skill's instructions alone:
+
+```json
+{
+ "extensions": {
+ "com.nousresearch.hermes": {
+ "servers": {
+ "trade": { "trust": "untrusted" }
+ }
+ }
+ }
+}
+```
+
+The server name must match an `mcp.json` entry. With `untrusted`, every tool
+call to that server that is not annotated `readOnlyHint: true` asks the user
+first, and fails closed where nobody can answer (cron, unattended runs). The
+only other accepted value is `full`, the default, so a package can narrow
+access but never widen it. A `config.yaml` server with the same name replaces
+the package's entry, including its trust. Other harnesses ignore this extension.
+`trust` can sit beside `app`, `requires` and `liveness` in the same server
+entry (see [Application declarations](./application-declarations.md)).
+
The [rendered specification](https://agent-plugins.org/specification) currently
labels v1.0.0 a Working Draft, while the
[versioned specification repository](https://github.com/agentplugins/agent-plugins-spec/blob/main/spec/1.0.0.md)
diff --git a/website/docs/reference/mcp-config-reference.md b/website/docs/reference/mcp-config-reference.md
index 4f8dd8d5a91..f2dbceddd08 100644
--- a/website/docs/reference/mcp-config-reference.md
+++ b/website/docs/reference/mcp-config-reference.md
@@ -68,7 +68,7 @@ mcp_servers:
| `auth` | string | HTTP | Authentication method. Set to `oauth` to enable OAuth 2.1 with PKCE |
| `sampling` | mapping | both | Server-initiated LLM request policy (see MCP guide) |
| `elicitation` | mapping | both | Server-initiated user-input requests. `enabled` (default `true`) and `timeout` in seconds (default `300`). Form-mode requests route through the approval surface; URL-mode is declined (see MCP guide) |
-| `trust` | string | both | Trust tier: `full` (default) or `untrusted`. On an `untrusted` server, every write-capable tool call (any tool without a `readOnlyHint: true` annotation) requires user approval through the standard approval surface before it runs. `readOnlyHint` is a server-supplied *hint* — a lying server can at most skip approval for tools it claims are read-only, never gain extra access — so mark any server you don't fully control as `untrusted`. The same hint decides whether a call is transparently retried after the transport session expires mid-call: only `readOnlyHint: true` tools are replayed, while unannotated (write-capable) tools return an `outcome_uncertain` error — on a Streamable-HTTP server that expires idle sessions this means the first unannotated call after an idle period may fail and must be verified before re-invoking. Unrecognized values are treated as `untrusted` (fail-closed) |
+| `trust` | string | both | Trust tier: `full` (default) or `untrusted`. On an `untrusted` server, every write-capable tool call (any tool without a `readOnlyHint: true` annotation) requires user approval through the standard approval surface before it runs. `readOnlyHint` is a server-supplied *hint* — a lying server can at most skip approval for tools it claims are read-only, never gain extra access — so mark any server you don't fully control as `untrusted`. The same hint decides whether a call is transparently retried after the transport session expires mid-call: only `readOnlyHint: true` tools are replayed, while unannotated (write-capable) tools return an `outcome_uncertain` error — on a Streamable-HTTP server that expires idle sessions this means the first unannotated call after an idle period may fail and must be verified before re-invoking. Unrecognized values are treated as `untrusted` (fail-closed) A portable package can request `untrusted` for its own server in `plugin.json` (see [Portable Agent Plugins](../developer-guide/plugins/index.md#portable-agent-plugins-v1-packages)); a `config.yaml` entry with the same name always wins |
## Environment variable references