CLI reference
Every `mdk` command, its arguments, flags and defaults, grouped as `mdk --help` groups them
Overview
mdk is the command-line tool that scaffolds, runs and checks an MDK stack from the mdk.yaml stack file in a project directory.
This page lists every command with its arguments, flags and defaults, in the groups mdk --help uses. It states what each
command takes and does, not how to sequence them: the install guide puts mdk on your PATH, the
Worker guide runs a stack end to end, and the first operator page creates the user who
signs in. Every command reads mdk <verb> [noun], and mdk <command> --help prints the same options from the binary.
Every command that reads an existing project takes --dir <path>, the directory holding mdk.yaml, and defaults to the
current directory. mdk onboard is the exception: it creates the project and asks for the directory as its first prompt,
so it has no --dir. mdk status, mdk whoami, the mdk rbac commands, mdk user list, mdk sa list and
mdk sa token print data in the format the global --output flag names. mdk version prints plain text, and
mdk validate prints JSON only with its own --json.
Global flags
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
-o, --output <fmt> | Optional | string | table | Output format for data: table, json, or yaml |
-v, --verbose | Optional | boolean | false | Turn on the MDK components' debug logs, by setting DEBUG=mdk:* unless DEBUG is already set |
--debug | Optional | boolean | false | Print the stack trace of an unexpected failure |
--version | Optional | boolean | false | Print the CLI version and exit |
-h, --help | Optional | boolean | false | Print usage help and exit |
Set up
mdk onboard
Sets up a new project interactively: checks the environment, asks which Workers, apps, and dashboard to include and
whether to install the MDK Developer Skill, as mdk skill add does, for which coding-agent client, writes
mdk.yaml, package.json, .gitignore, a project README.md and, when an app's setup asks for a secret, a project .env,
and prints the commands to run it. The policy it writes
binds the CLI's own account and each app, so the stack boots; the first operator is created afterwards.
It takes no flags and needs an interactive terminal. Without one, as in CI or a script, write the generated mdk.yaml
with spec.workers and spec.apps empty and without the app-site role and its binding, then add entries with
mdk add worker and mdk create app, which need no terminal.
Build
mdk create worker <name>
Scaffolds a Worker Plugin (mdk-contract.json, handlers and a mock device) into workers/<name>, links it into
package.json and adds it to mdk.yaml under spec.workers with a mock device. <name> starts with a lowercase
letter or digit, followed by lowercase letters, digits, ., _ or -.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
--org <scope> | Optional | string | none | npm scope for the package name: your-org gives @your-org/<name> |
--dir <path> | Optional | string | . | Project directory |
--force | Optional | boolean | false | Overwrite the target if it already exists |
--no-install | Optional | boolean | false | Skip npm install |
--no-stack-entry | Optional | boolean | false | Do not add the Worker to mdk.yaml; the entry is printed instead |
mdk create app <name>
Scaffolds an app (mdk-app.yaml, a plugin/ route table with controllers, controller tests, and a starter UI built into ui/) into
apps/<name>, links it into package.json, adds it to mdk.yaml under spec.apps and grants it the Kernel access its
manifest requests in spec.rbac. <name> follows the Worker rule.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
--org <scope> | Optional | string | none | Names the npm package @<scope>/<name> and the app id com.<scope>.<name> in mdk-app.yaml |
--id <id> | Optional | string | com.example.<name> | Reverse-DNS app id for mdk-app.yaml, overriding the one --org derives |
--dir <path> | Optional | string | . | Project directory |
--flat | Optional | boolean | false | Scaffold into <dir> itself as the root of a standalone app repo, for mdk add app github:…; nothing is linked or added to mdk.yaml |
--force | Optional | boolean | false | Overwrite the target if it already exists |
--no-install | Optional | boolean | false | Skip npm install and the starter UI build |
--no-stack-entry | Optional | boolean | false | Do not add the app to mdk.yaml; the entry is printed instead |
mdk create dashboard [name]
Scaffolds the MDK UI shell into apps/dashboard, named <stack>-dashboard from mdk.yaml. With a name, which follows
the Worker rule, it lands in apps/<name> instead. Inside the monorepo the template is copied locally. Elsewhere it is copied
from MDK_DASHBOARD_TEMPLATE_DIR when that is set, and fetched from GitHub at --ref when it is not.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
--dir <path> | Optional | string | . | Project directory |
--ref <git-ref> | Optional | string | v<cli version> | Branch, tag or SHA to fetch the UI shell from, and that links out of the shell's Markdown point at; inside the monorepo, or from MDK_DASHBOARD_TEMPLATE_DIR, only the links use it |
--force | Optional | boolean | false | Replace the target if it already exists, without asking. From a local template (the monorepo's or MDK_DASHBOARD_TEMPLATE_DIR), the old directory is deleted once the new one is copied and rewritten, and put back if that fails; a failed install, or anything after it such as a build, does not put it back. From GitHub, the template is extracted over the old directory: files it does not contain are left in place, and nothing is put back. |
--no-install | Optional | boolean | false | Skip npm install |
mdk add app <source> and mdk add worker <source>
Installs a package from npm or GitHub with npm install --ignore-scripts --save-exact, checks it with the same rules as
mdk validate, then adds it to mdk.yaml under spec.apps or spec.workers. For a GitHub source, the commit the
lockfile resolved is written into package.json as github:<owner>/<repo>#<sha>, so the dependency doesn't follow a
branch or tag. A refused package leaves mdk.yaml and package.json unchanged. mdk add app refuses a path on disk:
reference a local app by path in mdk.yaml instead. mdk add worker --path <dir> takes one, see below. An unscoped
name or any version ending in a tarball extension (.tgz, .tar.gz, or .tar), such as pkg.tgz or pkg@x.tgz, counts
as a path, with or without ./: unpack it and use the package directory.
A worker whose mdk-contract.json declares no telemetryPollIntervalMs is written with
config.telemetryPollIntervalMs: 60000, so its telemetry collector runs and snapshot and aggregate reads have a
series to answer from instead of failing with ERR_TELEMETRY_STORE_DISABLED; the command reports the seed. A contract
that sets its own interval is not overridden, and the entry carries no such key.
config.devices[].opts is seeded from the worker package's own smoke.config.js — the example device config every
Worker package ships for mdk validate worker --smoke, and the only machine-readable statement of what its plugin reads
per device, since mdk-contract.json carries no config schema. This runs one file of the package: setup() is
called in a separate process with a 10-second deadline, so a mock it starts and a port it binds die with that process,
and with a minimal environment (PATH, HOME and the temp-dir variables), so it cannot read your npm token or cloud
credentials. Install scripts still do not run, and nothing else of the package is executed. It runs by default for a
first-party catalog worker and a --path package; for any other npm or GitHub package it runs only with --seed-opts,
and the command says when it skipped one. --no-seed-opts never runs it.
What lands in mdk.yaml depends on whether the package ships a mock:
| Package | devices[].opts |
|---|---|
Ships a mock, example sets a numeric port | The example's values, with the project's own mock port. The entry runs against the bundled mock as written |
No mock, or no port in the example | The example's keys with null values — the options the plugin reads, for you to fill in. Its values point at its mock, so they would be wrong against hardware |
No smoke.config.js, or it failed to run | The placeholder it has always been, and the command says why |
The example owns the key set: a package whose example says address gets address, not host, and no key it did not
name is added. Seeded values are the example's — replace credentials before pointing a worker at hardware.
mdk run warns when an entry already in mdk.yaml is missing options the example names, which is the case the seed
cannot reach. mdk validate worker deliberately does not: reading the example config runs the package's own
setup(), and checking a package must never be a way to execute it. mdk run hosts the plugin regardless, so the
warning there costs no extra trust.
mdk add worker --path <dir>
Declares a Worker package that is already on disk, with the same validation, seeding and mdk.yaml entry as an
installed one. npm is not involved: nothing is added to package.json, and mdk.yaml references the package by a path
relative to the project directory. <source> is omitted — give one or the other, not both. This is the supported way to
wire in a checkout you are developing, which otherwise has to be written into mdk.yaml by hand.
mdk add worker --path ../my-miner-worker<source> is one of:
| Form | Example |
|---|---|
| npm package, optionally with a range | @your-org/mdk-worker-rig@^1 |
| npm package with a subpath inside it | @your-org/apps/ops |
| GitHub shorthand, optionally with a ref | github:owner/repo#v0.2.0, owner/repo |
| GitHub URL | https://github.com/owner/repo |
| Flag | Status | Type | Default | Applies to | Description |
|---|---|---|---|---|---|
--dir <path> | Optional | string | . | both | Project directory |
--name <name> | Optional | string | derived | both | Name in mdk.yaml; the default is the last segment of the package name, or of the subpath when there is one, without its mdk-, mdk-app-, mdk-worker- or mdk-plugin- prefix. Either name is lowercased, every run of characters other than a-z, 0-9 and - becomes -, and app- is prefixed when it does not start with a letter, so --name Rig_Two gives rig-two |
--no-install | Optional | boolean | false | both | Skip npm install; the npm package must already be installed. Not for GitHub sources |
--accept-permissions | Optional | boolean | false | app | When the app's requested Kernel access changed, replace its role in spec.rbac with the new request |
--keep-permissions | Optional | boolean | false | app | When the app's requested Kernel access changed, keep its role as it is and record the new request as seen |
--path <dir> | Optional | string | — | worker | Declare a package already on disk instead of installing one; <source> is omitted and npm is not involved |
--seed-opts | Optional | boolean | false | worker | Run the package's smoke.config.js to seed config.devices[].opts even for a third-party npm or GitHub package |
--no-seed-opts | Optional | boolean | false | worker | Don't run the package's smoke.config.js, even for a catalog worker or a --path package |
An app installs as service account app:<name>, with a credential under .mdk/credentials/apps/ and a role in spec.rbac
granting exactly what its mdk-app.yaml requests. A Worker whose package ships mock/server.js is added with mock: true; one that ships its simulator
under another single mock/*server*.js name is added with that path, and one with no bundled mock is
added without mock, so fill in config.devices[].opts with the address of your hardware.
mdk remove app <name>
Undoes mdk add app for the app spec.apps lists as <name>: removes its entry from mdk.yaml, keeping the file's comments
and formatting; removes its app-<name> role, every binding to that role and app:<name> from any other binding in spec.rbac;
deletes .mdk/credentials/apps/<name>.json; and runs npm uninstall on the package unless another app or worker entry still
uses it. It then applies the policy to a running Kernel, as mdk rbac init does. An app that is running, or a name spec.apps
does not list, is refused and nothing changes.
It holds the app's run lock so the app cannot start meanwhile, and ignores the SIGTERM that mdk stop sends, so it finishes. It writes mdk.yaml last: if it stops part
way, it says so, and running it again finishes the removal. The app's source under apps/<name> and its store under
.mdk/apps/<name> are kept.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
--dir <path> | Optional | string | . | Project directory |
mdk validate app [name] and mdk validate worker [name]
Checks a package and lists every problem; exits 1 when it is not valid. Name a component mdk.yaml declares, or check
any package directory with --path. For an app the check covers mdk-app.yaml, its version against package.json, the
permission rules, the route table, every handler file and the UI build; a named app's grant in spec.rbac is checked too.
For a Worker it covers package.json and mdk-contract.json against the schema and its semantic rules, with every handler
resolved on disk and compiled but not run.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
--dir <path> | Optional | string | . | Project directory |
--path <dir> | Optional | string | none | Check this package directory instead of a name declared in mdk.yaml |
--strict | Optional | boolean | false | App: fail on warnings too. Worker: hold a legacy contract to the full v1 requirements |
--smoke | Optional | boolean | false | App: call every route against a mock Kernel that grants only the declared permissions. Worker: run the behavioural checks against the mock smoke.config.js sets up |
--smoke-config <json|path> | Optional | string | none | Mock fleet or device spec for --smoke: inline JSON, a .json file, or a module with setup() |
--timeout <ms> | Optional | string | 10000 | Deadline per smoke call |
--json | Optional | boolean | false | Print { ok, kind, name, path, errors, warnings } |
The Worker testing guide lists every smoke.config.js field for a Worker, and the
apps guide covers the app smoke checks.
Run
mdk run [target] [name]
Starts the Kernel, Workers, app runtimes, and Gateway from mdk.yaml, or one component. Runs in the foreground, where
Ctrl+C stops everything in reverse boot order, or in the background under PM2 with --detach, where mdk stop does. Each Kernel,
Worker, app, Gateway, and MCP server runs once per project, held by a lock under .mdk/run/. The all and kernel targets
refuse to boot a spec.rbac that lets nobody administer the Kernel, with one of these messages:
| Refusal starts with | Fires when | Fix |
|---|---|---|
spec.rbac binds nobody | No binding in spec.rbac names a subject | mdk rbac init |
spec.rbac binds no user, and lets nobody write the policy | Bindings name only service accounts, and none of their roles may write the policy | mdk rbac init |
Both messages go on to say that mdk rbac init binds the CLI to an admin role in mdk.yaml, after which mdk run boots.
A policy it does boot can still refuse a component, so the run that starts the Kernel warns at start. Under --detach
the warnings go to the stack's log under .mdk/logs/ rather than the terminal.
| Warning names | Fires when | Fix |
|---|---|---|
mdk-cli | Nothing binds the CLI, so mdk status, mdk user, and mdk rbac apply are refused | mdk rbac init |
mdk-mcp | Nothing binds the MCP server's account, so mdk run mcp refuses every agent | mdk rbac init |
mdk-gateway | Nothing binds the Gateway's account, so a Gateway run alone refuses every route | mdk rbac init |
app <name> has no binding | An app's app:<name> account is unbound; an app whose recorded grant requests no permissions needs none | mdk rbac init |
A package mdk.yaml names that is missing from node_modules stops the run with Package "<name>" is not installed, and the
message gives the command that installs it: npm install when package.json already declares it, otherwise the package's
install source, such as npm install github:tetherto/mdk-app-agent for a catalog package that is not on npm.
A Worker the Kernel refuses does not stop the rest of the stack: mdk run prints
! worker <name> not registered with the Kernel (<error>) in place of its ready line. A device or
name bound to another Worker survives a restart, and a warning: line names the worker.terminate call
that releases it; a Worker the Kernel could not reach gets the DHT hint instead, which the
local and air-gapped profile covers.
| Target | Starts | Takes [name] |
|---|---|---|
all | Kernel, every Worker with its mocks, every app, the Gateway. The default | no |
kernel | The Kernel alone | no |
gateway | The Gateway alone, signing in as mdk-gateway | no |
worker | One Worker and its mock devices | yes |
app | One app runtime | yes |
dashboard | The scaffolded UI shell's dev server, as its own process | yes |
mcp | A standalone MCP server over the apps spec.apps declares; never part of all and needs the Kernel reachable | no |
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
-d, --dir <path> | Optional | string | . | Project directory |
-f, --file <path> | Optional | string | <dir>/mdk.yaml | Run this spec instead, with its own state under .mdk/stacks/<file>/, where <file> is the spec's file name without .yaml or .yml |
--detach | Optional | boolean | false | Run in the background under PM2, logging to .mdk/logs/<process>.log; returns once the run logs its ready line (Stack running., or Kernel running. and the like for one component), or removes it from PM2 and prints the end of its log when it fails first. Needs pm2 on the PATH. Not for dashboard |
--allow-write | Optional | boolean | false | mcp only: expose tools whose routes are not declared read-only |
A CI job runs the stack with mdk run --detach && mdk status --wait, runs its checks, then stops it with mdk stop.
--detach hands the same command, without the flag, to PM2, using the pm2 binary on the PATH (install it with
npm install -g pm2) the way startServices({ runtime: 'pm2' }) in @tetherto/mdk-core does. The stack keeps running
after the terminal closes, and PM2 restarts it if it crashes.
| What | Value |
|---|---|
| PM2 process name | mdk-<stack name>-<hash of the project's state directory>, with -<target>[-<name>] for one component |
| PM2 config file | .mdk/pm2/<process>.json, rewritten on each --detach |
| Log | .mdk/logs/<process>.log, appended, with a timestamp on each line |
| Stop | SIGINT, or the shutdown message on Windows (shutdown_with_message); killed after 15 seconds |
For a --file stack, everything this page places under .mdk/, including pm2/, logs/, run/, keys and stores,
sits under .mdk/stacks/<file>/ instead.
PM2 keeps one daemon for every project on the machine, and the hash keeps two projects whose stacks share a name, or a
--file stack beside the mdk.yaml one, apart. mdk stop, mdk restart and mdk status find a project's processes
by that hash, so renaming the stack in mdk.yaml does not lose a running one.
--file runs a second stack from the same project, such as an app alone on its mock site: it shares the project's
node_modules, and its state under .mdk/stacks/<file>/ (--file mdk.solo.yaml gives .mdk/stacks/mdk.solo/) keeps
it apart from the mdk.yaml stack's stores, keys and locks, so the two can run side by side on their own ports. A
relative --file path resolves from the current directory, not from --dir; package paths inside the spec resolve
from the project directory, as in mdk.yaml. Pass the same --file to mdk status and mdk stop. mdk rbac,
mdk add and mdk create edit mdk.yaml only, so the second spec carries its own spec.rbac. The Auth commands take
no --file, so mdk rbac, mdk user, mdk sa, mdk login, mdk logout and mdk whoami reach only the mdk.yaml
stack's Kernel.
mdk run dashboard [name] takes the directory name a dashboard was scaffolded under: mdk create dashboard ops-ui
creates apps/ops-ui, so mdk run dashboard ops-ui runs it. The default dashboard (mdk create dashboard with no
name) is dashboard, after its directory, not after its <stack>-dashboard package name. An unknown name is refused
with the list of dashboards the project holds. With no name, apps/dashboard is used when it exists, otherwise the
first app under apps/ with a dev script; either way the chosen one is printed as Dashboard: apps/<name> before
the dev server starts.
On Linux and macOS the dev server runs in its own process group and does not read the terminal, so Vite's keyboard
shortcuts (r, h, q, and the rest) do nothing. mdk run dashboard stops the whole dev server itself on Ctrl+C,
or when the terminal closes, even while it is still starting, so its port is released. To restart, press Ctrl+C and
run mdk run dashboard again.
On Windows the dev server shares the terminal and its shortcuts work, but stopping mdk run dashboard can leave Vite
running and holding its port. Find the process on that port and end it with taskkill /PID <pid> /T /F.
mdk run mcp reads these optional keys from spec.mcp in mdk.yaml:
| Key | Type | Default | Description |
|---|---|---|---|
port | number | spec.gateway.port + 100 | Port the MCP server listens on |
allowWrite | boolean | false | Same as --allow-write |
allowTools | string[] | none | Expose only these tool ids, write tools included |
spec.mcp.token and spec.mcp.identity are refused: each agent signs in with its own service account, and spec.rbac
decides what it may call.
mdk stop
Stops the project's stack however it runs, and waits until each process has exited and, when one of them served the
Gateway, until its port is free. A mdk run --detach is removed from PM2 (pm2 delete); any other process holding a
lock under .mdk/run/ (a foreground mdk run, or one component of it) gets SIGTERM. Either way the stack shuts down
in reverse boot order. A run under PM2 marks itself in .mdk/run/<pid>.pm2, and when PM2 cannot be asked (pm2 is not
on the PATH, or pm2 jlist fails) such a run is left running and named with the pm2 delete command to stop it:
any other signal is a crash to PM2, which starts it again. On Windows a
foreground run cannot be stopped gracefully from another process: SIGTERM ends it at once, so run it with --detach
there. mdk run dashboard holds no lock and keeps running.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
-d, --dir <path> | Optional | string | . | Project directory |
-f, --file <path> | Optional | string | <dir>/mdk.yaml | Stop the stack mdk run --file started |
| Exit code | Fires when | Fix |
|---|---|---|
0 | Every process stopped and the Gateway port is free, or nothing was running | None |
1 | PM2 could not be asked or pm2 delete failed, a run under PM2 could not be reached, a process is still running 10 seconds after SIGTERM, or the Gateway port it served is still in use 10 seconds later | Stop the pid or PM2 process the output names by hand |
mdk restart
Restarts the project's mdk run --detach processes with pm2 restart: each stops in reverse boot order and boots again
from mdk.yaml, with the same Workers and apps, and the command returns once each logs that it is running. A foreground
mdk run is refused: stop it and start it again.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
-d, --dir <path> | Optional | string | . | Project directory |
-f, --file <path> | Optional | string | <dir>/mdk.yaml | Restart the stack mdk run --file started |
| Exit code | Fires when | Fix |
|---|---|---|
0 | Every process is back and running | None |
1 | PM2 is not on the PATH, nothing runs under PM2, the stack runs in the foreground, or a process did not come back | Read the printed error and the end of the log it shows |
mdk status
A one-shot report on the environment (Node version, npm version against the CLI's engines.npm, package manager, mdk.yaml validity, whether every declared package
resolves, whether PM2 is on the PATH) and the stack: how it runs (the PM2 process name, PID, uptime and restart count,
or foreground, PID N), then the Kernel, Gateway, each Worker with its state, health and device count, and each app. A
missing PM2 is reported with its install command but never fails the check. It asks PM2 only when its daemon is already
running, so it never starts one. It starts, stops
and repairs nothing; its one write is the CLI's caller key under .mdk/trusted-keys/. With --wait it checks again every
second until the stack is healthy or the time runs out, then reports; a failed precondition (exit 4) ends the wait at once.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
-d, --dir <path> | Optional | string | . | Project directory |
-f, --file <path> | Optional | string | <dir>/mdk.yaml | Check the stack mdk run --file started |
--wait [seconds] | Optional | number | 120 when given | Keep checking until the stack is healthy or <seconds> have passed |
| Exit code | Fires when | Fix |
|---|---|---|
0 | Environment checks pass and every component reports healthy | None |
1 | Gathering the report threw an unexpected error | Read the printed error and check --dir |
2 | --output names a format other than table, json or yaml, or --wait is not a number of seconds | Pass a valid value |
4 | An environment precondition fails: old Node, an npm outside engines.npm, a missing or invalid mdk.yaml, a declared package that does not resolve | Fix the precondition the report names |
5 | The stack is not fully up: Kernel or Gateway unreachable, a Worker not READY, an app not running; or the Kernel is up but the session ran out or the account may not list Workers, so they were not checked; with --wait, still not up when the time runs out | Check the component the report marks unhealthy; for a refusal, mdk login again or bind the account to a role that may list Workers |
Auth
spec.rbac in mdk.yaml is the only place policy is written, and no matching rule means denied. The
security blueprint covers the policy itself; the first operator page walks the sign-in
sequence. Every command in this group takes -d, --dir <path> (default .).
mdk rbac
| Command | Effect |
|---|---|
mdk rbac init | Binds the CLI's account mdk-cli to an admin role (written if missing), mdk-gateway and mdk-mcp to a policy-reading role, and grants each app its requested Kernel access, then applies the policy to a running Kernel. A role you edited is left alone |
mdk rbac apply | Validates spec.rbac, listing every problem, and hands it to the running Kernel, which switches at once. A refused policy leaves the one in force untouched |
mdk rbac show | Compares spec.rbac with the policy the Kernel enforces |
mdk rbac apply exits 1 when the Kernel is down, when your session has expired or your permission is refused, or when the
Kernel refuses the policy. mdk rbac show exits 1 when the Kernel is down or the policy could not be read, as with an expired
session or a missing permission, and prints the error with no comparison; a policy that differs from spec.rbac exits 0.
mdk rbac init still writes mdk.yaml and exits 0 with the Kernel down or your sign-in refused, since the Kernel applies the
file when it next starts; it exits 1 when an app is invalid or its grant fails, and reports a role that conflicts with the app's
request without failing. All three exit 1 on an invalid spec.rbac, and 2 on an unknown --output format.
mdk user
Users live in the Kernel's token issuer, so every subcommand needs the Kernel running.
| Command | Effect |
|---|---|
mdk user add <name> | Creates or updates a user and sets their password; <name> is the sub of their tokens and an email works |
mdk user passwd <name> | Sets the password and ends the user's sessions |
mdk user disable <name> | Stops the user signing in and ends their sessions |
mdk user enable <name> | Lets a disabled user sign in again |
mdk user remove <name> | Deletes the user; their spec.rbac bindings stay until you remove them |
mdk user list | Lists users, honoring -o json and -o yaml |
Flags of mdk user add:
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
--email <email> | Optional | string | none | Email, also matched by User bindings |
--group <group> | Optional | string | none | Group matched by Group bindings; repeatable, and replaces the current groups |
--admin | Optional | boolean | false | Bind the user to the admin role in spec.rbac, writing the role if missing, and apply the policy |
--no-password | Optional | boolean | false | Create the user without a password; they cannot sign in until mdk user passwd |
--password-stdin | Optional | boolean | false | Read the password from stdin instead of prompting twice |
mdk user passwd takes --password-stdin too. A password is never accepted as a flag value, and the Kernel refuses one
shorter than twelve characters. When the signed-in account may list users, mdk user passwd, mdk user disable, and
mdk user enable refuse a name the Kernel has no user for and exit 1.
mdk serviceaccount
mdk sa is the alias. A service account signs in with its own key: app:<name> for each app, created by mdk add app, and
a named account per AI agent. The private key stays in .mdk/credentials/ and never ships in a package.
| Command | Effect |
|---|---|
mdk sa add <name> | Creates an agent credential and registers it with a running Kernel; bind it to a role in spec.rbac next |
mdk sa rotate <name> | Replaces the key of app:<app> or an agent; the old key's sessions end |
mdk sa remove <name> | Deletes an agent's credential and registration; fails for a name that has neither |
mdk sa token <name> | Signs in as the account and prints a short-lived access token for an HTTP client; -o json adds the refresh token |
mdk sa list | Lists the credentials here against what the running Kernel registered; exits 1 when the registrations could not be read (session ran out or no permission), as mdk user list does |
mdk login <username>, mdk logout, mdk whoami
mdk login signs in to the Kernel's token issuer and keeps the session in .mdk/session.json, readable by you alone. While
it lasts, mdk status, mdk user, mdk sa and mdk rbac act as you, with what spec.rbac binds you to; an expired
session is an error, never a quiet return to the service account. mdk logout ends the session, and mdk whoami prints
who the CLI acts as, honoring -o json and -o yaml. With an expired session, mdk whoami also fails with
ERR_CLI_SESSION_EXPIRED and exits 1; mdk login again, or mdk logout to act as the service account.
| Flag | Status | Type | Default | Applies to | Description |
|---|---|---|---|---|---|
--password-stdin | Optional | boolean | false | mdk login | Read the password from stdin |
Other
mdk skill add
Installs the MDK Developer Skill suite into the project, so a coding agent knows MDK conventions.
| Flag | Status | Type | Default | Description |
|---|---|---|---|---|
--client <client> | Optional | string | all | Target client: cursor, claude or all |
--dir <path> | Optional | string | . | Project directory |
mdk version
Prints the package name and version to stdout. mdk --version prints the version alone.
mdk help [command]
Prints usage help for mdk, or for one command; the same as mdk <command> --help.
Next steps
- Install the CLI: put
mdkon your PATH from npm, or from a source checkout to work on the CLI itself - Run your Worker with the CLI: the commands in sequence, from a declared package to a dashboard and an agent
- Create the first operator: the user every dashboard and route sign-in needs
- Read the CLI package notes: how the CLI is built, tested, and run from source