Output for programs
These flags work on every command:
With
--json, a REST command prints the body of the response as the server sent it, and an MCP command prints the structuredContent of the tool’s answer. An error looks like this:
code is the server’s own code when it sent one (the error codes of the API) and the CLI’s otherwise, such as USAGE_ERROR. status, requestId, retryAfter, details and hint are there when there is something to say. Quote the requestId to support.
Exit codes
A script reads the exit code before it reads anything else.
A workspace without a plan is refused with
3 over REST and with 5 from an MCP tool: see When the workspace has no plan.
Retries and idempotency
The CLI tries a call at most three times, waiting half a second and then a second and a half between tries. What it repeats depends on what the first try could have done.- A
429is always waited out. The server refused the call before it did anything. ARetry-Afterof up to 30 seconds is honoured. A longer one is reported at once, with exit code6. - A lost answer is repeated only when repeating cannot do anything twice. A dropped connection, a timeout, a
502, a503or a504may have been carried out and lost on the way, so the CLI repeats the call only when it reads, or when it carries an idempotency key. An MCP tool is repeated when it only reads or when its contract says that repeating it changes nothing more. A tool that starts a build is not repeated. - Everything else is returned at once. A
400, a401or a404would answer the same again.
--idempotency-key. The CLI makes a key when you leave it out and sends the same one on every try. Give your own, a UUID is ideal, to repeat the call by hand later, for instance after a script was cut off:
--json.
Wait for a build
create-widget and revise-widget answer at once with the widget’s widget_id and the phase it is in, and the build goes on in the background. (replicate-widget builds nothing: it offers the copy the browser extension stored, so there is nothing to wait for.) Add --wait and the command keeps asking get_widget every 7 seconds until the build has ended, then prints the finished widget:
Without
--json, the CLI prints each new phase as Widget <widget-id>: <phase> on standard error.
A build that starts is charged a credit, so do not run a build command again just because it failed or timed out. Run widgetic mcp list-widgets first: the widget may exist already.
GitHub Actions
This workflow builds a widget from a brief that you type in when you start it, publishes it and prints the embed code. The key comes from a secret, and the workflow holds every change to the workspace you mean.WIDGETIC_API_KEYis the full access key thatwidgetic mcpneeds. Make it in the workspace you mean and keep it in the repository’s secrets.WIDGETIC_WORKSPACEmakescreate-widgetrefuse the call, and change nothing, if the key works in another workspace. See Which workspace a change goes to.- The brief goes in through an environment variable (
$BRIEF) and not into the script text, so nothing a person types can run as a command. - GitHub Actions sets
CI, so the CLI never looks for a newer version or asks about one. - A build that finishes but cannot publish, because the plan does not include publishing or because the publish did not finish, has no
composition_id. Thenotesays why, and the job fails with it.
WIDGETIC_API_KEY, install the CLI with npm at a version you pinned, and read the exit code.