From 2a289b32e88a47e9b428e07293adb07daa37f14a Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 06:08:38 -0800 Subject: [PATCH] Document direct control protocol authentication (cherry picked from commit 9e84a049f7f96fbd769fbf29ed53291fa787539a) --- docs/control-protocol.md | 17 +++++++++++++++-- docs/mcp.md | 7 ++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 945f6e8b99..96720c6c5c 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -6,7 +6,20 @@ from 1 to 65535 (`--control=` works too), given once; otherwise the app prints an error and exits before it starts. Each connection must authenticate with the app's control token before it can send commands. The [MCP setup guide](mcp.md#connect-to-the-desktop-app) shows how to give the app and the CLI -the same token file. After authentication, send one JSON request per line: +the same token file. + +The CLI handles authentication. A direct loopback client can send this JSON line first, with the +app's 64-digit hexadecimal control token in `params.token`: + +```json +{"id":"auth","method":"auth","params":{"token":""}} +``` + +With the correct token, the app replies `{"id":"auth","ok":true,"result":{"authenticated":true}}`. +With an incorrect token, it replies `{"id":"auth","ok":false,"error":"authentication required"}` +and closes the connection. Authenticate once on each new connection. + +After authentication, send one JSON request per line: `{"id": 1, "method": "ui.inspect", "params": {}}` → `{"id": 1, "ok": true, "result": {...}}` or `{"id":1,"ok":false,"error":"..."}`. Set `VECTORCRAFT_CONFIG_DIR` to a dedicated directory for an isolated native test profile. Preferences, @@ -34,7 +47,7 @@ and returns its slot that stalls gets the usual error line first); persistent clients can send further requests within these bounds, or reconnect after idle expiration. These transport budgets are separate from the existing 60-second command-processing wait. -Transport: `apps/vectorcraft/src/control_server.rs`. +Transport: the `craft-automation` server in Craft Libs. ## Synthetic input budgets diff --git a/docs/mcp.md b/docs/mcp.md index b925380696..aa9a78acdc 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -84,9 +84,10 @@ claude mcp add vectorcraft -- vectorcraft-cli mcp ### Connect to the desktop app -The app and the MCP server need the same control token. Choose an absolute path to a token file in an -existing private directory. Start the app with that path before starting the MCP server. VectorCraft -creates the token file if it is missing and reuses a valid token already in the file. +The app and the MCP server need the same control token. Choose an absolute path for a private token +file and start the app with that path before starting the MCP server. Let VectorCraft create the file +for a new setup. If the file already exists, the app requires a valid token and rejects files that +grant access to other users. ```sh # Linux (deb, rpm). Use your private token-file path.