hyperhive/hive-matrix-mcp
Repository files (latest commit first)
Filename Latest commit message Latest commit date
atlas c74249f371 matrix: make the hive-internal main account an ordinary matrixAccounts entry
`matrixAccounts` is meant to be the agent's full account list, but the
hive-internal `main` account was outside it: the nix module emitted only
the extras and `hive-matrix-daemon` prepended a `main` it synthesized
from the per-agent paths, with the option schema forbidding the name
outright.

nix/agent-modules/matrix.nix now declares `main` itself, as an ordinary
entry under `matrix.enable`, from the state-dir paths the module already
used for its token path-watcher (now a shared `stateDir` binding) plus
`matrix.url`. The whole set, `main` included, is serialized to
HIVE_MATRIX_ACCOUNTS.

accounts::configured therefore synthesizes `main` only when the parsed
list carries none, and otherwise takes the declared one verbatim —
hoisting it to index 0, since the daemon reads index 0 as the primary
and nix serializes an attrset, so `main` sorts wherever its key falls.
Declared xor synthesized: an agent whose harness predates this entry
keeps working, a current one gets its own, and there is no arrangement
where `main` is duplicated or missing.

The reserved-name assertion is replaced rather than dropped: the name
must now be legal (the module uses it), but `main`'s tokenFile stays
pinned to `<state>/matrix-token`, since hive-c0re provisions the
hive-internal token there and nowhere else — a retarget would evaluate
fine and then never restore. The other two fields are mkDefault and free
to override.

Refs #4475
2026-09-18 09:34:44 +02:00
..
src matrix: make the hive-internal main account an ordinary matrixAccounts entry 2026-09-18 09:34:44 +02:00
Cargo.toml refactor(sock): one socket client, retry as a policy value 2026-07-26 22:44:48 +02:00
README.md feat(#2659): serve hive-matrix-mcp over persistent streamable-http, drop stdio bridge 2026-07-24 12:44:39 +02:00

hive-matrix-mcp

Per-agent matrix integration: a long-running daemon (hive-matrix-daemon) that holds a matrix-sdk Client + sync loop per configured account and serves the matrix tool surface (send_message, send_dm, list_rooms, read_room, …) directly over streamable-http. No stdio bridge, no per-turn respawn — claude reconnects to the same stable URL every turn.

When to use it

Look here when changing matrix tool behaviour, multi-account handling, or the incoming-event → todo/wake path. The daemon owns the whole lifecycle: per-account bring-up (accounts.rs, client.rs), the sync loop that sweeps invites/unread rooms into the harness's in-agent todo socket (timeline.rs, wake.rs), and the MCP tool router itself (mcp.rs).

Shape

One bin (hive-matrix-daemon, src/main.rs) built from the crate's own lib (src/lib.rs):

  • accounts.rs — multi-account config + the account→Client dispatch registry (main is always the hive-internal primary; extras come from HIVE_MATRIX_ACCOUNTS).
  • client.rs — session restore, stale-token recovery, avatar sync, cross-signing bootstrap.
  • timeline.rs / wake.rs — per-sync-callback invite/unread sweeps that push todos onto HIVE_AGENT_SOCKET.
  • handlers.rs — per-tool dispatch, returns protocol::DaemonResponse.
  • mcp.rs — the rmcp tool router + serve_http, resolving each call's optional account arg against the registry before calling into handlers.
  • paths.rs — per-agent path resolution (token file, matrix-sdk state dir, homeserver URL, accounts snapshot).