Workspace tools: keys and devices from the command line or an AI client
The npm package @huelake/connectivitizer contains a command, connectivitizer, that does what the Credentials and Devices pages of the web app do: it lists devices and keys, creates keys, and sets who may reach what. The same functions are available to an AI client as tools (Model Context Protocol). It needs Node.js 20 or later and nothing installed beforehand:
npx -y @huelake/connectivitizer helpKeys are not printed. A command that creates a key writes it into the file you name, for example the secrets.h of a sketch, and answers with the key's name and prefix. The one exception is keygen without --save, which prints the new shared key once.
Below, connectivitizer stands for npx -y @huelake/connectivitizer. To type it shorter, install the package once with npm install -g @huelake/connectivitizer.
Sign in
npx -y @huelake/connectivitizer loginThe browser opens the web app. Sign in there, compare the code on the page with the one in the terminal, pick the workspace and approve. This takes an admin of the workspace, because the program receives a key that manages it.
- The key is stored on this machine, in the state directory
czuses as well (CONNECTIVITIZER_HOME, elseconnectivitizerin your user's application data;--state <dir>chooses another). It is valid for 30 days; sign in again after that. - It appears under Credentials with the name given with
--name(default: "Connectivitizer tools") and can be revoked there at any time. - It can create and change keys and devices and open sessions. It cannot create further keys that manage the workspace, and it cannot invite or remove members.
connectivitizer logoutremoves it from the machine.connectivitizer statussays whether a sign-in exists and for which workspace.
On a machine without a browser, set CONNECTIVITIZER_NO_BROWSER=1: the command prints the address and the code, and the page can be opened on any other machine.
Commands
connectivitizer devices # name, online, services, the key each device logs in with
connectivitizer device lamp # one device
connectivitizer device lamp --alias "Lamp in the hall"
connectivitizer device lamp --allow Boards,Dashboard # only these keys may connect; --allow-all lifts it
connectivitizer keys # without their secrets
connectivitizer key create Boards --device --save include/secrets.h:DEVICE_KEY
connectivitizer key create Lamps --device --sessions --reach cabin/api,lamp --save pi/secrets.json:deviceKey
connectivitizer key create Dashboard --app --save .env:CZ_API_KEY
connectivitizer key update Boards --sessions on # its devices may open sessions to other devices
connectivitizer key update Boards --reach cabin/api # ... but only to the service "api" of "cabin"
connectivitizer keygen --save include/secrets.h:SHARED_KEY --save app/.env:CZ_SHARED_KEY
connectivitizer secret copy include/secrets.h:SHARED_KEY ../other/secrets.json:sharedKey
connectivitizer sessions --device lamp --failed # why a connection did not workAnswers are JSON. A device is named by its name, alias or id; a key by its name or its prefix (czd_1c25660e1a).
Where a key is written depends on the file's ending: .h gets #define NAME "…", .json a property, .ps1 a variable, everything else a line NAME=…. A value of that name is replaced, the rest of the file stays as it is, and a missing file is created. The answer warns when the file is inside a git repository that does not ignore it.
The three kinds of key:
| Key | Made with | What it is |
|---|---|---|
Device key czd_… | key create … --device | What a device logs in with. With --sessions its devices may also open sessions to other devices, within --reach. |
API key czk_… | key create … --app | What a program that opens sessions to devices authenticates with. |
Shared key czs_… | keygen | The end-to-end secret both ends of a session hold. It is made on this machine and never sent to the platform, so the workspace does not list it. |
Keys and devices are not revoked or deleted with this command. That is done in the web app.
For an AI client (MCP)
connectivitizer mcp serves the same functions as tools over standard input and output. Register it in the client as a local server:
{
"mcpServers": {
"connectivitizer": {
"command": "npx",
"args": ["-y", "@huelake/connectivitizer", "mcp"]
}
}
}In Claude Code the same is claude mcp add connectivitizer -- npx -y @huelake/connectivitizer mcp.
The first time, the client calls sign_in: the browser opens, you approve as above, and the client continues. From then on it can, for example, create the device key for a new sketch directly into its secrets.h, switch on that a key's devices may call other devices, or look up why a session failed.
| Tool | What it does |
|---|---|
sign_in, status, sign_out | The sign-in through the browser, as login above. |
list_devices, update_device | Devices with their services and keys; alias and allowed keys of a device. |
list_keys, create_device_key, create_api_key, update_key | Keys without their secrets; new keys go to the files named in saveTo. |
create_shared_key, copy_secret | A shared key into every file that needs it; a key from one secrets file into another. |
list_sessions | Recent sessions with mode and the reason of a failure. |
What the client sees and does not see:
- No tool returns a key. The client learns names, prefixes and file paths.
- The client can read files of the project like any other, including a secrets file a key was written to. Whether it may is a setting of the client, not of Connectivitizer.
- The tools change the workspace with an admin's rights, within the limits named under "Sign in". Approve tool calls in the client as you would approve shell commands.