Control channel: a new connection has five seconds to show its token (#10961)

A client could connect and send nothing, or only blank lines, and hold one of the 16 connection
seats for as long as it liked. All reads before the token now share one five-second deadline; the
connection is then closed without a reply. An authenticated connection may idle as before.

`solidcraft-cli mcp --connect` used to open a connection at start and hold it until the first tool
call. It now only checks that the app is there, and the first call connects.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bherbruck
2026-11-02 04:23:23 +00:00
committed by GitHub
parent 5d6a80ff35
commit 21fc384e40
4 changed files with 167 additions and 11 deletions
+3 -1
View File
@@ -99,7 +99,9 @@ The first request on a connection must carry the token as a top-level `"token"`
(`{"id": 1, "method": "ui.inspect", "params": {}, "token": "…"}`); later requests on the same
connection may leave it out. A first line without the right token is answered with
`{"ok": false, "error": "unauthorized: …"}` and the connection is closed, without running
anything. Tokens are compared in constant time.
anything. Tokens are compared in constant time. A connection that hasn't sent that first request
within five seconds is closed without a reply, and blank lines don't extend the time. So connect
when you have something to send; once authenticated, a connection may stay idle.
`solidcraft-cli mcp --connect 127.0.0.1:PORT` reads the token file for that port by itself
(`--token T` or `SOLIDCRAFT_CONTROL_TOKEN` give one explicitly). For a test harness, or a