Skip to main content

SET UP A SERVE FEDERATION HUB

This guide makes one swamp serve the hub that other serves join, so you can see them all from one place.

Note

Preview. Serve federation is a preview feature: no flag turns it on, and its commands and the serve-hub app may change in later releases. Every serve and every CLI that uses it must run Swamp 20261129.160739.0 or later.

Prerequisites

Move serve.yaml to version 2

Serve federation needs version 2 on the hub. Follow Move serve.yaml to Version 2.

Make the serve a hub

Add a federation block to the hub's serve.yaml:

version: 2
port: 19600
auth:
  mode: token
  admins:
    - user:paul
federation:
  role: hub
  name: central

name is the hub's own member name and defaults to hub. It follows the member name rules: letters, digits, - and _, at most 64 characters.

Restart serve. federation is read only at startup: swamp serve reload reports it under needsRestart instead of applying it.

Grant access

Serve federation is authorized on access:swamp/federation:

Action Allows
read swamp serve member list and get, and the serve-hub app
admin Minting, listing and revoking join tokens; removing members

Grant admin to whoever mints tokens and read to whoever watches the hub. See Manage Access Grants and Authorization.

Mint a join token for each member

Each member joins with its own single-use token, minted for the name it will join as. On the hub:

swamp serve member token create edge-1
Join token: edge-1
Expires: 2026-11-30T00:48:57.982Z

  edge-1.<secret>

This token is shown once and will not be displayed again; the hub keeps only its hash.
Give it to the member's operator; it joins once, as the name it was minted for.

To mint from another machine, run the same command against the hub with --server and a token that holds admin on access:swamp/federation:

swamp serve member token create edge-2 --duration 2h \
  --server wss://hub.example.com --token '<admin-token>'
  • A token expires after one hour by default. --duration takes up to 30d.
  • A token joins once. A used, expired or revoked token is refused.
  • Creating a token again for the same name replaces its unused token.
  • swamp serve member token list shows each token's state: unused, used, expired or revoked.

Hand the token over

The plaintext is printed once. Give it to the member as a file the member's serve can read, never on a command line or in a chat message. On the member host, save it with owner-only permissions:

(umask 077; cat > join-token.txt)

Paste the token, then press Ctrl-D. To withdraw a token before it is used:

swamp serve member token revoke edge-1

Only an unused token can be revoked.

Verify

swamp serve member list
NAME     ROLE  STATUS  LAST SEEN  INSTANCES  SWAMP                           JOINED
central  hub   online  10s ago    1          20261129.213627.0-sha.b1e10d9f  2026-11-29T23:49:17.433Z

The hub lists itself. Members appear once they join.

Next steps