NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

fix(hermes): reconcile mcp_servers configuration drift at startup

Open apurvvkumaria opened this issue 5 months ago • 0 comments

Source

Identified in PR #5876 — feat(mcp): add OpenShell-managed MCP servers, specifically the PR Review Advisor findings.

Problem

Hermes does not reconcile mcp_servers configuration drift during startup. The existing STRICT_HASH_PATH integrity path verifies config.yaml and .env, but it does not prove that the effective MCP server configuration and the running gateway state agree after an MCP transaction, restart, resume, or rebuild.

A runtime change through nemoclaw mcp add|remove can therefore leave persisted intent, the strict integrity state, and the gateway's loaded MCP configuration out of sync.

Affected paths

  • agents/hermes/start.sh
  • agents/hermes/runtime-config-guard.py
  • agents/hermes/mcp-config-transaction.py
  • the shared verify_config_integrity path in sandbox-init.sh

Impact

  • MCP servers added or removed through NemoClaw may not be reflected after gateway restart or sandbox rebuild.
  • The registry can report one server set while the gateway serves another.
  • Operators receive no clear indication that the running gateway is stale.
  • Credential-bearing MCP configuration can remain active longer than intended after removal.

Required behavior

  • Define a canonical, credential-safe representation of the intended mcp_servers configuration.
  • Extend the strict startup integrity boundary to cover that representation, either within STRICT_HASH_PATH or through a dedicated MCP configuration hash.
  • During Hermes startup, compare persisted MCP intent and effective configuration with the state that will be loaded by the gateway.
  • On drift, either:
    • reconcile deterministically by regenerating configuration and reloading/restarting the gateway; or
    • fail closed before gateway startup with actionable recovery guidance.
  • Update integrity metadata transactionally only after the intended configuration has been applied successfully.
  • Cover additions, removals, restart, resume, and rebuild without logging credential values.

Regression coverage

Add coverage in test/hermes-mcp-config-transaction.test.ts for:

  • no drift: startup proceeds without unnecessary reload;
  • an MCP server added through the transaction module: startup detects and applies or rejects the drift;
  • an MCP server removed through the transaction module: stale gateway configuration cannot survive;
  • stale, missing, or malformed MCP integrity metadata: startup fails closed or performs the documented reconciliation;
  • integrity output and error guidance do not expose credential values.

Add a Hermes runtime/E2E scenario that mutates mcp_servers, restarts or rebuilds the sandbox, and verifies the gateway's effective server set matches the persisted registry intent.

Acceptance criteria

  • Hermes startup cannot silently continue when persisted mcp_servers intent differs from the effective gateway configuration.
  • Successful nemoclaw mcp add|remove operations remain correct after restart, resume, and rebuild.
  • Drift is either reconciled automatically or rejected with an actionable fail-closed error.
  • The strict integrity boundary covers MCP server configuration without exposing raw credentials.
  • Unit and runtime regression tests cover both additions and removals.

apurvvkumaria avatar Jul 03 '26 21:07 apurvvkumaria