Repository navigation
fix(hermes): keep cwd, transport sse and extra keys in Hermes MCP config - #3807
Conversation
Hermes rebuilt every server entry through a lossy allowlist, so stdio cwd,
the `transport: sse` discriminator and documented passthrough keys
(timeout, connect_timeout, auth, ...) never reached config.yaml.
- Switch the `hermes` row of the remote shape owner to
type_key=transport ({streamable-http: omitted, sse: "sse"}), verified,
with the 0.36 url-only shape retired.
- Hermes renders its native shape (modeled keys plus non-denylisted
`extra` passthrough) and opts into native comparison, so ownership
recognizes the 0.36 allowlist render and heals APM-owned entries on the
next install; foreign entries stay preserved.
- Shape-table guard: a row with retired shapes must be bound by an adapter
that keeps native comparison on.
- Tests: unit goldens, ownership heal/conflict, guard mutation, L4 Hermes
lifecycle (HERMES_HOME outside HOME), and Hermes restored in the P1
transport and heal lifecycle matrices.
Fixes #3749
apm-spec-waiver: Hermes MCP native shape follows vendor docs; no OpenAPM requirement pins harness MCP keys (T3 brief F29)
Co-authored-by: Parth-Vasave <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…ermes MCP Co-authored-by: Parth-Vasave <[email protected]> Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Frozen SSE healing leaves a stale content hash, causing subsequent installs to drop Hermes’ ownership claim and leading to update conflicts and incomplete uninstall cleanup.
1 open issue
What changed in this PR
This PR addresses #3749 by preserving Hermes MCP configuration fields and extending the shared transport-shape and ownership mechanisms introduced in #3789.
Changes:
- Preserve stdio
cwd, allowed extra keys, andtransport: ssein Hermes configuration. - Enable native comparison and migration of earlier APM-written entries.
- Add lifecycle coverage, an architecture guard, and updated usage documentation.
| File | Description |
|---|---|
tests/unit/install/test_mcp_ownership.py |
Include Hermes among native-comparison adapters. |
tests/unit/adapters/test_mcp_remote_transport_shapes.py |
Update the Hermes SSE expected shape. |
tests/unit/adapters/test_hermes_client_adapter.py |
Test field preservation, migration, and conflict protection. |
tests/integration/test_mcp_retired_shape_heal_lifecycle.py |
Restore Hermes migration assertions. |
tests/integration/test_mcp_remote_transport_harness_lifecycle.py |
Include Hermes in transport lifecycle coverage. |
tests/integration/test_hermes_mcp_fidelity_lifecycle.py |
Add configuration preservation and uninstall scenarios. |
tests/integration/test_architecture_owner_rule_mutations.py |
Test rejection of disabled comparison for retired shapes. |
src/apm_cli/adapters/client/hermes.py |
Preserve native fields and recognize legacy renders. |
src/apm_cli/adapters/client/_remote_shapes.py |
Define Hermes SSE transport and retire the URL-only shape. |
scripts/architecture_linter/checks/mutation_mcp_remote_transport.py |
Guard native comparison for adapters with retired shapes. |
packages/apm-guide/.apm/skills/apm-usage/dependencies.md |
Document Hermes transport and passthrough fields. |
docs/src/content/docs/integrations/hermes.md |
Explain preserved fields and migration behavior. |
docs/src/content/docs/consumer/install-mcp-servers.md |
Update Hermes transport and ownership guidance. |
CHANGELOG.md |
Add the Hermes configuration fix entry. |
.apm/architecture/owners/hooks-integrations.json |
Extend the shape owner's native-comparison contract. |
Review effort: Balanced
…dows-safe Replace the CHANGELOG placeholder with (#3807). The HERMES_HOME override unit test used a POSIX literal, which is relative on Windows and now rejected by the user-root owner; it uses a tmp_path root instead. The Hermes tests that set HERMES_HOME join the windows_compat family. Co-authored-by: Parth-Vasave <[email protected]> Co-authored-by: Copilot App <[email protected]>
`apm install --frozen` heals an APM-owned registry entry from a retired remote shape but never writes apm.lock.yaml, so its fingerprint still describes the retired shape. The next install saw a fingerprint mismatch, classified the healed entry as foreign and dropped the claim on every harness, so later updates conflicted and removing the declaration left the entry behind. The ownership owner now swaps the entry's remote shape keys back to a retired render's values; when that reproduces the recorded fingerprint exactly (and the shape keys equal the current render) the entry stays managed and is rewritten once so the lock records its current receipt. Any other edit changes the fingerprint and stays a conflict. apm-spec-waiver: ownership fingerprint bookkeeping only; no OpenAPM requirement covers harness MCP receipts Co-authored-by: Parth-Vasave <[email protected]> Co-authored-by: Copilot App <[email protected]>
…ntry Panel folds on the frozen-heal ownership fix: - A receipt that predates a --frozen heal no longer forces UPDATE_MANAGED. compare_native_mcp_connection reports it through stale_receipts and the entry stays MATCHING_MANAGED; the registry path refreshes the receipt via retain_native_receipt(replace=True). Repeated --frozen runs write nothing and env-derived values are not churned. - _shape_delta is the one definition of a shape change, shared by the retired-shape heal and the stale-receipt check. - Behavioral guard: every runtime whose shape row retires earlier shapes resolves compares_native_connections True (covers inherited opt-outs). - Hermes cells: the frozen-heal unit matrix runs for Copilot and Hermes, and a hand-written same-name Hermes entry equal to the 0.36 render stays foreign and unclaimed. apm-spec-waiver: ownership fingerprint bookkeeping only; no OpenAPM requirement covers harness MCP receipts Co-authored-by: Parth-Vasave <[email protected]> Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 3 | 0 | Heal placed in the ownership owner, fingerprint un-heal is sound; stale-receipt rewrite and duplicated shape-delta flagged (both folded). |
| Test Coverage Expert | 0 | 2 | 0 | Every scoped Hermes promise has a real-binary lifecycle trap that fails on revert; foreign/edited same-name Hermes cells added. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
All panel and Copilot reviewer findings are folded at 141ffc6, each with a test that fails when the fix is reverted, and nothing remains open. Next step: confirm CI is green on 141ffc6 and get a review from the CODEOWNERS-requested reviewer, Sergio Sisternes (@sergio-sisternes-epam), then ship in 0.36.1. Keep watching the frozen-install idempotency assertion (unchanged native bytes and mtimes on every harness); any future retired-shape heal depends on it.
Full per-persona findings
Python Architect
- [recommended] A stale receipt used UPDATE_MANAGED to refresh, so every later
--frozeninstall rewrote the same entry atsrc/apm_cli/install/mcp/ownership.py
Refreshing the lock receipt and writing the native file are different decisions;--frozennever writes the lock, so the rewrite repeated and could churn env-derived values.
Folded at 141ffc6: compare reportsstale_receipts; the entry stays MATCHING_MANAGED and the registry caller refreshes viaretain_native_receipt(replace=True). Lifecycle asserts a second--frozenrun writes nothing. - [recommended]
_in_retired_shapeand_healed_since_receipteach computed the shape-key delta
One definition should decide which differences are APM's shape change.
Folded:_shape_deltashared by both. - [recommended] The AST guard reads only the adapter's own class body, so an inherited
compares_native_connections = Falsegets past it atscripts/architecture_linter/checks/mutation_mcp_remote_transport.py
Folded:test_every_runtime_with_retired_shapes_compares_native_contentchecks the resolved attribute for every runtime with retired shapes.
Test Coverage Expert
- [recommended] No lifecycle test proved a user-authored same-name Hermes MCP entry is preserved rather than taken over
Folded:test_foreign_entry_in_a_retired_shape_is_never_taken_overplantsheal-foreign = {url, enabled: true}(the exact 0.36 Hermes render) and asserts it unchanged and unclaimed. - [recommended] Frozen-heal negative cases ran only against Copilot
Folded:test_frozen_heal_keeps_the_retired_receipt_verifiableis parametrized over copilot and hermes.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
Drive-to-merge pass: ready to mergeHead Folded in this run
Copilot signals reviewed
Regression-trap evidence (mutation-break gate)
Lint contract
CI
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors. |
Resolve tests/unit/adapters/test_hermes_client_adapter.py by keeping #3815's tmp_path-based, windows_compat HERMES_HOME override test; the #3749 Hermes tests keep their tmp_path fixture and windows_compat marks. Co-authored-by: Parth-Vasave <[email protected]> Co-authored-by: Copilot App <[email protected]>
|
Thanks for picking this up and for the co-author credit! I verified the fix on
I haven't checked this against a live Hermes agent, so that part isn't covered. LGTM. |

Description
Hermes MCP servers now keep what the manifest declares. Until now APM rebuilt every Hermes entry through an allowlist (
command/args/envorurl/headers), so:cwdwas dropped,transport: sseand Hermes connected over Streamable HTTP, andtimeout,connect_timeoutandauthnever reachedconfig.yaml.What changes:
adapters/client/_remote_shapes.py): thehermesrow now usestype_key="transport"with{streamable-http: omitted, sse: "sse"}, is marked verified, and lists the 0.36 url-only shape as retired.adapters/client/hermes.py): renders its native shape through the shared formatter. It keeps the modeled keys (command/args/env/cwdfor stdio,url/headers/transportfor remotes) and everyextrakey that passed the passthrough denylist owner (models/dependency/mcp.py), soserverUrl/httpUrl/enabledare still stripped. It drops the Copilot-only keys and stampsenabledlast.legacy_managed_renders). The ownership owner then rewrites APM-owned entries on the nextapm install/update/install --frozen. A same-name entry the user wrote is preserved and reported as a conflict. Unrelated top-levelconfig.yamlkeys are untouched.install/mcp/ownership.py, found by Copilot review):apm install --frozenheals a fingerprinted registry entry but never writes the lockfile, so the next install saw a fingerprint mismatch and dropped the claim on every harness (later updates conflicted, removing the declaration left the entry behind). The owner now swaps the entry's remote shape keys back to a retired render; only when that reproduces the recorded fingerprint exactly, and the shape keys equal the current render, does it stay managed, and it is rewritten once so the lock records the current receipt. Any other edit stays a conflict.retain_native_receipt(replace=True)instead of forcing a rewrite, so repeated--frozenruns write nothing;_shape_deltais the single shape-change definition; a behavioral test asserts every runtime with retired shapes resolvescompares_native_connectionsTrue (inherited opt-outs included); a hand-written same-name Hermes entry equal to the 0.36 render stays foreign; the frozen-heal unit matrix covers Copilot and Hermes.mutation_writes.mcp_remote_shape_tablenow fails when a row lists retired shapes but its adapter setscompares_native_connections = False, since those writes could never heal. Registry decision text updated, mutation test added.Vendor evidence (verified 2026-11-17):
url/headers(HTTP),command/args/env(stdio),transport("Set to sse to use the SSE transport instead of Streamable HTTP"),timeout,connect_timeout,auth("Set to oauth ..."),tools,ssl_verify,lazyand the other per-server keys.cwdis not in the reference table. Upstream source NousResearch/hermes-agent@065f5abbb3tools/mcp_tool_transport.py:135(cwd = config.get("cwd")in_stdio_launch).if config.get("transport") == "sse":) andtools/mcp_tool_server_run.py:289.Credit: implemented with parth (@Parth-Vasave), who reported and volunteered on #3749 (co-author trailer on the commits).
Issue and approved scope
Issue: Fixes #3749
Human scope-approval comment: #3749 (comment)
Does this PR complete the issue, or what remains? It completes it: project and user scope (including
HERMES_HOMEoutsideHOME) persistcwd, documented extra keys andtransport: sse; unrelated keys are preserved; reinstall is idempotent; uninstall removes only APM entries; earlier APM writes heal.Type of change
Testing
Validation (macOS,
.venv,-p no:xdist, lifecycle usesAPM_BINARY_PATH=.venv/bin/apm, temp HOME, no network):pytest tests/unit/install/test_mcp_ownership.py tests/unit/adapterspytest tests/unit/test_mcp_integrator_remove_stale.py tests/unit/test_mcp_client_factory.py tests/unit/test_transitive_mcp.py tests/integration/test_mcp_install_flow.py tests/integration/test_hermes_target.py tests/integration/test_architecture_mcp_native_comparison.py tests/unit/scripts/test_architecture_runner.py tests/unit/adapterspytest tests/integration/test_architecture_owner_rule_mutations.pypytest tests/integration/test_hermes_mcp_fidelity_lifecycle.py tests/integration/test_mcp_remote_transport_harness_lifecycle.py tests/integration/test_mcp_retired_shape_heal_lifecycle.pyhermes-sse)[project-v0.36.0-install],[user-v0.35.1-install]+ transport[user-sse]on the unfixed sourceKeyError: 'cwd', notransport: sse, no heal)pytest tests/unit/adapters/test_hermes_client_adapter.py tests/unit/adapters/test_mcp_remote_transport_shapes.py tests/unit/install/test_mcp_ownership.py tests/unit/scripts/test_architecture_runner.pyAPM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_hermes_mcp_fidelity_lifecycle.py tests/integration/test_mcp_remote_transport_harness_lifecycle.py tests/integration/test_mcp_retired_shape_heal_lifecycle.py tests/integration/test_architecture_owner_rule_mutations.pypytest tests/unit/install/test_mcp_retired_shape_heal.py -k frozen_healon the unfixed ownerfrozen-healed), 2 passedtest_mcp_retired_shape_heal_lifecycle.py -k frozen_heal_keepson the unfixed ownerAPM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_hermes_mcp_fidelity_lifecycle.py tests/integration/test_mcp_remote_transport_harness_lifecycle.py tests/integration/test_mcp_retired_shape_heal_lifecycle.py tests/integration/test_architecture_mcp_native_comparison.py tests/integration/test_mcp_install_flow.py tests/integration/test_hermes_target.py tests/integration/test_mcp_credential_scope_lifecycle.py tests/unit/test_mcp_integrator_remove_stale.py tests/unit/install--frozenrun on the previous owner (e4bcf2c).vscode/mcp.jsonrewritten, mtime changed)tests/integration/test_mcp_only_lockfile_lifecycle.py tests/unit/adaptersuvx [email protected] check/format --checkon the CI pathspylint --disable=all --enable=R0801 ...(CI paths)bash scripts/lint-auth-signals.sh,bash scripts/lint-architecture-boundaries.shstr(relative_to), 2100-line guardsNew tests:
tests/unit/adapters/test_hermes_client_adapter.py: goldens for stdio cwd plus extras, SSEtransport: sseplusauthwith denylisted aliases stripped, Streamable HTTP with notransportkey, registry SSE remote, unrelated keys and foreign servers preserved and idempotent, and v0.36 heal (fingerprint and no-fingerprint) vs a foreign edit (CONFLICT).tests/integration/test_hermes_mcp_fidelity_lifecycle.py(L4, RT3's oracle plus a packageapm uninstall -gcase).HERMES_HOMEusetmp_pathroots and carrywindows_compat(a POSIX literal is relative on Windows and the user-root owner rejects it)._assert_healedupgrade assertions.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedapm-spec-waiver:line is in the fix commit message.