# Hermes Agent (Nous Research)

<!-- description: Connect Herald to Hermes Agent: read the briefing over MCP in any chat, deliver it on a schedule, or push each new briefing to a Hermes webhook route. -->

Status: **documented** (follows the official docs; not yet run against a real install).

Official docs used:
[MCP](https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp),
[MCP config reference](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/reference/mcp-config-reference.md),
[webhooks](https://hermes-agent.nousresearch.com/docs/user-guide/messaging/webhooks),
[cron](https://hermes-agent.nousresearch.com/docs/user-guide/features/cron).

## What you get

- **Pull:** Hermes reads today's briefing, one category of it, or past stories, and can change
  what you follow, in any chat it is connected to.
- **Pull on a schedule:** a Hermes cron job asks for the briefing at a fixed time and delivers it
  to Telegram, Discord or another channel.
- **Push:** when Herald publishes, it POSTs to a Hermes webhook route; Hermes turns the event into
  a prompt and delivers the answer.

## Pull: MCP

Servers go under `mcp_servers` in `~/.hermes/config.yaml`. Reload with `/reload mcp` (a running
gateway also picks up changes to the file within about a minute).

**Same machine (stdio):**

```yaml
mcp_servers:
  herald:
    command: "/path/to/herald/.venv/bin/herald-mcp"
    env:
      HERALD_CONFIG: "/path/to/herald/config.json"
    tools:
      include: [herald_briefing, herald_categories, herald_history_search]
```

**Another machine (streamable HTTP).** Run `uv run herald-mcp --http` next to Herald (see the
[index](README.md#common-ground)) and put `HERALD_MCP_TOKEN` in `~/.hermes/.env`. A server with a
`url` uses streamable HTTP by default:

```yaml
mcp_servers:
  herald:
    url: "https://herald.example.com/mcp"
    headers:
      Authorization: "Bearer ${HERALD_MCP_TOKEN}"
    tools:
      include: [herald_briefing, herald_categories, herald_history_search]
```

If `HERALD_MCP_TOKEN` is unset, Hermes refuses to connect and names the variable.

**Tools to allow.** `tools.include` above keeps it read-only. Add `herald_follow` and
`herald_unfollow` when Hermes may change what you follow.

**Daily delivery without a webhook.** Schedule a job that calls the tool after Herald's run has
finished:

```bash
hermes cron create "30 7 * * *" "Call herald_briefing and send me the five items that matter most, one line each, with links." --name "Herald" --timezone "America/Sao_Paulo"
```

Delivery targets include `origin`, `telegram`, `telegram:<chat_id>` and `discord:#channel`; the
exact CLI flag for the target varies, so check your version's cron docs. Jobs fire only while the
gateway runs.

## Push: webhook

Herald signs with [Standard Webhooks](https://www.standardwebhooks.com/) (`webhook-id`,
`webhook-timestamp`, `webhook-signature`), one of the schemes Hermes checks.

**1. Create a signing secret.** Standard Webhooks secrets are `whsec_` plus base64. Hermes
base64-decodes a `whsec_` secret and Herald does the same, so both sides use the same key:

```bash
echo "whsec_$(openssl rand -base64 32)"
```

**2. Enable the webhook adapter** in `~/.hermes/.env`, with that value as the secret:

```bash
WEBHOOK_ENABLED=true
WEBHOOK_PORT=8644
WEBHOOK_SECRET=<the whsec_... value from step 1>
```

**3. Add a route** for Herald in `~/.hermes/config.yaml`. The route URL is
`http://HOST:8644/webhooks/herald`. `prompt` is a template over the JSON body (`{data.title}`
reads `data.title` from Herald's envelope), `deliver` picks where the answer goes, and
`signature: generic` pins the route to signed requests (generic HMAC or Standard Webhooks), so
a static token is rejected:

```yaml
platforms:
  webhook:
    enabled: true
    extra:
      routes:
        herald:
          signature: "generic"
          prompt: "Herald published {data.title} ({data.story_count} stories). Pick the five items that matter most for me, one line each, with links:\n\n{data.markdown}"
          deliver: "telegram"
```

The route uses `WEBHOOK_SECRET` as its secret. Hermes refuses to start a route without one; a
route-level `secret:` overrides it.

**4. Point Herald at the route.** In Herald's `.env`:
`HERMES_WEBHOOK_URL=http://127.0.0.1:8644/webhooks/herald` and `HERMES_WEBHOOK_SECRET` (the same
`whsec_` value as `WEBHOOK_SECRET`). Hermes rejects bodies over 1 MB, so cap Herald there too:

<!-- herald-config -->
```json
{
  "type": "webhook",
  "enabled": true,
  "name": "hermes",
  "languages": ["en"],
  "url": "${HERMES_WEBHOOK_URL}",
  "auth": { "type": "standard-webhooks", "secret": "${HERMES_WEBHOOK_SECRET}" },
  "events": ["briefing.published"],
  "format": "full",
  "max_body_bytes": 1048576
}
```

A briefing rarely comes near 1 MB. If one does, Herald sends the `markdown` format instead
(`{id, type, title, markdown}`, cut at a section boundary), so the `{data.*}` fields are missing
from the prompt for that delivery; `{markdown}` holds the text.

Hermes checks the timestamp within ±5 minutes, so keep both clocks in sync (NTP).

## Troubleshooting

| Symptom | Cause |
|---|---|
| `/reload mcp` reports a connection error | `herald-mcp --http` not running, URL not ending in `/mcp`, or `HERALD_MCP_TOKEN` missing from `~/.hermes/.env` |
| Herald tools missing in chat | a name in `tools.include` is misspelled, so nothing matches |
| Run report: `webhook:hermes HTTP 404` | Hermes answers 404 both for an unknown route and for a bad signature: check the route name, that both secrets are the same `whsec_` value, and both clocks |
| `HTTP 413` | body over Hermes' `max_body_bytes` (1 MB by default); set Herald's `max_body_bytes` to the same value |
| `HTTP 429` | more than 30 requests a minute on the route; Herald retries with backoff |
| The agent answers but nothing arrives | `deliver` defaults to `log`; set it to your channel |
| The prompt is cut | keep the prompt to the fields you need; `{__raw__}` (the whole body) is capped at 4000 characters |

The webhook agent gets only a small default tool set (web search, extract, vision, clarify), not
the Herald MCP tools; the briefing is already in the payload.

## Testing without Hermes

The sink checks Standard Webhooks signatures with the same secret:

```bash
uv run herald dev sink --port 8787 --standard-webhooks-secret "$HERMES_WEBHOOK_SECRET" --out herald-sink
# HERMES_WEBHOOK_URL=http://127.0.0.1:8787/ in .env
uv run herald --data-dir /tmp/herald-try run --hours 6
```

It verifies the signature (timing-safe, ±5 minutes), validates the envelope and saves it as
`herald-sink/evt_<id>.json`. A saved body cannot be replayed to Hermes with `curl`: the signature
covers the timestamp and expires after five minutes. Point Herald at Hermes and run again instead.
