CLI and AI agents
CLI and AI agents
kmo is the Key Man Out command-line tool. It lets you, or an AI agent working for you, follow a break-glass guide without clicking through the website: search assets, read the recovery instructions as Markdown, request access as a Successor, decrypt a secret, and save attachments. Use the CLI with your agent to pass secrets through files or pipes without printing their values into the conversation. The Claude Code plugin teaches this workflow. An existing MCP integration is also available, but its secret-reading tool returns plaintext to the agent and is not recommended for this use case.
Decryption happens on your computer, exactly as in the browser. The server never receives your unlock passphrase, private identity, or any decrypted content.
Install
Open the CLI download page for platform downloads, checksums, installation commands, and the Claude Code plugin. The same link is available in the portal sidebar and Account Security → CLI access.
Release binaries
Choose Linux (x86_64 or ARM64), macOS (Intel or Apple Silicon), or Windows (x86_64) on keymanout.app/download, then copy its installation command. The command includes the release's SHA-256 checksum, downloads the archive directly from Key Man Out, and checks it before extracting or installing anything. You can also download the archive and SHA256SUMS for manual installation.
The Linux builds are statically linked against musl, so they also work on older Linux distributions and Alpine. The macOS and Linux commands install to /usr/local/bin using sudo. The Windows command installs to %LOCALAPPDATA%\Programs\kmo and updates your user PATH without administrator access.
Run kmo --version to confirm the install. To upgrade, download and verify the latest archive, then replace the installed binary.
Sign in
kmo login
kmo login connects to https://keymanout.app and prints a link and an 8-letter code such as BCDF-GHJK, then waits. Open the link and sign in if asked. kmo opens it for you in a desktop terminal, but not over SSH or without a graphical display (see SSH and headless machines). Then check the request:
- The client name, hostname and version are reported by the device and are not verified. Approve only a code you started yourself. If someone sent you a link or code, deny it.
- Access is read-only unless the CLI asked for more with
kmo login --scope write. You can always grant less than was requested. - Teams: all of your current teams are selected. Untick any the CLI should not reach. A team you join later is not added automatically; run
kmo loginagain to include it.
Approving needs a sign-in from the last 15 minutes. If yours is older, select Sign in again and you return to the same code afterwards. Once approved, the terminal finishes signing in within a few seconds. The CLI token lasts 30 days and is stored in a private file in your config directory (~/.config/keymanout, or %APPDATA%\keymanout on Windows; override with KMO_CONFIG_DIR).
Every signed-in device is listed under Account Security → CLI access, where you can revoke it. kmo logout revokes the token from the terminal. Use --profile NAME (or KMO_PROFILE) to keep separate logins, for example for separate accounts. Profile names are not case-sensitive: Prod and prod are the same profile. Logging in again to a profile revokes its previous token. If revoking the previous token fails, kmo warns with its token ID so you can revoke it in Account Security.
Unlock and leases
Reading metadata and instructions needs no unlock. Decrypting a secret or attachment, and editing encrypted content, needs your vault identity unlocked:
kmo unlock # passphrase prompt, or the browser if your vault has no passphrase; lasts 30 minutes
kmo unlock --browser # approve it in the web app instead, even if your vault has a passphrase
kmo unlock --ttl 2h # any duration from 1m up to 8h
kmo lock # end it early
kmo unlock gets your private identity, then stores it encrypted under a short lease. The key to that file is split: half stays on your computer, half is held by the server and is only released to your CLI token until the lease expires. When the lease expires, you run kmo lock, you revoke the device, or you rotate or reset your identity, the server stops releasing its half and the stored copy becomes useless.
kmo gets the identity in one of two ways:
- Passphrase. If your vault has a passphrase,
kmo unlockasks for it in the terminal and decrypts the identity locally. - Browser. If your vault opens only with security keys,
kmo unlocksends you to the web app to approve the unlock (see Unlock in the browser).--browserdoes this for any vault.
Always run kmo unlock yourself, in your own terminal. Never paste your passphrase into an AI chat. With a passphrase vault and no terminal, kmo unlock refuses to prompt (exit code 2). Scripts can pass --passphrase-stdin or --passphrase-file PATH, or use --browser. A vault without a passphrase refuses --passphrase-stdin and --passphrase-file with error code no_passphrase_method (exit code 1) and changes nothing; run kmo unlock without them.
Unlock in the browser
With a security key you unlock kmo through the web app. kmo itself never talks to the key, so it works with any key the browser supports, over USB or NFC, on any operating system.
$ kmo unlock
Your vault opens with a security key, so kmo will unlock it in the browser.
Open this link to unlock kmo in your browser:
https://keymanout.app/cli/unlock/V1StGXR8Z5jdHi6BmyT4Qa#key=age1…
Check that the page shows this code: BCDF-GHJK
Waiting for approval (expires in 5 min). Press Ctrl-C to cancel.
- kmo creates a one-time key that exists only in its memory, and starts an unlock request on the server. The request is bound to your CLI token, your account and your current vault identity, and expires after 5 minutes.
- Open the link, signed in as the same Key Man Out account. The page shows the CLI token's name, where the request came from, when it started, and the code.
- Check that the code on the page matches the one in your terminal. Then select Unlock kmo and unlock your vault as usual: tap your security key, enter your passphrase, or, if this tab is already unlocked, just approve.
- The page encrypts your identity to kmo's one-time key and sends only the encrypted result. kmo collects it, checks that it belongs to this request, your account and your vault's public key, and creates the lease. The server hands the result out once, then deletes it, and emails you that kmo was unlocked.
The part of the link after # is kmo's one-time public key. Browsers never send that part to the server, so open the whole link exactly as printed. A page that says "This link is incomplete" got the link without it. The page locks your vault again afterwards if it unlocked the vault just for kmo; a tab that was already unlocked stays unlocked.
Only approve an unlock you just started yourself, and only when the codes match. Whoever runs the kmo that started the request can read your vault from their computer until its lease ends. If someone sends you an unlock link, deny it, and revoke the CLI token it names under Account Security → CLI access. If you get a "vault was unlocked for kmo" email you didn't expect, revoke that CLI token, then rotate your vault identity.
Press Ctrl-C while kmo waits to cancel. kmo withdraws the request, prints "Cancelled. The unlock request was withdrawn.", and ends with status 130 (with --json, error code interrupted). If the server can't be reached, kmo says it couldn't confirm the withdrawal; the request is useless without that kmo process and expires on its own. Deny on the page makes kmo stop with error code unlock_request_denied (exit code 5).
SSH and headless machines
kmo opens the link in your default browser only in a desktop terminal. It never opens one when:
- you pass
--no-browser; - stdin or stderr isn't a terminal (scripts and agents);
- you're connected over SSH (
SSH_CONNECTIONorSSH_TTYis set); - you're on Linux or BSD without a graphical display (
DISPLAYorWAYLAND_DISPLAY). WSL is the exception: kmo opens the Windows browser.
In those cases kmo still prints the link and the code, says why it didn't open a browser, then waits. Open the link in a browser where you can unlock your vault (with your security key or passphrase), such as on your laptop or your phone, and compare the code. This also works without a terminal: kmo unlock on a vault without a passphrase prints the link and waits. If kmo can't start a browser, it prints "(Could not open a browser; open the link manually.)" and keeps waiting.
Team vault keys
Some assets are encrypted to a team vault key (a keyring) instead of to you, for example when you're a Successor. To reveal them, unlock that key through the browser:
kmo unlock --keyring "Master keys" --team ops # the key's label or id, and the team's slug, id or name
The page unlocks your own vault first, then asks you to use one of the team vault key's security keys. kmo stores the key under a separate lease that kmo status lists. kmo secret, kmo attachment get, kmo edit and the MCP reveal tools use it for that team, and kmo lock ends it with your personal lease. --keyring can't be combined with --raw or the passphrase options.
If the team vault key changes later (for example, it's rotated in the web app), kmo won't encrypt to the changed key. kmo create and kmo edit then stop with error code keyring_reunlock_required (exit code 1) and nothing is saved. Run kmo unlock --keyring … --team … again, then retry. kmo never moves to a new team vault key on its own.
After a team vault key unlock, lock with kmo 0.4 or later. Older kmo versions don't know about team vault key leases: their kmo lock may say "Already locked" while the lease stays valid. If an older kmo is also installed on the computer, revoke the CLI token in Account Security → CLI access to be sure.
kmo 0.3.0 removed --identity-file. Identity backup files are no longer supported, and kmo unlock --identity-file now stops with error code identity_file_removed (exit code 2) without reading the file. Backup files you downloaded earlier still contain your private identity. Delete them. Key Man Out no longer uses them.
After you reset your vault identity in the web app, run kmo unlock again: the reset ends every lease, team vault key leases included. Until a team's owner confirms the reset, you aren't a recipient in that team, so kmo create and edits that change encrypted content stop before reading ciphertext with "Waiting for the team owner to confirm your identity reset before you can save encrypted changes in this team." (error code identity_reset_hold, exit code 5). Ask the owner to confirm it on the team's Settings page. Metadata-only edits to the name, website or instructions remain allowed under the usual permissions. If kmo cannot check your identity, it keeps the reported sign-in, connection or server error; an unavailable check does not mean you need to enroll again.
For shells where you do not want the local half written to disk, use raw mode:
export KMO_SESSION="$(kmo unlock --raw)"
The local half then exists only in the KMO_SESSION variable of that shell and its children. --raw cannot be combined with --json, so the session key never appears in JSON output. A raw lease only works for programs started from that shell: an MCP server launched by your agent app cannot see KMO_SESSION, so use plain kmo unlock when an agent needs the vault. kmo status shows how long the current lease has left.
Commands
Every command accepts --json for machine-readable output on stdout; messages and errors go to stderr. Assets can be referenced by id or as team/asset name.
| Command | What it does |
|---|---|
kmo login [--scope read|write] [--name NAME] [--no-browser] | Sign in with the browser approval flow |
kmo logout | Revoke this device and delete its local state. Exits 1 if the token could not be revoked or a local file could not be deleted; the profile is removed either way, and the message (or the single --json result) names what is left |
kmo status | Server, account, token scope and teams, lease time left, and team vault key leases (ringLeases). When the server cannot be reached, the token shows as unverified (tokenValid: null), not invalid |
kmo unlock [--ttl 30m] [--raw] [--passphrase-stdin | --passphrase-file F | --browser] [--no-browser] | Start an unlock lease, with your passphrase or in the browser. --json prints unlocked, method (passphrase or browser), leaseId, expiresAt and expiresInSeconds |
kmo unlock --keyring K --team T [--ttl 30m] [--no-browser] | Unlock a team vault key in the browser. --json adds keyring: { id, label, teamId } |
kmo lock | Revoke the lease and every team vault key lease, and delete every file exported under them. Waits up to a minute for a reveal that is already decrypting or writing in another terminal or MCP server to finish (a reveal still downloading is cancelled and prints nothing, although the server has already recorded the read), and fails without changing anything if an unlock or login is still running then. Exits 1 if the server could not be reached to revoke it (the local copy is still deleted) or an exported file could not be deleted; with --json the single JSON result then carries complete: false, serverRevoked/serverError and exportWipeFailures |
kmo teams | Teams this device can reach |
kmo list [--team T] [--search Q] | Assets, with your role and whether you can view them |
kmo show <asset> | Metadata, instructions as Markdown, attachments, your access and next steps |
kmo secret <asset> [--raw] | Decrypt and verify the secret. Prints to a terminal only, unless you pass --raw. Content without an integrity commitment always prints a warning on stderr, even with --raw |
kmo attachment list <asset> | List attachments |
kmo attachment get <asset> <name|number> [-o PATH] [--force] | Decrypt one attachment to a private file (-o - for stdout). Existing files are not replaced without --force |
kmo create --team T --name N [--website URL] [--instructions-file MD] [--secret-stdin | --secret-file F] [--attach FILE ...] | Create an asset (write access) |
kmo edit <asset> [--name] [--website] [--instructions-file MD] [--secret-stdin | --secret-file F | --clear-secret] [--attach FILE ...] [--remove-attachment NAME ...] | Edit an asset you created |
kmo access request <asset> [--type standard|time-delay|dns] [--domain D] [--business-hours] | Request access as a Successor (reuses a pending request) |
kmo access list [--status S] | Your access requests |
kmo access verify-dns <asset|request id> | Check the TXT record of a DNS-verification request |
kmo mcp [--allow-reveal] [--allow-write] [--export-dir DIR] [--attach-root DIR] | Run the MCP server on stdio |
Instructions are converted between the web editor's format and Markdown: headings, bold, italic, strikethrough, inline code, code blocks, lists, quotes, links and line breaks round-trip. Tables and images are not supported by the editor; kmo warns and keeps their text.
Edits check that nobody else changed the asset since it was read, including an edit made in the same second. A conflict exits with code 6 and is never retried automatically. Changing the secret or attachments re-encrypts the whole payload to the current recipients and needs an unlock.
Exit codes: 0 success, 1 error, 2 usage, 3 sign-in required, 4 locked or lease expired, 5 access denied or pending approval, 6 conflict, 130 cancelled with Ctrl-C. On macOS and Linux, a cancelled kmo cleans up and then ends by the signal itself (shells report Ctrl-C as 130), so a script that called it stops instead of running its next command.
Unlock error codes
With --json, errors carry these codes in error.code.
| Code | Exit | Meaning |
|---|---|---|
unlock_request_expired | 1 | Nobody approved the request within 5 minutes. Run kmo unlock again |
unlock_request_denied | 5 | The request was denied in the browser |
unlock_request_cancelled | 1 | A newer kmo unlock replaced the request, or the CLI token was revoked |
unlock_request_used | 1 | The request was already used |
unlock_request_not_found | 1 | The server no longer knows the request (it was cleaned up). Run kmo unlock again |
identity_changed | 1 | Your vault identity changed while kmo was waiting (enrollment, rotation or reset) |
identity_required | 1 | Your account has no active vault identity yet. Set one up in Account Security first |
keyring_changed | 1 | The team vault key changed while kmo was waiting |
unlock_relay_invalid | 1 | The browser sent data kmo couldn't verify, or the server returned an unlock request kmo can't use. Nothing was saved |
identity_mismatch | 1 | The identity from the browser doesn't match your vault's public key, or (with --keyring) a team vault key from the browser doesn't match the server's public key for it. Nothing was saved |
unlock_delivery_lost | 1 | The connection dropped while kmo collected the unlock, or kmo gave up while the answer carrying it was on its way, and the server hands it out only once. Nothing was saved |
unlock_poll_failed | 1 | kmo couldn't reach the server while waiting |
browser_unlock_unsupported | 1 | This server can't unlock kmo in the browser yet |
rate_limited | 1 | Too many unlock requests in a short time. Wait a moment and run kmo unlock again |
keyring_not_found, keyring_ambiguous | 1 | No team vault key, or several, match --keyring. The ambiguous error lists the candidates; pass the id |
keyring_access_denied | 5 | You can't unlock this team vault key |
keyring_retired | 1 | The team vault key was retired, so it can't be unlocked |
team_membership_required | 5 | You're not a member of the team named with --team |
ring_lease_limit | 1 | This CLI token already holds the most team vault key leases it may. Run kmo lock, or wait for some to expire |
keyring_reunlock_required | 1 | A team vault key you hold changed, so kmo won't encrypt to it. Unlock it again |
no_passphrase_method | 1 | --passphrase-stdin or --passphrase-file for a vault without a passphrase |
unlock_superseded_by_lock | 1 | kmo lock, kmo logout or kmo login ran in another terminal while this unlock waited. Nothing was unlocked, and kmo revoked any lease it had already created. Run kmo unlock again |
interrupted | 130 | Ctrl-C while waiting; the message says whether the request was withdrawn |
Reveals and lock/unlock coordinate through a file lock in the config directory (lease-<profile>.lock). A secret or attachment that is already being decrypted finishes before kmo lock, kmo unlock or kmo login replaces or removes the lease, in whichever process it runs; a reveal started while one of those runs waits for it (up to 30 seconds) and then checks the lease again, so nothing is printed or written for a lease that was just locked.
A lock also wins over an unlock that is still waiting. Every kmo lock, kmo logout and kmo login advances a counter in lock-epoch-<profile>, even when the vault was already locked. An unlock checks the counter again just before it saves its lease. If the vault was locked in the meantime, for example while you were approving in the browser, the unlock saves nothing, revokes any lease it already created and fails with unlock_superseded_by_lock.
Agent workflow commands (kmo 0.5 and later)
These commands are additive; the server still accepts kmo 0.4. The download page reports the version of the published binaries, which may differ from a source checkout. Maintainers publish the CLI release and refresh the website downloads before advertising new commands as available in a binary release.
| Command | Behavior |
|---|---|
kmo doctor [--team TEAM] [--write] --json | Check server compatibility, sign-in, team access, enrollment, scope, and local unlock state without decrypting content; return actionable next steps. A team vault key counts as unlocked for its team, or for any team when none is named |
kmo runbook --output runbook.md | Save a recovery guide starter without replacing an existing file; omit --output to print it |
kmo secret ASSET --output PATH [--force] --json | Check the output destination before the audited read, then atomically save exact secret bytes with private permissions; return only path and verification status |
kmo secret ASSET --export --json | Save to the lease-managed temporary export directory; return only path and verification status |
kmo attachment get ASSET NAME --export --json | Export an attachment under its decrypting lease instead of choosing a permanent destination |
kmo verify ASSET --json | Decrypt and verify the entire content commitment locally without printing plaintext; legacy content without a commitment fails verification |
kmo run --env NAME=ASSET -- PROGRAM ARG... | Supply a secret through the child's environment; resolve every binding successfully before starting it |
kmo run --file NAME=ASSET -- PROGRAM ARG... | Supply a private temporary credential file's path through the child's environment and clean it up after the program ends |
--output refuses overwrite unless --force is explicit. CLI 0.5 creates files with mode 0600 on Unix and a protected owner-only ACL on Windows before writing contents. Windows destinations must support enforcing that ACL; otherwise the operation fails before writing plaintext. Filesystems without hard links use an atomic no-replace move instead; if neither operation is supported, choose another destination. Failed reads create no destination file; failed writes leave no partial replacement. Direct output is permanent and remains after lock. Managed --export files use the same registry as MCP exports: lock, logout, re-unlock, and lease expiry reconciliation remove them. If no kmo process is running, expired files remain until the next invocation. Always lock when finished.
For PostgreSQL, pass a password without shell substitution:
kmo run --env PGPASSWORD=PASSWORD_ASSET_ID -- \
psql --no-password --host DB_HOST --username DB_USER --dbname DB_NAME --command 'SELECT 1'
For a program that reads a credential file from an environment variable:
kmo run --file GOOGLE_APPLICATION_CREDENTIALS=CREDENTIAL_ASSET_ID -- \
gcloud storage ls
A program receives only OS essentials such as PATH, HOME, and locale by default. --inherit-env explicitly opts into the rest of the caller's environment; KMO_* variables are always removed. Binding names must be distinct environment variable names and cannot start with KMO_. Environment values preserve trailing newlines and cannot contain NUL; use --file for such a credential. A missing, denied, locked, or unverified credential prevents the program from starting. Child failure exit codes are preserved, and when a signal ends the program, kmo ends by the same signal. --json is refused for run because the program owns stdout/stderr.
kmo run rechecks local lease state each second and asks the server about every five seconds; these checks never transfer key material. A local lock, an expiry, or the server answering that access was revoked stops the program at once and removes temporary credential files. A check that gets no usable answer (an unreachable or failing server, a rate limit, a slow connection) does not stop it: a long restore is not abandoned midway over one failed request. If the server confirms nothing for 60 seconds, kmo stops the program, including when a check is still waiting for a response. Each distinct lease is checked concurrently so an unavailable lease cannot hide another lease’s revocation.
On macOS and Linux, kmo runs the program in a dedicated process group whenever it can do so without taking the terminal away from something else: for fully attached foreground commands, for commands whose input and output are all redirected (the usual case for scripts and AI agents), and for commands without a controlling terminal. The whole group, descendants included, is terminated on cancellation, lease failure, and normal completion. A terminal job with only some streams redirected keeps its original group so sibling pagers remain usable; cleanup then targets the direct child, as on Windows, and descendants require the consuming program's own lifecycle controls.
Ctrl-C in a fully attached program reaches only that program. If it ends the program, kmo passes the interrupt on to the script that called it, as if kmo had not been in between. This also forwards an explicitly sent SIGINT or SIGQUIT: a child’s exit status cannot distinguish a terminal keystroke from a directly sent signal. With a fully attached terminal, Ctrl-Z cancels the invocation and cleans its credentials; inspect the operation’s state before running it again. A stop request sent to kmo itself pauses the program with it. Before continuing the program, kmo checks for cancellation and obtains fresh server authorization; the final local check and resume share the same lock gate as launch. Isolated groups are killed immediately during cleanup so OS job control cannot resume a stopped worker; application cleanup handlers may not run. The resume gate includes a bounded server check, so another terminal’s lock can wait up to ten seconds for that check. A redirected program that requests /dev/tty gets an error asking you to attach a terminal or disable its interactive prompts. A forced OS kill or stop of the wrapper, or host failure, can leave the program running or files in place until lock or expiry reconciliation. These controls do not revoke credentials already copied by the consumer. Consumer output is inherited and is not redacted: choose programs and logging settings that keep credentials out of their output.
verify and credential consumption use the normal gated read route and send the same access notifications as a reveal. Verification proves the stored content commitment, not that the credential works or a backup can restore. doctor checks local lease metadata; secret operations independently revalidate access with the server.
Rehearse recovery in the portal
Team owners can open Recovery readiness in the team sidebar while locked. The page reports instructions, active Successors and enrollment, stored recipient coverage, legacy/repair flags, and Gatekeeper assignments. It never fetches ciphertext, opens an access gate, or validates a real backup. Missing Gatekeepers prompt a policy review rather than silently changing the permitted recovery methods.
Create a separate practice asset with disposable credentials, assign its Successor and Gatekeepers, and have the Successor sign in with their own account. Follow the normal approval and unlock steps, restore practice data, verify a non-secret outcome, clean up, and lock. The owner can then record the exercise after confirming all four steps. The record is an owner attestation, not an independently verified restore. Records survive page reloads; the most recent 20 appear in the portal. Do not use this exercise to grant production access merely to test readiness.
Use with an AI agent
Install the Claude Code plugin, then start a new Claude Code session and run /keymanout:vault. The plugin teaches the agent to ask you to sign in and unlock in your own terminal, read recovery instructions while locked, and move secrets between files and programs without displaying their values. It installs no MCP server and grants no extra shell permissions. Other shell-capable agents can follow the same examples.
Install from the public plugin repository:
claude plugin marketplace add drgnstn/keymanout-claude
claude plugin install keymanout@keymanout
If you previously installed the local ZIP marketplace, follow the migration steps in that repository's README before adding the GitHub marketplace.
For Codex, Cursor, OpenCode, or another agent, install the same vault skill with the open skills installer (requires Node.js). It asks which agents to install it for, and works for Claude Code too:
npx skills add drgnstn/keymanout-claude@vault
Run login and unlock yourself on the same machine, OS account, and CLI profile the agent uses. Use kmo login --scope write while preparing production; successors can omit --scope write. When the agent asks, run kmo unlock --browser --ttl 15m and approve the code. Never send the agent a passphrase, private identity, CLI token, or KMO_SESSION. A browser tab's personal unlock alone does not unlock kmo.
Save a production runbook and existing secrets
Keep credentials out of instructions: names, websites, instructions, and attachment names are unencrypted metadata. The server and authorized team members can read them while the vault is locked. Put secret values in the encrypted secret field or attachment contents; put sensitive procedure details in an encrypted attachment too.
The following examples use Bash. Replace the team, asset IDs, and paths with your own. An agent can create runbook.md without credentials, then upload existing secret files by path without opening them:
set +x
kmo create --team ops --name 'Production database recovery' \
--instructions-file ./runbook.md \
--secret-file /secure/db-password \
--attach /secure/restore-config.json
Record prerequisites, recovery commands, non-secret validation steps, rollback, and where each credential is stored. Configure Successors, Gatekeepers, and approval policies in the web app; creating an asset does not configure succession. Rehearse with your successor's own account before an emergency.
For a value already held in an environment variable, pass it through stdin without displaying it or putting it in a command-line argument:
set +x
set -o pipefail
printf '%s' "$DB_PASSWORD" | kmo edit ASSET_ID --secret-stdin
Prefer files or stdin when available. Environment variables can leak through child processes, debuggers, or logs. --secret-file preserves exact UTF-8 content; --secret-stdin removes one trailing newline. Use an attachment for binary content. Check kmo show ASSET_ID --json to confirm the asset and file names without revealing the secret.
Pass recovered secrets directly to a program
An agent may safely read kmo show ASSET_ID --json for metadata and instructions. Never run kmo secret as a bare tool call, including with --json: that puts the secret in the agent session. Redirect or capture stdout in the same shell call before it reaches the tool result.
For a password consumer such as PostgreSQL, this example captures the value inside a subshell, checks that the read succeeded, and makes it available only to the consuming process and its children:
(
set +x
set -euo pipefail
PGPASSWORD=$(kmo secret ASSET_ID --raw)
export PGPASSWORD
psql --no-password --host DB_HOST --username DB_USER --dbname DB_NAME \
--command 'SELECT 1' > /dev/null 2> /dev/null
)
Use this only with a program whose logging behavior you understand. The example suppresses client output; an error is reported by its exit status. Command substitution removes trailing newlines. For exact bytes or a multiline secret, write to a private temporary file instead:
set +x
set -euo pipefail
secret_dir=$(mktemp -d)
chmod 700 "$secret_dir"
trap 'rm -rf -- "$secret_dir"' EXIT
umask 077
kmo secret ASSET_ID --raw > "$secret_dir/credential"
kmo attachment get ASSET_ID restore-config.json -o "$secret_dir/restore-config.json"
# Pass the paths directly to a program that accepts credential/config files.
# Do not display the files or send them to the agent.
If a program accepts stdin, a pipe such as kmo secret ASSET_ID --raw | CONSUMER can avoid a file. Use pipefail, a consumer that does not echo secrets, and a consumer that safely handles failed or empty input. A pipeline can start the consumer before kmo finishes; use the file approach when a failed read must prevent the operation from starting.
Keep tracing (set -x), tee, verbose HTTP output, file previews, secret diffs, and environment dumps out of this workflow. Do not use eval or source on vault contents. Parse secret JSON locally with its output routed to the destination, without showing it to the model. Consumer output, diagnostics, or logs can still expose credentials: redirection is not an automatic redactor.
Run kmo lock after finishing and remove temporary files you created. Unlike MCP's managed exports, files saved by shell redirection or kmo attachment get remain on disk after lock. Retain intended production files with appropriate permissions. File deletion is not guaranteed secure erasure on SSDs or backed-up storage.
The plugin is handling guidance, not an isolation boundary. An agent with shell access can still read an unlocked vault or local files. These patterns keep values out of normal tool output; they cannot guarantee that a misbehaving agent or program will not expose them.
MCP integration (not recommended for secret handling)
The CLI's existing MCP server remains available for compatibility. Its read_secret tool returns plaintext to the model, and inline secret writes also put plaintext in the session. For workflows that keep secret values out of chat, use the CLI and plugin workflow instead.
MCP itself does not require secret disclosure: export_attachment already returns a path and hash, not file contents. A future integration could provide file-based secret input/output too. The existing secret-reading tool cannot avoid putting the value in its result.
kmo mcp speaks the Model Context Protocol on stdio. Sign in and unlock in your own terminal first; the MCP server picks up a new unlock without restarting the agent. The MCP server never unlocks the vault itself and has no tool for it.
By default the MCP server will not reveal secrets or attachments: read_secret and export_attachment refuse, and its guidance never points the agent at CLI reveal commands. Add --allow-reveal to let it call them. This flag is a policy for the MCP tools, not a security boundary: an agent that can also run shell commands could run kmo secret --raw itself while your vault is unlocked. If you need an enforced boundary against agent access, keep the unlocked vault outside the agent’s shell permissions. The CLI/plugin patterns above are handling guidance rather than that boundary. Add --allow-write (with a token from kmo login --scope write) to let it create assets and edit assets you created; only add it to configurations that need it.
Claude Code
claude mcp add kmo -- kmo mcp
OpenCode (opencode.json)
{
"mcp": {
"kmo": {
"type": "local",
"command": ["kmo", "mcp"],
"enabled": true
}
}
}
Cursor (.cursor/mcp.json) and other clients using the common JSON format
{
"mcpServers": {
"kmo": {
"command": "kmo",
"args": ["mcp"]
}
}
}
| Tool | Purpose |
|---|---|
kmo_status | Sign-in, scope, teams, seconds left on the lease, and team vault key leases (ringLeases) |
list_teams, search_assets, get_asset | Find an asset and read its guide (marked as untrusted content), attachments and your access |
request_access, list_access_requests, verify_dns | Successor access requests, with approval times and DNS records |
read_secret | Decrypt and verify a secret (--allow-reveal only). Every call is a fresh read on the server, recorded and notified like a read on the website |
export_attachment | Decrypt an attachment into a private export directory and return its path and SHA-256, never its bytes (--allow-reveal only). Recorded and notified like read_secret |
create_asset, update_asset | Write tools (--allow-write only). Attached files must be inside --attach-root (default: the agent's working directory, refused when that is your home directory, a folder containing it such as /home or C:\Users, or the root of a drive). Files in kmo's config directory and in any export directory recorded by any kmo process or profile (including other MCP servers with a different --export-dir) are never attached |
lock | End the lease and delete exported files |
Exports are written with private permissions to <config>/exports/<lease id>/, or a per-lease folder under --export-dir. The export directory must belong to you and not be writable by other users, and every folder above it must belong to you or to root and not be writable by other users unless it is sticky like /tmp (the same rule as OpenSSH's StrictModes; a group-writable folder is accepted when the group is your own private group). That way no other account can rename the folder or swap it for a link while files are written. kmo creates each per-lease folder itself and only ever deletes folders it created: if a folder with that name already exists under --export-dir, the export is refused and the folder is left alone. On Windows the ancestor and directory checks are best effort; the default location under %APPDATA% is private to you. From CLI 0.5, newly created files receive and verify a protected owner-only ACL before contents are written. Existing profile files and directory ACLs retain the previous best-effort handling.
Exported files last only as long as their lease. The lock tool, kmo lock, kmo logout and a new kmo unlock delete every export of the profile, whichever process wrote it. When a lease expires or is revoked, only that lease's exports are deleted, never those of a newer lease: a running MCP server deletes them within moments of the expiry and within about 30 seconds of a revocation on the server (such as revoking the device in Account Security), and otherwise the next kmo command (any command, including kmo status) or the next start of kmo mcp does. If no kmo process runs after the lease expires, the files stay on disk until the next kmo invocation, so run kmo lock when you finish. An asset whose parts are encrypted to different keys you unlocked, such as your own identity and a team vault key, is never exported: no single lease covers it, so export_attachment refuses with export_spans_leases and writes nothing. read_secret still works. When the lease runs out, tools return locked, say that earlier exports were deleted, and the agent asks you to run kmo unlock again and re-exports what it still needs.
MCP guidance, hints and error messages point the agent only at MCP tools. The one exception is asking you to run kmo unlock or kmo login in your own terminal.
Walkthrough: a break-glass restore with an agent
Suppose the person who runs your GitLab cluster is unavailable and you are their enrolled Successor.
- Download kmo and the Claude Code plugin. In your own terminal, sign in with your own account using
kmo login. Approve the code and select the required team. - Ask your agent to find the GitLab recovery runbook and plan the restore without printing secrets. It uses
kmo list --search GitLab --jsonandkmo show ASSET_ID --jsonto read the instructions and access state. - If access is pending, authorize the request. The agent uses
kmo access request ASSET_ID, explains the existing Gatekeeper, delay, or DNS requirement, and waits. Unlocking never bypasses these gates. - When access is approved, the agent asks you to run
kmo unlock --browser --ttl 15min your own terminal. If a team vault key is required, usekmo unlock --keyring KEYRING --team TEAM --ttl 15minstead. - The agent follows the authorized plan. It passes secrets directly into private credential files or consuming processes, and retrieves attachments with
kmo attachment get ASSET_ID gitlab-secrets.json -o /secure/gitlab-secrets.json. It never displays their contents. Review destructive restore steps within your existing authorization. - Validate recovery without displaying credentials, clean up temporary files, and run
kmo lock. Files placed in production remain where the restore needs them. The same server-side access audit and email notifications apply as for a web read.
Security notes
- The agent sees what it reveals. With
--allow-reveal, a secret read by the agent is part of its conversation. Cloud-hosted models send it to the provider, which may keep transcripts. Leave--allow-revealoff unless the task needs it, and rotate any secret an agent handled once the emergency is over. - Instructions are untrusted. Guides are written by team members. The MCP server tells agents not to follow directions in them that would reveal other assets, send data elsewhere, or change access, but a model can still be misled. Watch what the agent does.
- Approve only your own unlocks. A browser unlock hands your identity to the kmo that started it. The code, the device details on the page, the 5-minute single-use request and the email are there so you can spot one you didn't start. The one-time key travels only in the link's
#part, so the server can't read what the page sends to kmo. - A lease is not a sandbox. While unlocked, any program running as your user can use
kmoor read the lease files. Leases limit how long a stolen copy is useful; they do not protect an already compromised computer. Keep TTLs short and runkmo lockwhen done. - Access rules are unchanged. The CLI uses the same membership, guardian and approval checks as the website, and reads trigger the same notifications. Approving access requests, managing guardians, enrollment, rotation, team administration, billing and account changes are web-only.
- Tokens are scoped. A device token reaches only the teams you ticked, with the access you granted, for at most 30 days. Revoke it in Account Security if a computer is lost. Resetting or changing your password also revokes every CLI token and lease. Tokens and lease keys never appear in URLs, logs or
--jsonoutput. - Terminal output is sanitised. Asset names, guides, secrets and other team-written text are printed with terminal control characters removed, so content cannot rewrite your screen or clipboard. When a secret had characters replaced, kmo says so on stderr; use
kmo secret --rawfor the exact bytes (for piping).--jsonoutput is unchanged. - Interrupted writes are reported as
outcome_unknown. If a create or edit was sent but no answer arrived, the change may or may not have been saved. Check withkmo listorkmo showbefore retrying.
See the Security Model for how encryption and approvals work.
