@hivemagnus/magnus-server
The Magnus server is the control plane of a Magnus fleet. It is a Hono API
server backed by PostgreSQL and Redis that Linux hosts running
@hivemagnus/magnus-agent report to. Its browser clients are
HiveXUI, the suite's UI, and the standalone
Magnus console.
It keeps the fleet inventory and desired state, ingests agent heartbeats,
health snapshots and logs, dispatches signed commands, cron jobs, file syncs
and skill installs through a durable queue, and records every change in an
append-only audit log. Optional modules add anomaly detection and remediation
plans, rollouts, webhooks, an AI fleet assistant, Hermes Agent and Ardent
management, and security observation export to Cindertrace.
Requirements
- Node.js
^24.22.3 || ^26.13.1
- PostgreSQL 15 or later
- Redis 7 or later
- A TLS certificate for production (cleartext HTTP is a loopback-only development opt-in)
Install
npm install -g @hivemagnus/magnus-server
magnus-server --help
The package ships compiled JavaScript, the generated Prisma client, the Prisma
schema and every migration, so it needs no install-time code generation.
Configure
All configuration comes from environment variables. Start from the documented
example:
mkdir -p ~/.magnus && cp "$(npm root -g)/@hivemagnus/magnus-server/.env.example" ~/.magnus/server.env
chmod 600 ~/.magnus/server.env
# fill in DATABASE_URL, REDIS_URL, TLS paths and the required secrets
# (one `openssl rand -hex 32` each; every secret must be different)
magnus-server env-schema --format table lists every documented variable and
magnus-server env-schema prints the same list as JSON.
Required: DATABASE_URL (in production), REDIS_URL, API_SECRET,
JWT_SECRET, AUDIT_HMAC_SECRET,
LOG_INGEST_SIGNING_SECRET, CREDENTIAL_ROTATION_KEY, METRICS_TOKEN,
WEBHOOK_ENCRYPTION_KEY, and in production TLS_CERT_PATH / TLS_KEY_PATH.
NODE_MANAGER_SECRET and RESULT_SIGNING_SECRET are required only under an
explicit (deprecated) NODE_AUTH_MODE=compat or warn: from 3.0.0 the server
runs in enforce mode by default and agents use their own keys
(per-node credentials). The server refuses to
start while any is missing; there are no fallback secret values.
Webhooks are refused until WEBHOOK_ALLOWED_ORIGINS lists the exact HTTPS origins
they may target, as a comma-separated list.
Local data (audit logs, credential rotation state, uploaded backups) lives
under MAGNUS_HOME, default ~/.magnus.
Run
magnus-server check --env-file ~/.magnus/server.env # validate env, reach PostgreSQL and Redis, list integrations
magnus-server migrate --env-file ~/.magnus/server.env # apply migrations and base data
magnus-server start --env-file ~/.magnus/server.env # MAGNUS_AUTO_MIGRATE=true: back up and migrate first
| Command |
Purpose |
start (default) |
Start the API server. With MAGNUS_AUTO_MIGRATE=true it first dumps the database and applies pending migrations under an advisory lock. --migrate applies them without a dump. |
check |
Validate configuration, connect to PostgreSQL and Redis, report pending migrations, available updates and enabled integrations (--format json for tooling). Exits non-zero on a problem. |
migrate |
Run prisma migrate deploy with the packaged schema and migrations, then create the base rows (system actor, sentinel nodes, starter library). Idempotent. |
verify-migrations, verify-initialization |
Check the exact packaged migration checksums (and, for the second, the committed base data) with read-only queries. Nothing is applied or repaired. |
migrations |
List applied and pending migrations with their impact (fast, slow, one-way). |
backup |
Dump PostgreSQL (pg_dump -Fc) into MAGNUS_BACKUP_DIR and print the restore command. |
restore FILE |
Replace the database with a dump (stop the server first; asks unless --yes). |
upgrade, rollback |
Upgrade or roll back the magnus init project this server was installed into (runs magnus upgrade; see UPGRADING.md). |
agents upgrade |
Upgrade agents to the version this server ships (--to, --nodes, --canary, --dry-run, --retry RUN_ID). --allow-major also moves agents of another major with a server-signed authorization (cross-major moves). |
agents doctor, agents fence, agents stop |
Read-only per-node upgrade diagnosis (--heal repairs what the server owns), move a node's fence generation up (fence NODE VALUE, audited), stop a run (stop RUN_ID). magnus-server agents --help explains each. |
node-auth server-key status\|stage\|promote\|retire |
Rotate the server signing key (rotating the server key). The command line cannot see agent pins, so promote needs --force; the ADMIN route checks them. |
env-schema |
Print the documented environment variables (--format json or table). |
version, help |
Print the version or usage. |
--env-file <path> may be repeated. Variables already set in the process
environment take precedence, and empty values count as unset.
The API is served under /api/v1, interactive documentation at /api/docs
(OpenAPI 3.1 JSON at /api/docs/openapi.json), and Prometheus metrics at
/metrics (bearer METRICS_TOKEN).
Docker Compose
docker/compose.yml runs magnus-server with PostgreSQL
and Redis. The image is built from the monorepo root with
Dockerfile: it builds and npm packs the server and its
workspace dependencies, then installs those tarballs exactly as an npm user
would.
cp services/control-api/.env.example services/control-api/docker/.env # set POSTGRES_PASSWORD, REDIS_PASSWORD and the secrets
docker compose -f services/control-api/docker/compose.yml --env-file services/control-api/docker/.env up -d --build
Compose refuses to start while a required secret is missing. The server
listens on https://127.0.0.1:4000; without a mounted certificate it
generates a self-signed one for MAGNUS_TLS_HOSTNAMES (default localhost)
in its data volume, which is meant for evaluation only. To use a real
certificate, mount it and set TLS_CERT_PATH and TLS_KEY_PATH.
bash services/control-api/scripts/check-compose.sh brings the stack up with
throwaway secrets, checks it end to end and removes it again.
Optional integrations
Every integration is off until it is configured; the server starts and runs
without any of them. magnus-server check prints which are on.