feat(hermes): add current plugin and MCP integration - #981
Open
CommanderTurtle wants to merge 36 commits into
Open
feat(hermes): add current plugin and MCP integration#981CommanderTurtle wants to merge 36 commits into
CommanderTurtle wants to merge 36 commits into
Conversation
Author
tayuLuc
reviewed
Jul 21, 2026
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



feat(hermes): add current plugin and MCP integration
Summary
This PR revives the intent of #425 as a clean implementation against the
current Context Mode and Hermes Agent APIs.
It adds:
mcp__context_mode__ctx_*tool guidance;This is not a cherry-pick of the old PR. Its final head became an orphaned
full-repository snapshot after force-push history changes, and several Hermes
contracts have changed since then.
Motivation
Hermes already supports MCP and a public Python plugin system. Context Mode can
therefore remain the normal MCP execution/indexing server while a small native
plugin enforces routing before high-output terminal calls enter model context.
The split is intentional:
Current Hermes Contract Validation
The implementation was checked against current Hermes Agent
mainata41d280f95c69f67380358b305b62345934ecaf3.register(ctx)and all six registered hooks are accepted by the currentPluginManager.pre_tool_callreturns Hermes' consumed{"action":"block","message":"..."}schema.pre_llm_callreturns{"context":"..."}once per session.transform_tool_resultreturns a replacement string for eligible oversizedresults.
mcp__<sanitized_server>__<sanitized_tool>format.on_session_endis treated as a per-turn persistence boundary.on_session_finalizeperforms actual teardown and state release.Reviewer Feedback From #425
From intent in code-review #4233782693
tests/adapters/hermes.test.ts.stdio process.
The bounded state is stricter than requested: it is concurrency-safe, evicts
oldest entries, and never exceeds exactly 1,000 session IDs.
Safety and Failure Model
Verification
The full Context Mode Node/Vitest run produced 4,660 passes, 56 skips, and 34
failures. All failures are pre-existing environment prerequisites on the Windows
test host: no Git Bash for POSIX-shell assertions, no symlink privilege for
symlink security tests, and no npm executable in the isolated Node runtime.
The Hermes adapter tests passed.
Manual Validation Before Merge
hermes mcp add context-mode --command npx --args -y context-mode..hermes-plugin.hermes mcp test context-mode.ctx statsdispatches.git statusremains allowed.Maintenance
I am willing to own Hermes-specific issue triage and keep this adapter aligned
with future public Hermes hook and MCP contract changes.
References
Table of Contents
Implementation of PR #425 revival against current upstream code.
Details
Context Mode PR 425 Revival Report
Date: 2026-07-20
Executive Finding
The Hermes Agent integration proposed in #425 remains
architecturally sound, but its final branch cannot be safely rebased. The last
PR commit is an orphaned full-repository snapshot after multiple force pushes.
This revival therefore reimplements the intent against current upstream APIs
instead of cherry-picking historical code.
The resulting adapter uses only documented Hermes plugin hooks and the normal
Context Mode MCP server. It has been validated against current checkouts of
both projects, including Hermes' real PluginManager, real block-directive
consumer, and real MCP stdio registration path.
Revisions Under Test
main1618d9764921c66f3c9cdab8a45d2d8f7f0b0648maina41d280f95c69f67380358b305b62345934ecaf37555fad47f457b8bff28fe8b7a1c0af4e7d7419bBoth
origin/mainrevisions were fetched and confirmed current immediatelybefore the final test pass.
Historical Intent Recovered
PR 425 proposed:
pre_tool_callblocking andpre_llm_callguidance;The owner and reviewers identified the following merge conditions:
get_pre_tool_call_directive().tests/adapters/hermes.test.ts.OrderedDictwith exact 1,000-entry LRU eviction and threaded tests.Discussion Chronology
tayuLucopened the proposal with configuration, plugin, README,and a six-step manual test plan.
mksgluasked why the adapter was Python. The author correctlytied that choice to Hermes' Python-native plugin loader.
EPPCOM-Solutionsrequested proof of the real Hermes API, thefour specific Vitest behaviors, a bounded guidance map, and documentation
cleanup. The review explicitly called the architecture defensible.
mksglurequired the contributor to own future Hermes issues,bugs, and improvements because the maintainer does not use Hermes.
SoTHISIsFitnessrecorded community interest and characterizedthe remaining blockers as tractable.
the author selected pytest and moved the historical Python tests to it.
The maintainer then required manual testing before reopening.
dfein38347gasked for the integration to be reopened; GitHub nolonger allowed reopening the historical PR.
The current README no longer contains the duplicate Linux summary line noted
in the old review, so no historical merge-artifact deletion was carried over.
Current-API Corrections
The old patch is not merely stale source code. Several contracts changed or
were incorrect in the original proposal:
mcp__<sanitized_server>__<sanitized_tool>. The revived guidance usesmcp__context_mode__ctx_*exactly.hermes mcp add context-mode --command npx --args -y context-mode.on_session_endis a per-turn plugin boundary in the current agent loop.The plugin persists a snapshot there without discarding session state.
on_session_finalizeis the actual CLI/gateway teardown boundary and nowperforms final persistence and state release.
parallel calls from overwriting one another.
no platform skip.
Implemented Surface
context-mode/.hermes-plugin/plugin.yamlcontext-mode/.hermes-plugin/__init__.pycontext-mode/.hermes-plugin/README.mdcontext-mode/configs/hermes/AGENTS.mdcontext-mode/docs/adapters/hermes-agent.mdcontext-mode/tests/adapters/hermes.test.tscontext-mode/tests/adapters/hermes_probe.pycontext-mode/tests/adapters/hermes_test.pycontext-mode/package.json.hermes-pluginin the npm package.current_hermes_compatibility_test.pySafety and Resource Invariants
plugin does not duplicate the MCP server.
Conclusion
The historical design can be revived cleanly, but only as a current-API
reimplementation. The reviewer blockers are resolved in code and tests. The
remaining work before submission is human policy rather than engineering:
choose the target branch, confirm long-term Hermes-specific issue ownership,
and run the documented manual conversation check in a maintainer-approved
Hermes installation.
Details
Verification Results
Date: 2026-07-20
Environment
v24.14.01.3.143.12.100.11.29Dependencies were resolved in the cloned repository's isolated
.venv, and the current Context Mode MCP server was launched only for the compatibility test.Required and Targeted Tests
pytest tests/adapters/hermes_test.py -qvitest run tests/adapters/hermes.test.tstsc --noEmitgit diff --checkThe live compatibility harness established all of the following through current
Hermes code:
{ "block_schema": "consumed by current Hermes", "ctx_stats": "dispatched", "guidance": "first turn only", "hooks": 6, "mcp_tools_registered": 15, "plugin": "loaded" }Full Context Mode Suite
The full suite was run through Node.js rather than Bun because Context Mode's
test matrix exercises Node-specific SQLite and shell behavior.
The six affected test files are unrelated to the Hermes adapter. Their failures
are attributable to this Windows host's missing test prerequisites:
installed/discoverable.
EPERMbecause Developer Mode or anelevated symlink privilege is unavailable.
npmbecause this isolated Noderuntime provides
node.exebut no npm executable.The machine-readable full report is
full-vitest-results.json. The HermesVitest file passed within the same test environment.
An earlier
bun run testattempt was not used as release evidence: Bun cannotfaithfully execute this repository's Node-specific
better-sqlite3, Zod, shell,and symlink assumptions. Its pretest build and bundle assertions did pass.
Manual Check Still Recommended
Before merge, perform one maintainer-approved installed-session check:
context-modewith the current Hermes MCP CLI syntax..hermes-plugin.hermes mcp test context-modesucceeds.ctx stats.curlrequest and confirm Hermes receives the blockmessage and selects the prefixed Context Mode tool instead.
git statusand confirm it is allowed.Details
Source References
Historical PR
pr-425-original:7555fad47f457b8bff28fe8b7a1c0af4e7d7419bThe PR conversation contains the original architecture, the three blocking
review findings, the pytest recommendation, the owner's maintenance request,
and the requirement for manual validation.
Current Hermes Sources Used
hermes-agent/hermes_cli/plugins.pyhermes-agent/cli.pyhermes-agent/agent/turn_finalizer.pyhermes-agent/gateway/run.pyhermes-agent/tools/mcp_tool.pyhermes-agent/tests/hermes_cli/test_plugins.pyhermes-agent/tests/tools/test_mcp_tool.pyOfficial Hermes Documentation
Current Hermes source and tests are authoritative for the exact MCP tool prefix.
They use double separators:
mcp__server__tool. Any older single-underscoreexample should not be copied into this integration.
Verified
ctx_stats.The implementation addresses every material comment from PR #425, including bounded guidance state, pytest adoption, public API proof, current MCP naming, manual-test guidance, and maintainership language. It is grounded in the current Hermes repository, plugin API, hook contracts, and MCP documentation.