# centrs CLI reference

<!-- GENERATED FILE — do not edit. Regenerate with `bun run docs:cli`. -->
<!-- Source of truth: the CliCommandMetadata objects in src/cli/*.ts -->

Every flag below is generated from the same metadata that renders
`centrs <command> --help`; CI fails when this file and the metadata drift
(`bun run docs:cli --check`). Behavior, examples, and designed-but-not-yet
implemented flags live in each command's `commands/<name>/README.md`.

Long flags that take a value accept both `--flag value` and `--flag=value`,
including an explicit empty `--flag=` value. Missing values and another flag
in a value slot produce `usage/missing-flag-value`. Password flags accept
flag-shaped values; use `--password=--help` for a literal help token.
`--help` and `-h` before `--` show help even after an incomplete option.
`centrs help <command>` and `centrs --help <command>` also show command help.

| Command | Summary |
| ------- | ------- |
| [`retrieve`](#retrieve) | Read RouterOS values through the shared core using the selected protocol. |
| [`execute`](#execute) | Run a RouterOS read or write command via native API, REST, SSH, or mac-telnet. |
| [`api`](#api) | Structured RouterOS API passthrough (gh-api style) over REST or native API. |
| [`transfer`](#transfer) | Copy files to/from a RouterOS device and manage device files (rest/native/sftp). |
| [`terminal`](#terminal) | Open an interactive RouterOS console (ssh or mac-telnet). |
| [`explain`](#explain) | Analyze RouterOS input offline or add read-only device evidence from one router. |
| [`devices`](#devices) | Inspect and mutate the CDB-backed device registry. `devices` is the only command that writes the CDB. |
| [`discover`](#discover) | Discover RouterOS neighbors over MNDP and optionally save them into the CDB. |
| [`btest`](#btest) | Run MikroTik's bandwidth test as a client or server (peer measurement). |
| [`mcp`](#mcp) | Start the centrs MCP server (stdio) — scoped RouterOS tools gated by the CDB allowlist. |
| [`settings`](#settings) | Manage centrs's own global preferences (`centrs.env`) and inspect the `__default__` CDB record. |

## retrieve

Read RouterOS values through the shared core using the selected protocol.

```text
Usage: centrs retrieve <target> <routeros-path> [flags] | centrs retrieve <target...> <routeros-path> [flags] | centrs retrieve --host <host|url> <routeros-path> [flags] | centrs retrieve --group <name> <routeros-path> [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--via` | `<protocol>` | Pin the protocol selector. Defaults to `rest-api` for retrieve (`--sample` included), and to `native-api` under `--follow`. |
| `--group` | `<name>` | Fan out across every CDB record in the group (repeatable; de-duped by record index). |
| `--where` | `<attr>`=`<value>` | Device-class selector over CDB facts + core fields (repeatable, AND-combined). |
| `--near` | `<lat>`,`<lon>`,`<radius>` | Geo selector: devices whose GPS is within radius (m/km/mi/ft; bare number = km). Lat-first. |
| `--bbox` | `<south>`,`<west>`,`<north>`,`<east>` | Geo selector: devices whose GPS is inside the lat-first bounding box. |
| `--all` |  | Fan out across every CDB record (excludes `__default__`). |
| `--default` |  | Select the reserved `__default__` record. |
| `--quickchr` | `<name>` | Target a running quickchr-managed CHR VM by name (repeatable; fans out when repeated). Exclusive of positional targets and CDB selectors; conflicts with direct connection overrides (--host/--port/--username/--password, and --ssh-key where the command has it). |
| `--concurrency` | `<n>` | Max in-flight targets during fan-out (transport-aware default: rest-api 8, native-api 4). |
| `--host` | &lt;host\|url&gt; | Host or base URL to dial. With no `<target>` it is the target (no CDB lookup); with one it overrides the resolved host. |
| `--port` | `<port>` | Override the resolved management port. |
| `--username / --user / -u` | `<name>` | RouterOS username (aliases `--user`, `-u`). Falls back to `CENTRS_USERNAME`. |
| `--password` | `<secret>` | RouterOS password. Falls back to `CENTRS_PASSWORD`. |
| `--timeout` | &lt;ms\|5s&gt; | Per-request timeout, separate from --wait's overall deadline. REST currently rejects values above 60s. |
| `--attribute` | `<name>` | Project one attribute. May be repeated. |
| `--attributes` | `<a,b>` | Project a comma-separated attribute list. |
| `--all-attributes` |  | Request the RouterOS detail/all-attributes shape. |
| `--list-attributes / --list` |  | List inspect-derived attributes without running the data call. |
| `--query / --filter` | `<expr>` | Row filter written as after `print where` (`disabled`, `mtu>=1500 and !dynamic`), run on the router as an API query; repeatable, AND-ed. No `~` or `in`. |
| `--follow` |  | Keep the menu's rows current over native-api `listen`: a `started` line, snapshot frames, a `synced` line, then a line per change, then a summary (NDJSON for json/yaml/ndjson). Single target, list menus whose print takes follow-only. |
| `--sample` | `<interval>` | Read the menu again every interval (with a unit, e.g. `5s`): a `started` line, one line per complete read, then a summary. With --wait, sets polling cadence and returns one final envelope. Sees counters and state listen never reports. Single target; rest-api or native-api. |
| `--wait` | `<deadline>` | Wait for a successful read or a condition until this overall deadline, with a unit (e.g. `2m`). Retries refused, closed, reset and timed-out connections and a down or unreachable host; other errors fail at once. One final envelope; single target. |
| `--until` | `<expr>` | With --wait: succeed when any selected row matches this --query grammar predicate; repeatable, AND-ed. Returns the matching rows. Already true succeeds on the initial read. |
| `--until-empty` |  | With --wait: succeed on a completed read with zero rows selected by --query. Silence and failed reads never satisfy it. |
| `--sweep` | `<duration>` | `--follow` only: how often a membership sweep finds removals RouterOS does not send, including silent exits from --query. Needs a unit; default `10s`; `0` turns it off. |
| `--count` | `<n>` | `--follow`: stop after N live changes (snapshot frames and `synced` do not count). `--sample`: stop after N samples. |
| `--duration` | `<duration>` | `--follow`/`--sample`: stop after this wall-clock window (e.g. `30s`), counted from the end of validation. |
| `--format` | &lt;text\|json\|yaml\|ndjson&gt; | Output format for the CLI response. Defaults to text; use --json or --format json for the structured envelope. `ndjson` prints each envelope as one compact line. |
| `--json` |  | Shortcut for `--format json`. |
| `--max-results` | `<bytes>` | Fail instead of printing output larger than the given byte budget. |
| `--cdb-file` | `<path>` | Read target credentials from a WinBox CDB file. |
| `--cdb-password` | `<password>` | Decrypt an encrypted WinBox CDB file. |
| `--match` | &lt;user=name\|target=addr\|record-type&gt; | Pick one of several CDB records saved for `<router>` (as `devices show --match`); single target only. |
| `--resolve` | &lt;none\|arp&gt; | Resolve a MAC-address target to an IP via the host ARP cache (default none). |
| `--validate / --no-validate` |  | Enable or disable inspect-backed preflight validation. |
| `--verbose` |  | Show resolved setting sources in text output, on stderr. |

## execute

Run a RouterOS read or write command via native API, REST, SSH, or mac-telnet.

```text
Usage: centrs execute <target> <command> [flags] | centrs execute <target...> -- <command> [flags] | centrs execute --host <host|url> [--] <command> [flags] | centrs execute --group <name> <command> [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--via` | &lt;native-api\|rest-api\|ssh\|mac-telnet&gt; | Pin the protocol selector; no silent downgrade when set. A bare MAC target defaults to mac-telnet. |
| `--group` | `<name>` | Fan out across every CDB record in the group (repeatable; de-duped by record index). |
| `--where` | `<attr>`=`<value>` | Device-class selector over CDB facts + core fields (repeatable, AND-combined). |
| `--near` | `<lat>`,`<lon>`,`<radius>` | Geo selector: devices whose GPS is within radius (m/km/mi/ft; bare number = km). Lat-first. |
| `--bbox` | `<south>`,`<west>`,`<north>`,`<east>` | Geo selector: devices whose GPS is inside the lat-first bounding box. |
| `--all` |  | Fan out across every CDB record (excludes `__default__`). |
| `--default` |  | Select the reserved `__default__` record. |
| `--quickchr` | `<name>` | Target a running quickchr-managed CHR VM by name (repeatable; fans out when repeated). Exclusive of positional targets and CDB selectors; conflicts with direct connection overrides (--host/--port/--username/--password, and --ssh-key where the command has it). |
| `--concurrency` | `<n>` | Max in-flight targets during fan-out (transport-aware default: rest-api 8, native-api 4). |
| `--cmr` |  | Run on CMR clients through their controller: the `<target>` is the controller (RouterOS 7.26beta1+, `cmr` package). Needs `--labels`; native-api or rest-api only. |
| `--labels` | `<expr>` | With `--cmr`: RouterOS label expression selecting clients (comma list; plain = OR, `+` AND, `-` AND NOT, `all`). |
| `--host` | &lt;host\|url&gt; | Host or base URL to dial. With no `<target>` it is the target (no CDB lookup); with one it overrides the resolved host. |
| `--port` | `<port>` | Override the resolved management port. |
| `--username / --user / -u` | `<name>` | RouterOS username (aliases `--user`, `-u`). Falls back to `CENTRS_USERNAME`. |
| `--password` | `<secret>` | RouterOS password. Falls back to `CENTRS_PASSWORD`. |
| `--ssh-key` | `<path>` | `--via ssh`: explicit private-key path. Falls back to `CENTRS_SSH_KEY` / the `ssh-agent`. |
| `--insecure` |  | Disable SSH host-key verification (`--via ssh`: accepts changed/impersonated keys, not just new) or accept a self-signed `api-ssl` TLS cert. Default verifies. |
| `--cdb-file` | `<path>` | Read target credentials from a WinBox CDB file. |
| `--cdb-password` | `<password>` | Decrypt an encrypted WinBox CDB file. |
| `--match` | &lt;user=name\|target=addr\|record-type&gt; | Pick one of several CDB records saved for `<router>` (as `devices show --match`); single target only. |
| `--resolve` | &lt;none\|arp&gt; | Resolve a MAC-address target to an IP via the host ARP cache (default none). |
| `--timeout` | `<duration>` | Per-request timeout (for REST, max 60s). |
| `--validate / --no-validate` |  | Run offline analysis, then RouterOS :parse, plus `/console/inspect` for structured commands over native API/REST (default true; `--validate=false` disables both stages). |
| `--yes` |  | Confirm write-shaped add/set/remove commands in non-interactive runs. |
| `--max-results` | `<bytes>` | Fail if the rendered envelope exceeds this byte budget. |
| `--format` | &lt;text\|json\|yaml&gt; | Output format for the CLI response. Defaults to text; use --json or --format json for the structured envelope. |
| `--json` |  | Shortcut for `--format json`. |
| `--verbose` |  | Include additional context in text output, on stderr. |
| `--` |  | End centrs option parsing: every following token is the literal RouterOS command (e.g. `-- /interface print where disabled=yes`). Put centrs flags before it; one of execute's own long flags after it is refused as `usage/flag-after-separator`. |

## api

Structured RouterOS API passthrough (gh-api style) over REST or native API.

```text
Usage: centrs api <router> <endpoint> [flags] | centrs api --host <host|url> <endpoint> [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `-X / --method` | `<verb>` | HTTP method, default GET (case-insensitive). GET→print, PUT→add, PATCH→set, DELETE→remove, POST→run. |
| `-f / --field` | `<key=value>` | Body field, repeatable; assembled into the JSON body (verbatim string values). |
| `-d / --data` | `<json>` | Raw JSON request body. Conflicts with `-f` / `--input`. |
| `--input` | &lt;file\|-&gt; | Read the raw JSON body from a file or stdin (`-`). |
| `--query / --filter` | `<expr>` | Row filter written as after `print where` (`disabled`, `mtu>=1500 and !dynamic`), sent as query words; repeatable, AND-ed. No `~` or `in`. |
| `--raw-query` | `<word>` | Verbatim RouterOS query word (repeatable), e.g. has-property `name`, absence `-name`, or stack ops `#\|` `#&` `#!`. |
| `--attribute / --proplist` | `<a,b>` | Property projection → `.proplist`. |
| `--raw` |  | Strip the envelope; emit bare RouterOS JSON. Defaults `--validate` to false (an explicit `--validate=true` still runs the gate); does not imply `--yes`. |
| `--yes` |  | Confirm a mutating (non-read) request in non-interactive runs. |
| `--stream` |  | Stream the command's native replies (`!re` rows and `!empty`) as NDJSON: a `started` line, a line per reply, then a summary envelope. Never changes the command: a GET streams one print. To follow changes, request `<menu>/listen`, which implies it. |
| `--count` | `<n>` | Stop a `--stream` after N `!re` rows; `!empty` replies do not count (not the device count= argument). |
| `--duration` | `<dur>` | Stop a `--stream` after this wall-clock window (e.g. `5s`). |
| `--via` | &lt;rest-api\|native-api&gt; | Pin the transport; no silent downgrade. Default rest-api. |
| `--group` | `<name>` | Fan out across every CDB record in the group (repeatable; de-duped by record index). |
| `--where` | `<attr>`=`<value>` | Device-class selector over CDB facts + core fields (repeatable, AND-combined). |
| `--near` | `<lat>`,`<lon>`,`<radius>` | Geo selector: devices whose GPS is within radius (m/km/mi/ft; bare number = km). Lat-first. |
| `--bbox` | `<south>`,`<west>`,`<north>`,`<east>` | Geo selector: devices whose GPS is inside the lat-first bounding box. |
| `--all` |  | Fan out across every CDB record (excludes `__default__`). |
| `--default` |  | Select the reserved `__default__` record. |
| `--quickchr` | `<name>` | Target a running quickchr-managed CHR VM by name (repeatable; fans out when repeated). Exclusive of positional targets and CDB selectors; conflicts with direct connection overrides (--host/--port/--username/--password, and --ssh-key where the command has it). |
| `--concurrency` | `<n>` | Max in-flight targets during fan-out (transport-aware default: rest-api 8, native-api 4). |
| `--host` | &lt;host\|url&gt; | Host or base URL to dial. With no `<router>` it is the target (no CDB lookup); with one it overrides the resolved host. |
| `--port` | `<port>` | Override the resolved management port. |
| `--username / --user / -u` | `<name>` | RouterOS username. Falls back to `CENTRS_USERNAME`. |
| `--password` | `<secret>` | RouterOS password. Falls back to `CENTRS_PASSWORD`. |
| `--insecure` |  | Accept a self-signed `api-ssl`/REST TLS cert. Default verifies. |
| `--cdb-file` | `<path>` | Read target credentials from a WinBox CDB file. |
| `--cdb-password` | `<password>` | Decrypt an encrypted WinBox CDB file. |
| `--match` | &lt;user=name\|target=addr\|record-type&gt; | Pick one of several CDB records saved for `<router>` (as `devices show --match`); single target only. |
| `--resolve` | &lt;none\|arp&gt; | Resolve a MAC-address target to an IP via the host ARP cache (default none). |
| `--timeout` | `<duration>` | Per-request timeout (for REST, max 60s). |
| `--validate / --no-validate` |  | Validate structured requests with `/console/inspect`; `/execute` scripts run offline analysis, then RouterOS :parse (default true; `--validate=false` disables both stages). |
| `--format` | &lt;json\|ndjson\|yaml\|text&gt; | Output format. Defaults to json for api; `CENTRS_FORMAT` overrides. |
| `--json` |  | Shortcut for `--format json`. |
| `--verbose` |  | Include additional context in text output, on stderr. |

## transfer

Copy files to/from a RouterOS device and manage device files (rest/native/sftp).

```text
Usage: centrs transfer <router>|--host <host> upload <local> [remote] | download <remote> [local] | list [path] | remove <remote> | mkdir <remote> | copy <src> <dst> [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--via` | `<method>` | Pin the method: rest, native, or sftp (large transfers; `ssh` is an alias); scp/fetch/ftp are not built yet. Auto picks the cheapest by size/direction, after a CDB record's `via=` (ssh→sftp). |
| `--ssh-key` | `<path>` | sftp only: explicit private-key path. Falls back to CENTRS_SSH_KEY / the ssh-agent. |
| `--insecure` |  | Accept a self-signed TLS cert (https/api-ssl) or a new SSH host key. Default verifies. |
| `--force / --overwrite` |  | Skip the existing-destination check on the device for `upload`/`mkdir`/`copy` (`upload` then overwrites). Default refuses an existing target. `download` always replaces the local file. |
| `--group` | `<name>` | Fan out across every CDB record in the group (repeatable; de-duped by record index). |
| `--where` | `<attr>`=`<value>` | Device-class selector over CDB facts + core fields (repeatable, AND-combined). |
| `--near` | `<lat>`,`<lon>`,`<radius>` | Geo selector: devices whose GPS is within radius (m/km/mi/ft; bare number = km). Lat-first. |
| `--bbox` | `<south>`,`<west>`,`<north>`,`<east>` | Geo selector: devices whose GPS is inside the lat-first bounding box. |
| `--all` |  | Fan out across every CDB record (excludes `__default__`). |
| `--default` |  | Select the reserved `__default__` record. |
| `--quickchr` | `<name>` | Target a running quickchr-managed CHR VM by name (repeatable; fans out when repeated). Exclusive of positional targets and CDB selectors; conflicts with direct connection overrides (--host/--port/--username/--password, and --ssh-key where the command has it). |
| `--concurrency` | `<n>` | Max in-flight targets during fan-out (transport-aware default: rest-api 8, native-api 4). |
| `--out-dir` | `<dir>` | `download` fan-out only: write one file per target into `<dir>`, named by CDB identity. Required when downloading across a selection. |
| `--yes` |  | Confirm a mutating fan-out (upload/remove/mkdir/copy) across multiple routers in non-interactive runs. |
| `--verify` | &lt;size\|checksum\|off&gt; | Post-transfer integrity check. Default size; `--no-verify` skips. |
| `--no-verify` |  | Disable post-transfer verification; conflicts with --verify. |
| `--type` | &lt;file\|directory\|disk\|package&gt; | list filter: RouterOS /file row type. |
| `--name` | `<glob>` | list filter: file-name glob. |
| `--host` | &lt;host\|url&gt; | Host or base URL to dial. With no `<router>` before the verb it is the target (no CDB lookup); with one it overrides the resolved host. |
| `--port` | `<port>` | Override the resolved management port. |
| `--username / --user / -u` | `<name>` | RouterOS username (aliases --user, -u). Falls back to CENTRS_USERNAME. |
| `--password` | `<secret>` | RouterOS password. Falls back to CENTRS_PASSWORD. |
| `--timeout` | &lt;ms\|5s&gt; | Operation timeout. REST rejects values above 60s. |
| `--format` | &lt;text\|json\|yaml&gt; | Output format. Defaults to text; --json / --yaml shortcuts. |
| `--json` |  | Shortcut for --format json. |
| `--yaml` |  | Shortcut for --format yaml. |
| `--cdb-file` | `<path>` | Read target credentials from a WinBox CDB file. |
| `--cdb-password` | `<password>` | Decrypt an encrypted WinBox CDB file. |
| `--match` | &lt;user=name\|target=addr\|record-type&gt; | Pick one of several CDB records saved for `<router>` (as `devices show --match`); single target only. |
| `--validate / --no-validate` |  | Enable or disable the existence-probe preflight. |
| `--verbose` |  | Show the resolved transport in text output, on stderr. |

## terminal

Open an interactive RouterOS console (ssh or mac-telnet).

```text
Usage: centrs terminal <router> [flags] | centrs terminal --host <host> [flags] | centrs terminal --quickchr <name> [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--via` | `<method>` | Transport: `ssh` (host target, default) or `mac-telnet` (MAC target, default for a MAC). rest/native have no terminal capability. |
| `--host` | `<host>` | ssh: the host to dial (the target when no `<router>` is given; no CDB lookup). mac-telnet: the UDP delivery host (default L2 broadcast). |
| `--port` | `<port>` | Override the port: ssh default 22, mac-telnet default 20561. |
| `--quickchr` | `<name>` | Open an ssh console to one running quickchr machine; host/port/user/key come from its descriptor. Once only; not with `<router>`, --host, --port, --username, --password, --ssh-key or --match. |
| `--username / --user / -u` | `<name>` | RouterOS username (aliases --user, -u). Falls back to CENTRS_USERNAME. |
| `--password` | `<secret>` | RouterOS password. Falls back to CENTRS_PASSWORD. |
| `--source-mac` | `<mac>` | mac-telnet: explicit in-packet source MAC (overrides egress resolution). |
| `--ssh-key` | `<path>` | `--via ssh`: explicit private-key path. Falls back to `CENTRS_SSH_KEY` / the `ssh-agent`. |
| `--insecure` |  | `--via ssh`: disable host-key verification (accepts changed/impersonated keys). Default verifies. |
| `--cdb-file` | `<path>` | Read target credentials from a WinBox CDB file. |
| `--cdb-password` | `<password>` | Decrypt an encrypted WinBox CDB file. |
| `--match` | &lt;user=name\|target=addr\|record-type&gt; | Pick one of several CDB records saved for `<router>` (as `devices show --match`); single target only. |
| `--resolve` | &lt;none\|arp&gt; | `--via ssh` only: turn a MAC target into an IP. CDB-first; `arp` opts into the host ARP cache (default none). The mac-telnet default ignores it. |
| `--format` | &lt;text\|json\|yaml&gt; | Error-envelope format on failure. --json / --yaml shortcuts. |
| `--json` |  | Shortcut for --format json. |
| `--yaml` |  | Shortcut for --format yaml. |
| `--verbose` |  | Verbose error output. |

## explain

Analyze RouterOS input offline or add read-only device evidence from one router.

```text
Usage: centrs explain [<router>] '<input>' [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--via` | &lt;rest-api\|native-api&gt; | Pin the transport; no silent downgrade. Default rest-api. |
| `--host` | &lt;host\|url&gt; | Host or base URL to dial. With no `<router>` it is the target (no CDB lookup); with one it overrides the resolved host. |
| `--port` | `<port>` | Override the resolved management port. |
| `--username / --user / -u` | `<name>` | RouterOS username. Falls back to `CENTRS_USERNAME`. |
| `--password` | `<secret>` | RouterOS password. Falls back to `CENTRS_PASSWORD`. |
| `--insecure` |  | Accept a self-signed `api-ssl`/REST TLS cert. Default verifies. |
| `--cdb-file` | `<path>` | Read target credentials from a WinBox CDB file. |
| `--cdb-password` | `<password>` | Decrypt an encrypted WinBox CDB file. |
| `--resolve` | &lt;none\|arp&gt; | Resolve a MAC-address target to an IP via the host ARP cache (default none). |
| `--timeout` | `<duration>` | Per-request timeout (for REST, max 60s). |
| `-p` | `<secret>` | Alias for --password. |
| `--quickchr` | `<name>` | Resolve one running quickchr VM by name. |
| `--file` | `<path>` | Read the input from a file instead of the positional (`-` reads stdin). Piped stdin is used automatically when no input positional is given. |
| `--fail-on` | &lt;error\|warning\|never&gt; | Exit 2 when the verdict reaches this severity. Default `error`; an ambiguous or unknown statement is a warning, never an error. |
| `--complete` |  | Candidates at the cursor: menus and verbs, argument names, or values. Live evidence — offline emits a tip and enumerates nothing. |
| `--schema` |  | Describe the path at the cursor: a menu's verbs and submenus, a command's arguments, `print`'s proplist. Live evidence — offline emits a tip and enumerates nothing. |
| `--cursor` | `<byte>` | UTF-8 byte offset for --complete/--schema. Default: the end of the input. |
| `--full` |  | Lift --complete/--schema sizing to its safety ceiling (1024 names, 128 expansion probes). |
| `--curl` |  | Render a ready-to-edit REST curl for statements covered by a runtime-tested mapping rule. |
| `--tokens` |  | Emit the total, gapless token partition behind `data.tokens[]` (every byte not claimed by an analyzer is `unclassified`). |
| `--format` | &lt;text\|json\|yaml&gt; | Output format for the CLI response. |
| `--json` |  | Shortcut for `--format json`. |
| `--yaml` |  | Shortcut for `--format yaml`. |
| `--verbose` |  | Verbose error output. |

## devices

Inspect and mutate the CDB-backed device registry. `devices` is the only command that writes the CDB.

```text
Usage: centrs devices <init|encrypt|list|show|groups|add|edit|set|remove> [args] [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--encrypt` |  | `init` only — require encrypted creation with a non-empty CDB password; refuse an existing open CDB. |
| `--no-backup` |  | `encrypt` only — skip the plaintext pre-conversion snapshot. Without that snapshot, a forgotten password cannot be recovered. |
| `--cdb-file` | `<path>` | Override the resolved CDB path (default `~/.config/tikoci/winbox.cdb`). |
| `--cdb-password` | `<secret>` | CDB password for encrypted reads, writes, explicit encrypted initialization and conversion. Falls back to `CENTRS_CDB_PASSWORD`; a password alone never converts an open CDB. |
| `--via` | `<protocol>` | Resolve and report the protocol source for provenance examples; no network IO is performed. |
| `--group` | `<name>` | `list` filter / `add`,`set` first-class group field for the target entry. |
| `--where` | `<attr=value>` | `list` only — repeatable device-class filter over CDB facts (AND-combined), e.g. `--where lat=37.7749`. |
| `--near` | `<lat>`,`<lon>`,`<radius>` | `list` only — GPS filter: devices within radius (m/km/mi/ft; bare number = km). Lat-first. |
| `--bbox` | `<south>`,`<west>`,`<north>`,`<east>` | `list` only — GPS filter: devices inside the lat-first bounding box. |
| `--members` |  | `groups` only — expand each group's membership. |
| `--explain` |  | `show` only — include the raw `WinBoxCdbRecord` in `data.record` (its password field reads `<redacted>` unless `--show-password`). |
| `--match` | &lt;user=…\|target=…\|record-type&gt; | `show`,`set`,`remove` — disambiguate when `<router>` matches several records: `user=<name>`, `target=<addr>`, or a record-type token. |
| `--user` | `<name>` | `add`,`set` — first-class CDB user field. |
| `--password` | `<secret>` | `add`,`set` — first-class CDB password field. |
| `--password-stdin` |  | `add`,`set` — read the record password from stdin (one trailing newline stripped) so it never rides argv. Conflicts with `--password`. |
| `--show-password` |  | `show`,`add`,`set` — include the record password in cleartext. By default output carries `passwordSet` and withholds the password. |
| `--profile` | `<name>` | `add`,`set` — named WinBox profile (Workspace). |
| `--profile-none` |  | `add`,`set` — write the WinBox `<none>` profile sentinel. |
| `--profile-own` |  | `add`,`set` — write the WinBox `<own>` profile sentinel. |
| `--session` | `<name>` | `add`,`set` — first-class CDB session field. |
| `--comment` | `<text>` | `add` only — base free-form comment (may include kv-soup). |
| `--record-type` | &lt;macTarget\|ipAdmin\|ipUser\|romonNeighbor\|romonTarget&gt; | `add` only — record type (default `ipAdmin`). |
| `--lat / --latitude` | `<deg>` | `add`,`set` — latitude in decimal degrees (-90..90); a comment-kv fact, paired with --lon. |
| `--lon / --lng / --longitude / --long` | `<deg>` | `add`,`set` — longitude in decimal degrees (-180..180); a comment-kv fact, paired with --lat. |
| `--altitude / --alt / --ele / --elevation` | `<meters>` | `add`,`set` — altitude in meters (may be negative); a comment-kv fact. |
| `--altitude-type / --alt-type` | &lt;MSL\|AGL&gt; | `add`,`set` — vertical datum for --altitude (default MSL); case-insensitive. |
| `--gps` | `<lat>`,`<lon>`[,`<altitude>`[,`<altitude-type>`]] | `add`,`set` — combined lat,lon[,altitude[,altitude-type]] convenience (lat-first; missing altitude-type defaults MSL). |
| `--force` |  | `add` only — overwrite the existing (target, user) entry. |
| `--strict` |  | `add`,`set` — reject unknown comment kv keys instead of warning. |
| `--format` | &lt;text\|json\|yaml&gt; | Output format for the CLI response. |
| `--json` |  | Shortcut for `--format json`. |

### devices init

Create an empty CDB at the resolved path; existing readable files are left unchanged.

```text
Usage: centrs devices init [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--encrypt` |  | `init` only — require encrypted creation with a non-empty CDB password; refuse an existing open CDB. |
| `--cdb-file` | `<path>` | Override the resolved CDB path (default `~/.config/tikoci/winbox.cdb`). |
| `--cdb-password` | `<secret>` | CDB password for encrypted reads, writes, explicit encrypted initialization and conversion. Falls back to `CENTRS_CDB_PASSWORD`; a password alone never converts an open CDB. |
| `--format` | &lt;text\|json\|yaml&gt; | Output format for the CLI response. |
| `--json` |  | Shortcut for `--format json`. |

### devices encrypt

Encrypt an existing CDB in place, or verify an already-encrypted file; existing backups remain unchanged.

```text
Usage: centrs devices encrypt [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--no-backup` |  | `encrypt` only — skip the plaintext pre-conversion snapshot. Without that snapshot, a forgotten password cannot be recovered. |
| `--cdb-file` | `<path>` | Override the resolved CDB path (default `~/.config/tikoci/winbox.cdb`). |
| `--cdb-password` | `<secret>` | CDB password for encrypted reads, writes, explicit encrypted initialization and conversion. Falls back to `CENTRS_CDB_PASSWORD`; a password alone never converts an open CDB. |
| `--format` | &lt;text\|json\|yaml&gt; | Output format for the CLI response. |
| `--json` |  | Shortcut for `--format json`. |

## discover

Discover RouterOS neighbors over MNDP and optionally save them into the CDB.

```text
Usage: centrs discover [--timeout 15s] [--save] [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--timeout` | &lt;ms\|15s&gt; | Listen window before results are returned. Default 15s. |
| `--save` |  | Persist discovered neighbors into the CDB (`group=discovered`, `source=mndp`). |
| `--group` | `<name>` | `--save` group for new entries. Default `discovered`. |
| `--port` | `<port>` | UDP port to bind for MNDP. Default 5678. |
| `--cdb-file` | `<path>` | `--save` CDB path override (default `~/.config/tikoci/winbox.cdb`). |
| `--cdb-password` | `<secret>` | `--save` password for an encrypted CDB. Used to decrypt the existing CDB and re-encrypt on write. |
| `--format` | &lt;text\|json\|yaml&gt; | Output format for the CLI response. |
| `--json` |  | Shortcut for `--format json`. |

## btest

Run MikroTik's bandwidth test as a client or server (peer measurement).

```text
Usage: centrs btest <client <router>|server> [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--protocol` | &lt;udp\|tcp&gt; | (client) Transport. Default udp. |
| `--direction` | &lt;receive\|transmit\|both&gt; | (client) Test direction. Default receive. |
| `--duration` | `<dur>` | Bound the run (e.g. 15s). Omit for open-ended (Ctrl-C). |
| `--interval` | `<dur>` | Report cadence (20ms..5s). Default 1s. |
| `--connection-count` | `<n>` | (client, TCP only) Parallel TCP data connections (1..255). |
| `--local-udp-tx-size` | `<n>` | (client, UDP only) Client→server packet size (28..64000). |
| `--remote-udp-tx-size` | `<n>` | (client, UDP only) Server→client packet size (28..64000). |
| `--local-tx-speed` | `<bps>` | (client) Cap on client→server rate (e.g. 100M). |
| `--remote-tx-speed` | `<bps>` | (client) Cap on server→client rate (e.g. 100M). |
| `--random-data` |  | (client) Incompressible payload. |
| `--nat-mode` |  | (client, UDP only) Originate an outbound datagram first so server→client data can traverse NAT. Automatic when the test receives. |
| `--authenticate / --no-authenticate` |  | (server) Require EC-SRP5 auth. Default true; `--authenticate=false` also accepted. |
| `--bind` | `<addr>` | (server) Listen address. Default 127.0.0.1. |
| `--allocate-udp-ports-from` | `<n>` | (server) Base of the UDP data-port range. Default 2001. |
| `--max-sessions` | `<n>` | (server) Concurrent test cap (1..1000). Default 100. |
| `--user / --username / -u` | `<name>` | Credential (aliases --username, -u; falls back to CDB / CENTRS_USERNAME). |
| `--password` | `<secret>` | Credential (falls back to CDB / CENTRS_PASSWORD). |
| `--port` | `<port>` | Control port. Default 2000. |
| `--cdb-file` | `<path>` | (client) Read target credentials from a WinBox CDB file. |
| `--cdb-password` | `<password>` | (client) Decrypt an encrypted WinBox CDB file. |
| `--match` | &lt;user=name\|target=addr\|record-type&gt; | (client) Pick one of several CDB records saved for `<router>` (as `devices show --match`); `btest server` rejects it. |
| `--format` | &lt;text\|csv\|json\|yaml&gt; | Output format. Default text. |
| `--csv` |  | Shortcut for `--format csv`. |

## mcp

Start the centrs MCP server (stdio) — scoped RouterOS tools gated by the CDB allowlist.

```text
Usage: centrs mcp [start] [--cdb-file <path>] [--allow-adhoc-targets]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--cdb-file` | `<path>` | CDB allowlist path (default `~/.config/tikoci/winbox.cdb`, or CENTRS_CDB_FILE). |
| `--cdb-password` | `<password>` | Decrypt password for an encrypted CDB (or CENTRS_CDB_PASSWORD). |
| `--allow-adhoc-targets` |  | Reserved unsafe escape hatch for future inline targets; current tools still use CDB-only targets. |
| `--help` |  | Show this help. |

## settings

Manage centrs's own global preferences (`centrs.env`) and inspect the `__default__` CDB record.

```text
Usage: centrs settings [print|get|set|reset] [args] [flags]
```

| Flag | Value | Description |
| ---- | ----- | ----------- |
| `--all` |  | `print` only — also list unrecognized CENTRS_* lines found in the file. |
| `--cdb-file` | `<path>` | `print` only — CDB to probe for the `__default__` record summary (falls back to normal CDB resolution; never centrs.env). |
| `--cdb-password` | `<secret>` | `print` only — decrypt password for the probed CDB. |
| `--skip-env-file` |  | `print` only — note that other commands in this environment would not see centrs.env (settings itself always reads the real file). |
| `--format` | &lt;text\|json\|yaml&gt; | Output format for the CLI response. |
| `--json` |  | Shortcut for `--format json`. |
| `--help` |  | Show this help. |
