> ## Documentation Index
> Fetch the complete documentation index at: https://docs.widgetic.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Where the CLI finds your API key, the profiles and environment variables it reads, the files it keeps, how to check the setup and how it updates itself.

## Where the CLI finds the key

A command that needs a key uses, in this order:

1. **`WIDGETIC_API_KEY`** in the environment. It is used as it is and never written anywhere. Use it in scripts, CI jobs and agents.
2. **The key of the profile** that `widgetic auth login` saved.

```bash theme={"theme":"css-variables"}
widgetic auth login                                        # asks for the key without showing it
echo "$WIDGETIC_API_KEY" | widgetic auth login --with-key  # reads the key from standard input
widgetic auth status                                       # which key, where it comes from, where it works
widgetic auth logout                                       # forgets the key of this profile (--all: every profile)
```

`auth login` checks the key with the server before it saves it. It saves none that the server refuses, and none whose workspace has no plan, and it says why ([When the workspace has no plan](https://docs.widgetic.com/docs/cli/keys-and-workspaces.md#when-the-workspace-has-no-plan)). `--no-verify` saves the key without asking the server.

A key is never taken from an argument, because an argument stays in your shell history and in the list of running processes. The CLI sends the key to the API's own address and to nowhere else: a redirect to another host does not carry it along.

> [!NOTE]
>
> A saved key is plain text in a file that only you can read (see [Files the CLI keeps](#files-the-cli-keeps)). On a shared machine, or in CI, prefer `WIDGETIC_API_KEY` from a secret store over a saved key.

### Profiles

A profile is a name for a saved key. `--profile NAME` picks one for a single call, `WIDGETIC_PROFILE` picks one for a whole shell, and `default` is used when neither is given. A name uses letters, digits, dots, hyphens and underscores, at most 64 of them.

A key works in one workspace only, so keep a profile for each workspace you use:

```bash theme={"theme":"css-variables"}
widgetic auth login --profile acme-studio
widgetic auth status --profile acme-studio
WIDGETIC_PROFILE=acme-studio widgetic mcp list-widgets
```

## Environment variables

| Variable | What it does |
| - | - |
| `WIDGETIC_API_KEY` | The API key. It is used before any saved key, and it is the one secret. |
| `WIDGETIC_PROFILE` | The profile of the saved key to use when `--profile` is not given. Default: `default`. |
| `WIDGETIC_WORKSPACE` | The name of the workspace that every change made with `widgetic mcp` is held to. See [Which workspace a change goes to](https://docs.widgetic.com/docs/cli/keys-and-workspaces.md#which-workspace-a-change-goes-to). |
| `WIDGETIC_API_URL` | The REST address, to call another environment. It must be `https`, or `http` for `localhost`. Default: `https://api.widgetic.com/v1`. |
| `WIDGETIC_MCP_URL` | The MCP address, with the same rule. Default: `https://mcp.widgetic.com/`. |
| `WIDGETIC_CONFIG_DIR` | The folder of the CLI's own files. See [Files the CLI keeps](#files-the-cli-keeps). |
| `WIDGETIC_DEBUG` | Set to `1` to print a stack trace with an unexpected error, and to say why the CLI did not look for a newer version. |
| `NO_UPDATE_NOTIFIER`, `WIDGETIC_NO_UPDATE_CHECK` | Set to anything but `0`, `false`, `no` or `off`: the CLI never looks for a newer version and never asks about one. A CI job does the same without either (`CI` is set). |
| `npm_config_registry` | The npm registry that the look for a newer version asks. npm's own variable. Default: `https://registry.npmjs.org`. It must be `https`, or `http` for `localhost`. |

## Files the CLI keeps

The CLI keeps two files in one folder. The folder is `~/.config/widgetic` (`$XDG_CONFIG_HOME/widgetic` when that is set), `%APPDATA%\widgetic` on Windows, or the folder that `WIDGETIC_CONFIG_DIR` names.

| File | What it holds |
| - | - |
| `credentials.json` | The saved keys, one for each profile, as plain text. On macOS and Linux the file is mode `0600` in a folder of mode `0700`, so only you can read it. |
| `state.json` | What the CLI remembers between two runs and that is not a secret: when it last looked for a newer version and what it found, and when it last told you that the server's tool contract is not the one the CLI was built for. Nothing needs it. A missing or damaged file is the same as an empty one. |

## Check the setup

```bash theme={"theme":"css-variables"}
widgetic doctor
```

`doctor` is the first thing to run when something does not work. It checks the CLI and Node, the contracts the CLI was built from, the key and where it comes from, the REST API, the MCP server (the tool contract it speaks and the tools it offers, compared with this CLI) and the workspace the key works in, with its plan. A check that cannot run says why, and does not fail the others. This is what it prints before any key is saved:

```text theme={"theme":"css-variables"}
[ok]   CLI         @widgetic/cli/0.1.17 on Node 22.14.0 (linux)
[ok]   Node        22.14.0 (at least 22.12.0 is needed)
[ok]   Contracts   @widgetic/api-contracts 3.1.1: 169 REST operations, 56 MCP tools, tool contract 1.26.0
[warn] API key     No API key for the profile "default", so the servers can only be asked whether they answer.
                   Run `widgetic auth login`, or set WIDGETIC_API_KEY.
[ok]   REST API    https://api.widgetic.com/v1 answers (HTTP 401 without a key, 397 ms)
[ok]   MCP server  https://mcp.widgetic.com/ answers (HTTP 401 without a key, 148 ms)
[skip] Workspace   Needs an API key: it asks the MCP server where the key works.

Nothing is broken; 1 thing is worth a look.
```

Your versions and timings differ. `doctor` exits with `1` when a check fails and `0` otherwise, and `--json` prints every check for a script to read.

## Look things up

* `widgetic --help` is the menu, and `--help` works at every level.
* `widgetic schema api <group> <command>` and `widgetic schema mcp <command>` print everything one command takes, with the JSON Schema its input is checked against. It works offline and describes the version that is installed.
* `widgetic docs` prints the guide for AI agents and `widgetic docs index` prints every command with its help line. Both work offline, with no key, and match the installed version.

To point an agent at them, add this to the project's `AGENTS.md`:

```markdown theme={"theme":"css-variables"}
## Widgetic

- Before you run `widgetic`, run `widgetic docs` and read what it prints. `widgetic docs index` lists every command. Both match the installed version.
```

`widgetic completion` prints the script that completes commands and flags with the Tab key:

```bash theme={"theme":"css-variables"}
eval "$(widgetic completion bash)"    # in ~/.bashrc
eval "$(widgetic completion zsh)"     # in ~/.zshrc, after compinit
widgetic completion fish > ~/.config/fish/completions/widgetic.fish
```

## Secrets in a command

A value that the API marks as a secret, such as the key of an adapter, the secret half of a storage key or a database connection string, is never typed as the text of a flag, because what is typed stays in your shell's history and in the list of processes. The flag takes `@path` (a file) or `-` (a prompt that does not show what you type, or standard input when there is no terminal):

```bash theme={"theme":"css-variables"}
widgetic api partners set-partner-adapter-connection \
  --partner-id <partner-id> --adapter-id <adapter-id> --credential-key <name> \
  --credential @./provider-key.txt

pass show provider/key | widgetic api partners set-partner-adapter-connection \
  --partner-id <partner-id> --adapter-id <adapter-id> --credential-key <name> \
  --credential -
```

A secret typed as the text of the flag is refused with exit code `2`, nothing is sent, and the error does not repeat it. `--dry-run` prints `[redacted]` in its place, whether the secret came from a flag or from a `--data` document. The command's help says which flags take secrets.

## Keep the CLI up to date

After a command, at a terminal, the CLI says when a newer version is on npm, shows both versions and asks:

```text theme={"theme":"css-variables"}
A new version of the Widgetic CLI is available: 0.1.0 → 0.2.0
Update now? (runs `npm install -g @widgetic/cli@0.2.0`) [y/N]
```

* **It never gets in the way.** The look for the newest version is one small request to the npm registry, with no key and nothing from your account. It runs beside your command with a limit of 2 seconds, and its answer is kept for 24 hours (1 hour after a failure). The question comes after the command has printed its result, on standard error, and nothing that happens in it changes the command's exit code.
* **It asks a person, and only a person.** Never with `--json` or `--yes`, never when standard input, output or error is not a terminal, never in CI, never when `NO_UPDATE_NOTIFIER` or `WIDGETIC_NO_UPDATE_CHECK` is set, and never for `--help`, `--version`, `help`, `completion` or `update`. `WIDGETIC_DEBUG=1` says which of these applied.
* **The default is no.** Enter, Ctrl-C and 20 seconds of silence all mean no. A no is remembered for 7 days for that version, and a newer version asks at once. A server that refuses the CLI as too old (exit code `7`) always gets the question.
* **It installs what it showed.** On yes it runs the global install command of the package manager that installed this copy (`npm`, `pnpm`, `yarn` or `bun`), pinned to the version it showed, and then checks that the installed copy changed. A copy it cannot place, such as one inside a project's `node_modules`, is not touched: the CLI prints the new version and the command to run.

`widgetic update` does the same whenever you ask. It asks npm itself instead of using the answer it kept. `--check` only reports, `--yes` installs without asking, and `--json` prints `{package, current, latest, updateAvailable, updated, installedWith, command}` and never asks (add `--yes` to install).

In CI, pin the version you tested instead: `npm install -g @widgetic/cli@0.1.17`. A server can refuse a CLI that is too old with `426`, which the CLI reports as exit code `7`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.