Deployment
Run the Neurouter MCP gateway in production on Docker or Kubernetes with Helm, with PostgreSQL and pgvector, generated encryption keys, zero-downtime key rotation and backups.
Neurouter is one container. Run it with Docker on a single host, or on Kubernetes with the bundled Helm chart. Production needs PostgreSQL, an OpenID Connect identity provider, an https public URL and three secrets.
Container image
The image is a multi-stage build on node:26-bookworm-slim (glibc, because the ONNX runtime and sqlite-vec prebuilds target glibc). It runs as the non-root node user, listens on port 3000, has a health check on /healthz, and bakes the embedding model in so it needs no network access for models.
docker buildx build --platform linux/amd64,linux/arm64 -t <registry>/neurouter:<tag> --push .
Health endpoints: GET /healthz (liveness, alias /health) and GET /readyz (database and audit store ready).
PostgreSQL
- PostgreSQL 16 or newer with the
vectorextension. The migration runsCREATE EXTENSION IF NOT EXISTS vectorand fails with a clear message if the database role lacks the privilege. - PostgreSQL is required for more than one replica: SQLite is single-process. Replicas coordinate through PostgreSQL (LISTEN/NOTIFY, advisory locks and leases), so rate limits, approvals and caches are shared and no Redis is needed.
- Optionally put the audit log, sessions and metric rollups in a separate database with
AUDIT_DATABASE_URL. - Migrations are forward-only and additive in production, so old and new versions can run side by side during a rolling update.
Kubernetes with Helm
Create the secrets, then install the chart from deploy/helm/neurouter:
kubectl create secret generic neurouter-crypto \
--from-literal=NEUROUTER_MASTER_KEYS='k1:…' \
--from-literal=NEUROUTER_ACTIVE_KEY_ID=k1 \
--from-literal=HASH_PEPPER='…'
kubectl create secret generic neurouter-db --from-literal=DATABASE_URL='postgres://…'
helm install neurouter deploy/helm/neurouter \
--set image.repository=<registry>/neurouter --set image.tag=<tag> \
--set publicUrl=https://mcp.example.com \
--set crypto.existingSecret=neurouter-crypto \
--set database.existingSecret=neurouter-db \
--set oidc.issuer=https://idp.example.com \
--set oidc.clientId=neurouter \
--set oidc.existingSecret=neurouter-oidc \
--set ingress.enabled=true --set ingress.host=mcp.example.com
The neurouter-oidc secret holds OIDC_CLIENT_SECRET.
Chart defaults:
- 2 replicas,
RollingUpdatewithmaxUnavailable: 0, and a PodDisruptionBudget. - Non-root, read-only root filesystem with an
emptyDiron/tmp. migrations.mode=job: a pre-install/pre-upgrade Job migrates and the pods skip it. SetonStartto let every pod migrate under a database lock instead.terminationGracePeriodSecondsisapprovals.maxTimeoutSec + 30(default 900 + 30), so calls held for human approval can finish during a rollout. Keepapprovals.maxTimeoutSecat least as large as the maximum approval timeout in the gateway settings.- Optional:
metrics.serviceMonitor.enabled,autoscaling.enabled,networkPolicy.enabled(cloud metadata endpoints are always denied),archive.urlfor audit retention archives,otel.enabled.
Ingress: /mcp (calls held for approval) and /api/approvals/stream use server-sent events, so they need proxy buffering off and long read timeouts. The chart's NGINX ingress annotations set both.
Keys and rotation
| Variable | Protects | Rotation |
|---|---|---|
NEUROUTER_MASTER_KEYS | Key-encryption keys (KEKs) that wrap the data keys encrypting upstream credentials, upstream OAuth tokens and the audit checkpoint MAC key | Supported, no downtime |
NEUROUTER_ACTIVE_KEY_ID | Which KEK wraps new data keys | — |
HASH_PEPPER | HMAC pepper for API keys and OAuth tokens | Changing it invalidates every API key and token |
npm run keys -- gen [keyId] prints fresh values. Store them in your secret manager and back them up: without the KEKs, stored credentials can't be decrypted, and without the pepper no API key works.
Rotating a KEK without downtime:
- Generate a new key (
npm run keys -- gen k2) and append it:NEUROUTER_MASTER_KEYS=k1:…,k2:…. SetNEUROUTER_ACTIVE_KEY_ID=k2and roll the deployment. - As an admin,
POST /api/system/keys/rotatewith{"type":"rewrap"}to rewrap every data key underk2. PollGET /api/jobs/:id; the result'skekIdsInUselists the KEKs still referenced. - When
k1is no longer inkekIdsInUse, remove it fromNEUROUTER_MASTER_KEYSand roll again.
Rotating the data key: POST /api/system/keys/rotate with {"type":"dek"} creates a new data key, re-encrypts every secret under it and deletes retired data keys nothing references. Both jobs are also available in Settings → Gateway settings.
Backup and restore
- What to back up: the main database, the audit database if
AUDIT_DATABASE_URLis separate, and the crypto secret. A database backup without the keys can't decrypt upstream credentials; the keys without the database are useless. - PostgreSQL:
pg_dump -Fc "$DATABASE_URL" > neurouter.dump(and the same for the audit database). Restore into an empty database withpg_restore, start Neurouter with the same key values, then run an audit verification. - SQLite: stop the server (or use
sqlite3 neurouter.db ".backup backup.db"while it runs) and copy the file. - Audit retention archives (
AUDIT_ARCHIVE_URL) are written before rows are deleted; keep them under the same retention policy as your backups. - Restore a backup taken by the same or an older version, then let the newer version migrate it.