# MCP server

`herald-mcp` lets chat bots and agents use Herald. It works with OpenBot, OpenClaw, Hermes,
Claude Desktop, Claude Code and n8n; each has a recipe in
[`docs/integrations/README.md`](integrations/README.md).

## Tools for bots

| Tool | What it does |
|---|---|
| `herald_briefing(date?, language?, category?)` | The latest briefing, or one day's; whole or one category |
| `herald_history_search(query, days?)` | Search stories already published, in any output language; each hit has `texts`: `{language: {headline, summary}}` |
| `herald_categories()` | Every category and whether you follow it |
| `herald_follow(categories)` / `herald_unfollow(categories)` | Change what you follow (ids or groups such as `br`, `sports`) |

## Tools for agents

Tools for agents that drive a run step by step: `herald_fetch`, `herald_prefilter`,
`herald_cluster`, `herald_score`, `herald_select`, `herald_enrich`, `herald_render`, `herald_run`,
`herald_get_run` and `herald_list_runs`.

## Transports

Two transports:
- stdio (default), for a bot on the same machine: the bot starts `herald-mcp` itself;
- HTTP, for a bot elsewhere: `herald-mcp --http [--host 127.0.0.1] [--port 8765]` serves
  `http://HOST:PORT/mcp`. It refuses to start without `HERALD_MCP_TOKEN` (16+ characters, in
  `.env`), and every request must send `Authorization: Bearer <token>`. Keep it on `127.0.0.1`
  behind a reverse proxy with TLS if the bot is on another machine.

## Recipes

**OpenClaw:**

```bash
# same machine (stdio)
openclaw mcp set herald '{"command":"/path/to/herald/.venv/bin/herald-mcp",
  "env":{"HERALD_CONFIG":"/path/to/herald/config.json"}}'
# remote (HTTP); HERALD_MCP_TOKEN must be set in OpenClaw's environment
openclaw mcp set herald '{"url":"https://herald.example.com/mcp","transport":"streamable-http",
  "headers":{"Authorization":"Bearer ${HERALD_MCP_TOKEN}"}}'
openclaw mcp doctor herald --probe
```

**Hermes** (`~/.hermes/config.yaml`, then `/reload mcp`):

```yaml
mcp_servers:
  herald:
    command: "/path/to/herald/.venv/bin/herald-mcp"
    env:
      HERALD_CONFIG: "/path/to/herald/config.json"
  # or remote:
  # herald:
  #   url: "https://herald.example.com/mcp"
  #   headers:
  #     Authorization: "Bearer ${HERALD_MCP_TOKEN}"   # token in ~/.hermes/.env
```

**Claude Desktop / Claude Code:**

```json
{ "mcpServers": { "herald": { "command": "/path/to/herald/.venv/bin/herald-mcp",
  "env": { "HERALD_CONFIG": "/path/to/herald/config.json" } } } }
```

## Delivering through a bot

To deliver the briefing through a bot at a fixed time, schedule a job in the bot that calls
`herald_briefing` and sends the result to its channel. Herald's own run must finish before that
time.
