Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 32 additions & 20 deletions polyfills/events/hermes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Also available for [Claude Code](../claude-code/README.md),

This plugin implements the client side of the MCP Events extension,
[SEP-3415](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/seps/3415-events-extension.md)
(the Final text, as of 24 November 2026), for **poll and push** delivery.
Hermes already does the third mode, webhook delivery, itself (`events: true`
on a server), and this plugin leaves those servers to Hermes. Details are in
(the Final text, as of 24 November 2026), for **webhook, push and poll** delivery. Each watch uses a mode the server
advertises for that event type. Servers configured with `events: true` use
Hermes’s native webhook subscriptions. Details are in
[Spec and conformance](#spec-and-conformance).

## Install
Expand Down Expand Up @@ -120,7 +120,7 @@ To stop: "Stop watching the demo button."
### How the parts fit together

```
your MCP server ◄── events/list · events/poll · events/stream ── helper (Node: plugin/dist/helper.mjs)
your MCP server ◄── events/list · poll · stream · subscribe ── helper (Node: plugin/dist/helper.mjs)
│ ▲
wake {session, text} │ │ initialize {servers} · call {tool, session} · spoke
▼ │
Expand Down Expand Up @@ -164,18 +164,30 @@ plugin may use change (one named or removed, its entry edited, or switched to
resume on the servers still in it, and a watch on a server now left to Hermes
stays saved but doesn't run, so no server is watched twice.

### Webhook delivery stays with Hermes

Hermes implements webhook delivery natively: with `events: true` and a
public address for its webhook listener (`platforms.webhook.extra.public_url`),
each event starts an unattended agent run, with Hermes's own
`subscribe_event` tool and approval. This plugin adds the two modes Hermes
doesn't have, poll and push, and never subscribes by webhook. An event type a
server delivers only by webhook gets an answer that points to `events: true`.
The relay the Claude Code and Codex forms can use isn't used here: the helper
drops the relay settings from its environment and doesn't read the relay
file their setup writes (`~/.mcp-events/relay.json`), so a relay set up for
them changes nothing here.
### Webhook delivery

Push and poll work as soon as a server is connected. To receive signed
webhooks in the watching session, give the MCP server a credential header
in its configuration and set up a public HTTPS callback for the gateway.
For a type offering several modes, the plugin chooses webhook when configured
and authenticated, then push, then poll.

- **Private relay.** Set `MCP_EVENTS_RELAY_URL` and, if required by your
relay, `MCP_EVENTS_RELAY_ACCESS_KEY` in the gateway environment. The
gateway can also read a relay settings file at
`$HERMES_HOME/mcp-events/relay.json`. Set `MCP_EVENTS_RELAY_FILE` to
select an existing file, including one created by another Events plugin.
- **Public relay.** Set `MCP_EVENTS_RELAY=public` to opt in. Its operator
can read event payloads. Both relay options need Node 22 or newer.
See the [shared relay setup](../codex/README.md#webhook-delivery-the-relay).
- **Your HTTPS forwarder.** Set `MCP_EVENTS_PUBLIC_URL` to its public base
URL and `MCP_EVENTS_RECEIVER_PORT` to the loopback port it forwards to.
One session can own a given receiver port at a time. A relay supports
concurrent sessions.

For native Hermes webhook runs, configure `events: true` on the server and
`platforms.webhook.extra.public_url` for Hermes. That server then uses
Hermes’s own `subscribe_event` tool.

### Where it keeps things

Expand All @@ -195,7 +207,7 @@ announced once.

### Settings

There's nothing to set beyond the two grants above. The shared client's
The shared client's
environment variables work as in the other forms (`MCP_EVENTS_WAKES_PER_HOUR`,
`MCP_EVENTS_WAKE_GAP_S`, `MCP_EVENTS_PRE_STANDARD`), set in the gateway's
environment.
Expand Down Expand Up @@ -302,7 +314,7 @@ In short, details in [`SECURITY.md`](SECURITY.md):
of it, and a kept approval covers that exact watch only.
- The plugin reads no Hermes credentials, connects only to servers you
granted, and stays in the profile it was loaded for.
- Webhook delivery, which needs a public address, isn't done by this plugin.
- The plugin verifies webhook signatures before recording a delivery. A relay operator can read the payload.

## Spec and conformance

Expand All @@ -313,11 +325,11 @@ of the shared client is the Claude Code form's.

| Test | What it covers |
|---|---|
| `test/spec-test.ts` | LIST-1, DM-1, CAP-2, CAP-4, PUSH-1, PUSH-2, PUSH-11, POLL-1, POLL-2, POLL-5, STATE-1, DEDUP-1, SEC-1, SEC-2, the wake gate, refused and unanswered wakes, sessions kept apart, webhook left to Hermes (a relay set up for the other forms included), no server text in a wake |
| `test/spec-test.ts` | LIST-1, DM-1, CAP-2, CAP-4, PUSH-1, PUSH-2, PUSH-11, POLL-1, POLL-2, POLL-5, STATE-1, DEDUP-1, SEC-1, SEC-2, the wake gate, refused and unanswered wakes, sessions kept apart, webhook setup, signed delivery and unsubscribe, no server text in a wake |
| `test/e2e_test.py` | In Hermes: Hermes's approval for a watch (and a declined one), no watch with `approvals.mode: off` or in `hermes -z`, push and poll waking an idle session, `events: true` and servers not named left alone, a server switched to `events: true` mid-run no longer watched after the next turn, no injection grant, Tool Search |
| `test/test_plugin.py`, `tools/hermes/shared/test_servers.py` | The Python half: approvals keyed by the whole watch and the server's entry, only the call asked about run, questions shown in full, no watch where Hermes approves without asking, a delegated child's turn not counted as the person, the grant read with `ctx.get_config`, the helper started again when the servers change; which servers it may use, no `${VAR}` filled in, its own profile only, a stuck helper ended, telling that Hermes approves without asking |
| `test/plugin-test.ts` | The installed folder matches a fresh build |
| The upstream conformance suite's Events client scenarios (`modelcontextprotocol/conformance#541` at `c8625de`), through the bundled helper: `test/conformance-driver.ts --suite` | The 14 checks that apply pass. The webhook scenario's three are "unverified, not violated": webhook is Hermes's own here |
| The upstream conformance suite's Events client scenarios (`modelcontextprotocol/conformance#541` at `c8625de`), through the bundled helper: `test/conformance-driver.ts --suite` | Discovery, poll, push and webhook scenarios against the installed helper |
| [`WakeHermes.tla`](../claude-code/model/README.md#wakehermestla-how-often-events-wake-a-hermes-session), TLC | The wake budget and hand-over, with the gateway stopping between any two steps: holds, with five documented limits |
| `test/interop_hookbench.py` | [NHTanvir/hookbench](https://github.com/NHTanvir/hookbench)'s reference server, through Hermes: discovery, push, routing headers, filtering, payload as data, termination |
| `test/e2e_shared_gateway.py` | In Hermes's shared gateway, which the TUI and Desktop attach to: a watch, then an event waking the idle session |
Expand Down
9 changes: 5 additions & 4 deletions polyfills/events/hermes/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ tool result from the same server could. How often is bounded, not prevented.
frame a message. The only request the helper may make of the Python half is
`wake`. Writes have one deadline with the answer; a helper that stops
reading is ended, and the tools say so.
- **No webhook.** Webhook delivery needs a public address; this plugin never
sets one up, and ignores the relay the other forms can use (its settings
and its file, `~/.mcp-events/relay.json`). Hermes does webhooks itself for
`events: true` servers.
- **Webhooks.** The plugin verifies signed deliveries and stores events
before acknowledging them. Relay mailboxes and signing secrets belong
to the watching session. A relay operator can read payloads. The gateway
uses the relay configured for its profile or selected in its environment.
See [webhook delivery](README.md#webhook-delivery).

## Limits

Expand Down
22 changes: 7 additions & 15 deletions polyfills/events/hermes/docs/conformance.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SEP-3415 client conformance, in Hermes

How this client (the Hermes form of mcp-events, 0.1.0, on Hermes Agent
How this client (the Hermes form of mcp-events, 0.2.0, on Hermes Agent
v0.23.4) stands against the **Final** text of SEP-3415
(`seps/3415-events-extension.md` in `modelcontextprotocol/modelcontextprotocol`,
as fetched on 24 November 2026), the same revision as the other forms.
Expand All @@ -14,11 +14,6 @@ against that same code. There: **with `MCP_EVENTS_PRE_STANDARD=off`, 80 met
and 6 not applicable; by default 78 met, 2 met with a documented exception
(CAP-2 and CAP-4), 6 not applicable, none missing.**

In Hermes the client never subscribes by webhook (Hermes does that itself for
`events: true` servers), so the webhook clauses that bind a client which
subscribes by webhook don't apply to this form. Every other result there holds
here.

What this file adds: which rules this form's own tests check end to end,
through the helper as the Python half starts it and through a real Hermes,
and what is different in Hermes.
Expand All @@ -32,6 +27,7 @@ and what is different in Hermes.
| PUSH-1, STATE-1, DEDUP-1 | one `events/stream` per watch; the client's own registry; dedup by eventId | `test/spec-test.ts` "PUSH-1, STATE-1, DEDUP-1"; `test/e2e_test.py` "watch by push wakes the idle session" |
| PUSH-2 | unwatch cancels the stream | `test/spec-test.ts` "PUSH-2" |
| POLL-1, POLL-2, POLL-5 | polled at the recommended interval, with the cursor passed back | `test/spec-test.ts` "POLL-1, POLL-2, POLL-5"; `test/e2e_test.py` "poll and a declined watch" |
| WH-11, RX-1, RX-7 | The fixture verifies the callback, delivers a signed occurrence, wakes the watching session and receives an unsubscribe | `test/spec-test.ts` "a signed webhook wakes the watching session" |
| STATE-1, PUSH-11 | after a gateway restart, resumed from the saved cursor; what came meanwhile arrives once | `test/spec-test.ts` "STATE-1, PUSH-11" |
| SEC-1, SEC-2 | payloads reach the model only as tool results; the wake carries no server text | `test/spec-test.ts` "SEC-1, SEC-2" and "a wake carries nothing a server wrote" (three tests); `test/e2e_test.py` (the wake holds ids only) |
| SEC-3 | receiving an event authorizes nothing | starting and stopping a watch go through Hermes's approval, and no watch starts where Hermes approves without asking: `test/test_plugin.py`, `test/e2e_test.py` (approved, declined, and `approvals.mode: off`) |
Expand All @@ -42,7 +38,7 @@ and what is different in Hermes.

| Clause | In Hermes |
|---|---|
| WH-* (webhook delivery) | Not done by this form. Hermes implements webhook delivery itself for a server with `events: true`, and this form leaves such a server alone; an event type a server delivers only by webhook gets an answer that points to `events: true`. `test/spec-test.ts` "a webhook-only event type is not subscribed", `test/e2e_test.py` "stands down" |
| Webhook ownership | The plugin uses the shared webhook client on granted servers. Hermes owns servers with `events: true`. See `test/spec-test.ts` and the native ownership check in `test/e2e_test.py`. |
| SEC-2 (the wake) | Stricter than the shared client: `ctx.inject_message` puts the wake in the conversation as the user's message, so each line is written from the plugin's own data (watch id, the server's name in your config, event ids, your note), not the event type's name or a notice's text. `test/spec-test.ts` "a wake carries nothing a server wrote" |
| SEC-3, SEC-4 | `watch_event` and `unwatch_event` go through Hermes's own approval (a `pre_tool_call` approve directive; once, session, always or deny), with a key that is a digest of the whole watch, so "always" covers that exact watch only. Where Hermes approves without asking (`--yolo`, `/yolo`, `hermes -z`, `approvals.mode: off`), no watch starts. What the model does after a wake goes through Hermes's approvals as any turn does |
| SEC-5 (the client owns subscription state) | Per Hermes session, in `$HERMES_HOME/mcp-events/` (by a digest of the session key), private to the user |
Expand All @@ -61,14 +57,10 @@ spoken to as the Python half does (newline JSON-RPC: `initialize` with the
suite's server, then `list_event_types` and `watch_event` calls naming a
Hermes session, every wake answered as taken).

| Scenario | Result |
|---|---|
| `events-client-no-extension` | 1 of 1 |
| `events-client-poll` | 10 of 10 |
| `events-client-push` | 3 of 3 |
| `events-client-webhook` | 0 of 3, all "unverified, not violated": webhook is Hermes's own here, so this form never subscribes by webhook |

**14 of the 14 checks that apply.**
The driver runs all four scenarios (no extension, poll, push and webhook).
The webhook scenario checks subscriptions and refreshes. It uses the
shared client's development switch for the suite's anonymous loopback
server. The signed delivery itself is exercised by `test/spec-test.ts`.

To run it, from a checkout of the suite at that commit with its dependencies
installed, and this folder built:
Expand Down
4 changes: 2 additions & 2 deletions polyfills/events/hermes/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions polyfills/events/hermes/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "mcp-events-hermes",
"private": true,
"version": "0.1.0",
"version": "0.2.0",
"type": "module",
"description": "A Hermes Agent plugin that adds MCP Events (SEP-3415) by poll and push: Hermes can watch events on your MCP servers, and an event wakes the idle session that asked for it.",
"description": "A Hermes Agent plugin that adds MCP Events (SEP-3415) by webhook, push and poll: Hermes can watch events on your MCP servers, and an event wakes the idle session that asked for it.",
"engines": {
"node": ">=20"
},
Expand Down
23 changes: 18 additions & 5 deletions polyfills/events/hermes/plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""mcp-events for Hermes: MCP Events (SEP-3415) by poll and push.
"""mcp-events for Hermes: MCP Events (SEP-3415) by webhook, push and poll.

The Hermes half of the plugin. It registers the six tools, asks Hermes's own approval before a
watch starts or stops (a ``pre_tool_call`` approve directive), and runs the helper
Expand Down Expand Up @@ -77,14 +77,25 @@ def restart_if_changed(self) -> bool:
if helper is None or helper.closed:
return False
try:
if self.wanted() == self.started_with:
wanted = self.wanted()
if wanted == self.started_with:
return False
except Exception as exc: # noqa: BLE001 - an unreadable config ends nothing
logger.warning("mcp-events: the configuration could not be read again (%s)", exc)
return False
self.helper = None
previous = self.started_with[0] if self.started_with else {}
withdrawn = [name for name, cfg in previous.items() if wanted[0].get(name) != cfg]
# Retire lasting webhook subscriptions on the old connection before allowing a
# replacement helper to claim these sessions. Normal gateway stops keep them.
try:
if withdrawn:
helper.request("suspend", {"servers": withdrawn}, timeout=8)
except Exception as exc:
logger.warning("mcp-events: could not finish retiring watches before restart (%s)", exc)
finally:
helper.close()
self.helper = None
logger.info("mcp-events: the servers it may use changed; the helper starts again with the new set")
helper.close()
return True

def _state(self) -> Path:
Expand Down Expand Up @@ -125,7 +136,9 @@ def ensure(self) -> Optional[_helper.Helper]:
except Exception as exc: # noqa: BLE001
self.unavailable = f"Hermes's config.yaml could not be read ({exc})"
return None
helper = _helper.Helper(HERE / "dist" / "helper.mjs", node=node, env=_helper.helper_env(),
env = _helper.helper_env()
env.pop("MCP_EVENTS_DEV", None) # The anonymous loopback mode is for the helper test harness.
helper = _helper.Helper(HERE / "dist" / "helper.mjs", node=node, env=env,
on_request=self._on_request, log_path=state / "helper-stderr.log")
try:
helper.request("initialize", {"state": str(state), "servers": servers, "skipped": skipped}, timeout=30)
Expand Down
64 changes: 32 additions & 32 deletions polyfills/events/hermes/plugin/dist/helper.mjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions polyfills/events/hermes/plugin/plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: mcp-events
version: "0.1.0"
version: "0.2.0"
description: >-
MCP Events (SEP-3415) by poll and push: watch events on your MCP servers, and an event
wakes the idle session that asked for it. Webhook delivery stays with Hermes (events: true).
MCP Events (SEP-3415) by webhook, push and poll: watch events on your MCP servers, and an event
wakes the idle session that asked for it. Servers with events: true use native Hermes delivery.
author: Ido Salomon
provides_tools:
- list_event_types
Expand Down
Loading
Loading