Self-hosting agility-bridge
agility-bridge serve(v0.2): one server for several teams and devices, each workspace athttps://<host>/w/<slug>/mcp, next to a hosted or an on-premises Agility instance. See also: access model, secrets, CLI, configuration, audit log, devices.Want the whole path in one page, with sign-in and the admin panel? Follow the remote quickstart; day-to-day administration is in the admin guide.
The blocks marked for the walkthrough run in CI on a fresh machine from the package built from this repository (
scripts/walkthrough.ts, L-133), so they stay correct.
What you need
Section titled “What you need”- A Linux, macOS or Windows host with Node 24 (or Docker), reachable by your users over HTTPS through a reverse proxy (Caddy, nginx, Traefik, a cloud load balancer).
- An Agility instance it can reach, and an Agility access token per member (or a service member’s token for shared, read-only access).
- A place for the master key that is not the data directory or its backups (secrets).
Install (Node)
Section titled “Install (Node)”npm install -g agility-bridgeagility-bridge initagility-bridge admin-token > ~/.config/agility-bridge/admin.tokenchmod 600 ~/.config/agility-bridge/admin.tokeninit writes a new master key to ~/.config/agility-bridge/master.key. admin-token prints the break-glass token
that turns on the admin API; keep both files readable only by the server’s user.
Then create the first instance, credential, workspace, grant and device token with the CLI first setup: it works on the local database before the server ever starts.
Run the server
Section titled “Run the server”AB_MASTER_KEY_FILE=~/.config/agility-bridge/master.key AB_ADMIN_TOKEN_FILE=~/.config/agility-bridge/admin.token agility-bridge serveIt listens on 127.0.0.1:8787 (AB_HOST, AB_PORT), stores its database in ~/.local/share/agility-bridge
(AB_DATA_DIR or AB_DB_PATH, created 0700/0600) and logs JSON lines to stderr. Check it:
curl -s http://127.0.0.1:8787/healthFor a service, run it with your init system. A systemd unit, for example:
[Unit]Description=agility-bridgeAfter=network-online.target
[Service]User=agility-bridgeEnvironment=AB_MASTER_KEY_FILE=/etc/agility-bridge/master.keyEnvironment=AB_ADMIN_TOKEN_FILE=/etc/agility-bridge/admin.tokenEnvironment=AB_DATA_DIR=/var/lib/agility-bridgeEnvironment=AB_PUBLIC_URL=https://mcp.example.comExecStart=/usr/bin/agility-bridge serveRestart=on-failureNoNewPrivileges=trueProtectSystem=strictReadWritePaths=/var/lib/agility-bridgePrivateTmp=true
[Install]WantedBy=multi-user.targetBehind a reverse proxy (HTTPS)
Section titled “Behind a reverse proxy (HTTPS)”Terminate TLS at the proxy and forward to 127.0.0.1:8787. Then tell the server its public address:
AB_PUBLIC_URL=https://mcp.example.com: the server answers requests for that host, and sendsStrict-Transport-Securityon every response (also errors) because the public URL is HTTPS, even though it sees plain HTTP from the proxy (L-083).AB_ALLOWED_HOSTS: any other host name it should answer (comma-separated). Requests for unknownHostnames are refused, which blocks DNS-rebinding attacks; so isOrigin: null.AB_ALLOWED_ORIGINS: browser origins allowed to call it (with CORS headers). MCP clients are not browsers and need none.AB_TRUSTED_PROXY_HOPS=1when exactly one proxy sits in front, so rate limits see the client address fromX-Forwarded-For. Never set it without a proxy: clients could then choose their own address.- Let responses stream (no buffering): MCP answers can take up to the server’s 180-second deadline.
Caddy (reverse_proxy 127.0.0.1:8787 { flush_interval -1 }) does all of this with automatic certificates; for nginx:
location / { proxy_pass http://127.0.0.1:8787; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_buffering off; proxy_read_timeout 190s;}Then connect each device to https://mcp.example.com/w/<slug>/mcp with its own token (devices). A
device token works only at its own workspace’s address. Check one from the command line:
curl -s https://mcp.example.com/w/team-mobile/mcp -H "Authorization: Bearer $DEVICE_TOKEN" -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'On-premises Agility with a private CA
Section titled “On-premises Agility with a private CA”The server verifies the instance’s TLS certificate, always. For an instance whose certificate comes from your own CA, give that instance the CA bundle (PEM) when you add it — it is added to the public roots for that instance only:
agility-bridge instance add "On-prem" https://agility.corp.example/Agility --ca-file /etc/agility-bridge/corp-ca.pemThe instance must use HTTPS (http:// is accepted only for loopback test fixtures with AB_ALLOW_HTTP_INSTANCES=on).
If the server should never reach your private networks through an instance address, set
AB_INSTANCE_PRIVATE_ADDRESSES=refuse (configuration); leave it
at allow when the instance itself is on a private network.
The server probes a new address without any token before using it, and validates every stored token against it (access model). The Cloudflare Worker deployment cannot trust private CAs; use this server for such instances.
Pass-through workspaces (optional)
Section titled “Pass-through workspaces (optional)”For a simple shared server that stores no Agility tokens: with AB_PASSTHROUGH=on, an owner can make a workspace
pass-through (agility-bridge workspace set <workspace-id> --credential-source passthrough). Its callers send their
own Agility access token in the X-Agility-Token header instead of a device token, on the workspace’s normal address.
- HTTPS only: the server refuses the header on a plain-HTTP request (behind a proxy, it trusts
X-Forwarded-Proto: httpsonly withAB_TRUSTED_PROXY_HOPS). - The token is checked against the workspace’s instance (the member behind it), then trusted for 5 minutes by its
keyed fingerprint (HMAC); the token itself is never stored or logged. The audit log and the rate limits identify
callers by that fingerprint (
pt:…). Checking a new token costs Agility requests, so the server checks at mostAB_RATE_LIMIT_VALIDATIONS_PER_MINUTEnew tokens per instance (30), shares one check between concurrent requests with the same token, and stops checking for a client address that has used up its failed attempts. - Every workspace control applies unchanged: Agility projects, asset types, tools, limits, rate limits. There are no grants, and never write tools (read-only in 1.0, D-04).
- Anyone with a valid token for the instance and network access to the server can use such a workspace: keep it on a private network, and prefer per-user grants with device tokens when you need to know who is who.
Public tool catalogue (optional)
Section titled “Public tool catalogue (optional)”AB_PUBLIC_TOOL_CATALOG=on lets a client or a registry see which tools the server has before anyone signs in. A request to
/w/{slug}/mcp with no Authorization and no X-Agility-Token header may send initialize, ping, server/discover,
tools/list and notifications/initialized; the server answers from a static list and reads no storage. It is off by default
and it is safe by construction:
- The list is the read-only tools of the default groups (the same list an unconfigured stdio server shows), whatever the workspace. Write tools, reports and attachments are never in it, so it does not say whether your deployment offers them.
- The answer does not depend on the workspace name in the URL: a real, an unknown, a disabled and a malformed name get the same bytes, so it cannot be used to find out which workspaces exist.
- Everything else,
tools/call, prompts, resources and any request that presents a credential, valid or not, is401as before. The per-address request limit still applies. - It advertises no extension:
server/discoverlists the Tasks extension only to callers who signed in, so an anonymous caller cannot learn that deployment flag. initialize,server/discoverandtools/list(about 38 KB) are built once per process or Worker isolate and then served from memory with only the JSON-RPCidreplaced, byte for byte what a fresh build gives (P8-35). They are counted apart from signed-in requests (catalog: builtorcachedon the request event the observers get). A POST answer is not cacheable by browsers or the Cache API, so noCache-Controlis added; the address limiter is still the brake on the number of requests.- Tool descriptions are public documentation (they are in this repository), so listing them reveals nothing about your Agility instance or your people.
Docker
Section titled “Docker”The image runs agility-bridge serve as the non-root user 65532 on distroless Node 24, with a read-only root
filesystem and the database on the /data volume. It listens on port 8787 of the container (AB_HOST=0.0.0.0 inside
the image) and has a built-in healthcheck (GET /health). CI builds it, runs a smoke test against a synthetic Agility
and scans it on every change (scripts/docker-smoke.ts).
Releases from v0.2 publish it as ghcr.io/mhidalgo-lab/agility-bridge:<version> (also :<major.minor> and
:latest), with provenance and SBOM attestations; verify it and pin its digest.
To build it from a checkout instead:
docker build -f docker/Dockerfile -t agility-bridge:local .With Docker Compose and Caddy
Section titled “With Docker Compose and Caddy”docker/compose.yaml runs the published image (pinned by digest) behind
Caddy, which gets and renews the TLS certificate:
-
Set your host name in
docker/Caddyfileand inAB_PUBLIC_URLin the compose file. -
Create the secrets outside the data volume (a backup of the volume must never hold the key):
Terminal window cd docker && mkdir -p secretsagility-bridge init --key-file ./secrets/master.keyagility-bridge admin-token > ./secrets/admin.tokensudo chown 65532:65532 ./secrets/* && chmod 600 ./secrets/*The files must be readable only by their owner, uid
65532in the container; the server refuses anything looser. -
Start it:
docker compose up -d, then follow the CLI first setup remotely withAB_ADMIN_URL=https://<host>andAB_ADMIN_TOKEN_FILE=./secrets/admin.token.
The compose file also drops every capability and sets no-new-privileges.
Plain docker run
Section titled “Plain docker run”docker run -d --name agility-bridge --read-only --tmpfs /tmp -p 127.0.0.1:8787:8787 \ -v agility-bridge-data:/data \ -v "$PWD/secrets/master.key:/run/secrets/master.key:ro" -e AB_MASTER_KEY_FILE=/run/secrets/master.key \ -e AB_PUBLIC_URL=https://mcp.example.com \ ghcr.io/mhidalgo-lab/agility-bridge:0.2.0Publish the port on 127.0.0.1 and put the TLS proxy in front.
Backups and the master key
Section titled “Backups and the master key”- Database:
agility-bridge backup <new file>writes a consistent copy while the server runs (mode0600, never overwriting); run it on the server host as the server’s user, e.g. daily from cron. In Docker:docker exec agility-bridge /nodejs/bin/node /app/dist/index.mjs backup /data/backup-$(date +%F).db, then copy it out of the volume. - Master key: back it up separately (a password manager, a secret store). Whoever has a backup and the key can read every stored Agility token. Without the key, a backup’s tokens are lost: members enter them again.
- Restore: stop the server,
agility-bridge restore <backup> <new database file>(it checks the backup and never overwrites), pointAB_DB_PATHat the new file, start the server.
Upgrades
Section titled “Upgrades”agility-bridge backup <file>first.- Install the new version (
npm install -g agility-bridge@<version>, or a new image) and restart. The server migrates its database on start; a database written by a newer version is refused, so you can roll back by restoring the backup with the older version. - Clients cache the tool list: reconnect them (or restart their MCP server) to see new tools (L-012).
- Read the release notes for new settings; unknown
AB_settings stop the server, so typos are caught at start.
agility-bridge is an unofficial, community project. It is not affiliated with, endorsed by, or supported by Digital.ai. Digital.ai, Agility and VersionOne are trademarks of their respective owners.