diff --git a/nix/module.nix b/nix/module.nix index 8049e53..ac32ecb 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -863,10 +863,16 @@ in { Mint a token with `hhstream-mcp token mint`, run as {option}`sessions.user`, and give it to the client as an - `Authorization: Bearer …` header. **The unit refuses to start while - the table is empty**, because a listener that 401s every request is - almost always a forgotten mint; `--allow-no-tokens` is the escape - hatch for provisioning. + `Authorization: Bearer …` header. + + **The unit refuses to start while the table is empty**, because a + listener that 401s every request is almost always a forgotten mint, + and "connection works, auth fails" is far worse to debug than a + `systemctl status` that names the remedy. It retries every five + seconds rather than giving up, so it comes up on its own within one + interval of the first `token mint` — no `systemctl start` needed. + Pass `--allow-no-tokens` through {option}`mcp.http.extraArgs` to + start anyway. Not MCP's authorization specification, which is OAuth 2.1 plus RFC 9728 metadata discovery. A client that can only *discover* an @@ -1531,7 +1537,24 @@ in { UMask = "0077"; Restart = "on-failure"; - RestartSec = 2; + RestartSec = 5; + # No start-rate limit, which is what makes the empty-table refusal + # usable rather than merely correct. + # + # The server exits 2 while no token exists, because a listener that + # 401s every request is almost always a forgotten `token mint` and + # "connection works, auth fails" is a far worse thing to debug than a + # unit whose `systemctl status` names the remedy. But that puts a + # freshly provisioned machine in a failed state until an operator acts, + # and systemd's default (5 starts in 10s, then give up) would leave it + # there for good -- so minting the first token would also need a + # `systemctl start` nothing told anyone about. + # + # With the limit off, the unit retries every 5 seconds and comes up on + # its own within one interval of the first mint. The cost is a journal + # line every 5 seconds while the table is empty, which names exactly + # what is wrong. + StartLimitIntervalSec = 0; NoNewPrivileges = true; # This unit launches nothing and adopts nothing: it is a listener in