Token VaultDocs
Reference

tvault CLI

Complete command reference for the tvault CLI, covering install, contexts and login, every command with its flags and aliases, output conventions and exit codes.

tvault is the command line for Token Vault. It stores, reads and rotates credentials, manages agents, keys, labels and MCP servers, and connects Claude Code. Values go between the CLI and your webhook with a Token Vault ticket. They never pass through Token Vault.

This reference requires tvault 0.14.0 or later. For a guided tour see Use the tvault CLI. Source and releases: github.com/c-lgrant/tvault.

tvault version

Install

MethodCommand
npmnpm install -g @tvault/cli
Gogo install github.com/c-lgrant/tvault@latest
Shell installer (Linux, macOS; amd64, arm64; SHA256 verified)curl -fsSL https://raw.githubusercontent.com/c-lgrant/tvault/main/install.sh | bash
Release binariesGitHub Releases, tvault_<tag>_<os>_<arch> for linux and darwin, with checksums.txt

The installer honours TVAULT_VERSION (pin a tag) and TVAULT_INSTALL_DIR. The npm package downloads the matching release binary on install and verifies its checksum; TVAULT_SKIP_DOWNLOAD skips that.

Contexts and login

A context is a saved identity plus an API URL. Config lives in ~/.config/tvault/contexts.yaml (mode 0600, or under $XDG_CONFIG_HOME).

TypeLoginWhat it can do
admintvault login (browser)You, as the owner. Everything a signed-in human can do, except changes a Who can read policy makes web-app only (WEB_CONSOLE_REQUIRED). All requests count as the CLI channel
agentan agent key tvagent_...Read the credentials the agent holds. A scoped agent also gets its scopes
keya scoped key tvkey_...The key's scopes

The admin context holds a Token Vault CLI session (tvcli_ access token, tvclr_ refresh token), not a Google or Firebase credential. An admin sign-in lasts 8 hours. After that each command says CLI session ended: an admin sign-in lasts 8 hours, and you run tvault login again. Nothing renews it, so a sign-in that you forget on a machine ends by itself. Agent and key contexts do not expire this way. tvault logout revokes the refresh token server-side.

# Browser login. Name the context with --as (default: default)
tvault login --as me

# Over SSH or headless: paste a code instead of opening a browser
tvault login --as me --no-launch-browser

# A key, from a pipe (preferred: it stays out of shell history)
printf %s "$TVAULT_KEY" | tvault login --key-stdin --as ci
FlagNotes
--as <name>Name the context
--api-url <url>Default https://api.tokenvault.uk. Re-logging in reuses a context's stored URL
--frontend-url <url>Default https://tokenvault.uk. For a custom --api-url it is derived by dropping the api. prefix; the login fails if the host has none
--no-launch-browserPrint a link and paste the code back. Automatic over SSH or without a display
--key-stdinRead a tvagent_ or tvkey_ key from stdin (refuses a terminal, max 64 KiB)
--key <key>The key on the command line. Warned: it lands in history and the process list

Key login needs a context name (--as or --ctx). tvault --ctx dev login re-logs in the dev context.

tvault context list          # alias: ctx ls
tvault use ci                # switch the active context (= ctx use)
tvault --ctx ci get stripe   # one command in another context
tvault whoami                # who am I, which scopes

Select a context for one command with --context <name> or --ctx <name>. The CLI does no local permission check: the server decides.

VariableEffect
XDG_CONFIG_HOME, XDG_DATA_HOMEWhere config and shell completions go
TVAULT_TIMEOUTHTTP timeout in whole seconds (default 30)
TVAULT_CONTEXTPins the shell to one context (tvault 0.15.0). Every command uses it with no flag
TVAULT_CLIENT_LABELA host label for Activity events (tvault 0.16.0). Not set: no label is sent

Each CLI request names the program in the Activity page ("Program" on an event): tvault/<version>, and the label if you set TVAULT_CLIENT_LABEL on that machine, for example tvault/0.16.0 macmini. With it you can tell which machine made a read. You choose the text, and it is stored with the event. Token Vault makes no decision from it.

There is no environment variable for the API URL. It comes from the context.

While TVAULT_CONTEXT is set, --context with another name is refused, and so are login, logout, use, context use, context rm and connect. Set it in the environment of an agent's shell so the shell acts as that agent only. It stops mistakes; it is not a wall, so keep an admin sign-in off a machine where agents run.

Global flags

FlagTypeNotes
--context, --ctxstringUse this context for one command
--formatjson, table, wide, nameDefault: a table on a terminal, JSON when stdout is not a terminal. name prints the first column only
--debugboolPrint HTTP diagnostics to stderr
--dry-runboolPrint the request a write would send, without sending it. GETs still go out
--field <key>stringPrint one field of a composite credential
--kvboolPrint a composite credential as sorted KEY=VALUE lines
--jsonboolPrint the value as-is. Not an output format: use --format json. (Exception: label ls --json prints the raw server JSON)
--no-colorboolAccepted; currently has no effect
-h, --help

tvault <service> is a shortcut for tvault get <service>. tvault alone prints help.

Output and exit codes

  • stdout carries only values and data: credential values, new key secrets, --format renders, resulting label sets. Status lines, warnings, prompts, empty-state messages and [dry-run] output go to stderr. Capture a secret with KEY=$(tvault keys create ...).
  • A denial prints two lines on stderr: denied: ... and hint: .... See Denials.
  • Exit codes are listed on Errors and exit codes. Short form: 0 ok, 1 user error, 2 auth, 3 network, 4 server, 5 vault locked, 6 empty, 7 rate limited, 8 scope denied, 9 human only, 10 key expired, 11 key or agent suspended, 12 invalid key.

Credentials

Aliases: credentials and creds are tokens list; tokens is also tk.

tvault add <service>

Store a new credential. The value goes straight to your webhook.

From tvault 0.14.1, add only creates. If the name already exists, it stops with 409 TOKEN_EXISTS and the stored value does not change. To replace a value, use tvault set <service>. Earlier versions replaced the value.

printf %s "$SECRET" | tvault add stripe
tvault add stripe --for my-agent --yes
printf %s "$PAT" | tvault add github --mcp github --for my-agent=mcp --yes
tvault add home-hub --sign-in https://hub.example.com/mcp --for my-agent=mcp --yes
FlagTypeNotes
--for <agent>[=<uses>[:<servers>]]repeatableAfter storing, grant the credential to this agent (created if missing). my-agent is a value grant. my-agent=mcp, my-agent=value,mcp:github choose uses and MCP servers. Repeat for several agents
--labels a,blistAfter storing, label the credential
--mcp <preset>stringAfter storing, attach this MCP server preset (see tvault mcp-servers templates)
--sign-in <url>stringMake a Token Vault sign-in credential for the MCP server at this https URL. No value is read or stored. Creates the credential, sets the MCP server (header Authorization: Bearer ${AGENT_SESSION}) and applies the grants. Only MCP access fits: a plain --for <agent> means MCP access, and --for <agent>=value is refused before any call. Can't be combined with --value, --value-stdin, --type, --mcp or --labels (label it afterwards). Needs a recent sign-in
--server <name>stringWith --sign-in: the MCP server's name on the credential. Default mcp
--typestringDefault PlainText. Others: JWT, Certificate, SSHKey, RawCredential, TOTP
--valuestringThe value on the command line. Warned: it lands in history
--value-stdinboolRead the value from stdin (also the default when stdin is not a terminal)
--yesboolWith --for: create a missing agent without asking

Order of operations:

  1. Resolve or create every --for agent, and check the --mcp preset exists. All before the value is read, so a typo costs nothing.
  2. Store the value with a ticket.
  3. Attach the --mcp preset.
  4. Apply the grants.
  5. Apply the labels.

Grants run before labels so a label failure cannot block access. If a later step fails, the credential stays stored and the retry command is printed. With --sign-in there is no value step: the order is resolve agents, create the credential, set the MCP server, then apply grants. If setting the MCP server fails, the credential stays and the mcp-servers add and grant retry commands are printed. tvault ls shows the kind as "Token Vault sign-in". tvault get and tvault set on a sign-in credential exit 6 ("credential has no value") and print nothing on stdout. A grant with value fails with SIGNIN_TOOLS_ONLY.

New agents have no MCP switch to set, and their key is not printed.

Value input: a hidden prompt on a terminal; stdin otherwise (one trailing newline trimmed, max 1 MiB). An empty value creates a placeholder, and the CLI prints how to fill it.

tvault get <service>

Print a credential value to stdout, safe for $(...). service.field reads one field of a composite credential (split at the first dot, so avoid dots in credential names you read this way).

FlagNotes
--checkExit 0 if the credential has a value, 6 if empty. Never prints the value
--field, --kvSee global flags
curl -H "Authorization: Bearer $(tvault get github)" https://api.github.com/user
tvault get github --check >/dev/null 2>&1 && echo present

An admin context reads with a credential ticket and fetches from the webhook. An agent or key context calls GET /api/agents/credentials and follows the 307.

tvault set <service> (also tokens set, alias tokens up)

Rotate a credential's value. Same value input as add (--value, --value-stdin, or the prompt). Keeps the credential's type.

tvault list (alias ls), credentials (creds)

Columns: service, type. JSON includes the same keys.

tvault show <service> (also tokens show, alias tokens info)

Metadata only: service, type, display name, notes, tags.

tvault history <service>

Recent events for a credential (tokens history, alias hist). Columns: timestamp, event, actor.

tvault rm <service>... (also tokens rm, aliases tokens del, tokens d)

Delete credentials. --force skips the confirmation (required without a terminal).

Other tokens subcommands

CommandNotes
tokens create (new)Wizard on a terminal. Flags --service, --type, --value, --value-stdin. add is the shortcut
tokens edit <service>Metadata only: --name, --notes, --tags a,b. At least one
tokens refresh <service> (ref)Ask the webhook to refresh an OAuth token now. See Token refresh
tokens store-ticket <service>Print a store ticket envelope {service, webhookUrl, ticket, expiresIn}. With --value it stores directly. --type default PlainText

Agents

Aliases: agents is ag.

CommandFlagsNotes
agents create (new)--name, --kind classic|scoped, --scopes a,b, --grants a,b, --non-interactivePrints the key once, to stdout. Wizard if --name is missing on a terminal. --grants are value grants
agents list (ls)Columns: name, status, last_active, id. wide adds accesses
agents show <name-or-id> (info)Includes the granted service names only. It does not show uses or MCP servers
agents rotate-key <name-or-id>--self--self rotates the key this agent context uses and switches to the new key. Rotating another agent's key needs a signed-in human
agents suspend <name-or-id> (off)
agents resume <name-or-id> (on)
agents rm <name-or-id>... (del, d)--force
agents grants add <agent> <spec>...Same as tvault grant
agents grants list <agent> (ls)One row per entry (the value, each MCP server) with when it ends
agents grants rm <agent> <service>...--forceStops at the first failure

Agents and keys resolve by name or id. A 20-character alphanumeric argument that is also another principal's name is refused as ambiguous.

Grants

tvault grant <agent> <service>[=<uses>[:<servers>]]...

Give an agent access to credentials. The agent comes first and is required.

SpecMeaning
githubValue grant (the default)
github=mcpMCP access only, every MCP server the credential has now (not ones added later)
github=value,mcpBoth
github=mcp:github,docsMCP access limited to the named MCP servers
tvault grant claude-code github                         # value
tvault grant claude-code github=mcp                     # MCP access only
tvault grant claude-code github=value,mcp:github
tvault grant claude-code github=mcp:github linear=mcp

uses are value and mcp. MCP access is written tools in the API, and the CLI accepts tools as another spelling of mcp (it always sends tools). servers are MCP servers and can only be named with mcp. A bad spec exits 1 with the expected form. This is POST /api/agents/{id}/grants once per spec: see the Grants API.

Keys have their own commands, and keys get value grants only:

CommandFlags
keys grant <key> <service>--expires-in-hours <n> (default 0, no expiry)
keys ungrant <key> <service>

Asking for access

A key or agent never gives itself access. It asks, and the owner decides on a page in the web app. The link it prints grants nothing by itself. A request expires after one hour.

CommandFlagsNotes
access request <service>[=<uses>[:<servers>]]...--reason (required), --for <agent>, --expires <12h|7d|never>, --uses, --servers, --wait <10m>One grant action per credential. --for asks for another agent. --expires applies to every part it names, at most 30 days
access plan <file|->--reason, --waitAny list of changes: revoke, change_grant, labels, scopes, policies, MCP servers, new agents
access actionsEvery action type the server takes, with its fields. Read it before writing a plan
access status <request-id>What happened to each action, and to each part of a grant
access drop <service>...--forceGive up your own grants. No approval needed
tvault access request github=mcp:main --for ci-bot --expires 7d --reason "ci reads issues" --wait 10m
tvault access actions

The owner can untick any action and change when each part of a grant ends. A grant adds to what the agent holds and never shortens a part it already has. With --wait, the exit code is 0 when approved, 15 when denied and 16 when the request expires or the wait runs out.

Keys

Aliases: keys is key. Scoped keys (tvkey_) are API keys limited to a list of scopes. The secret prints once, on stdout.

CommandFlagsNotes
keys create (new)--name (required), --scopes a,b (required), --expires <30d|90d|365d|YYYY-MM-DD|never> (default 90d)Any <n>d works. A date expires 23:59:59 UTC that day
keys ls (list)Columns: id, name, status, scopes, expires, last_used
keys show <id-or-name> (info)Adds created_by and grants
keys rotate <id-or-name>--self--self also switches the active key context to the new key
keys revoke <id-or-name> (rm)--force, -y/--yesRequired without a terminal
KEY=$(tvault keys create --name ci --scopes credentials:read --expires 30d)
tvault keys grant ci stripe

Labels

A label is a tag (1 to 32 lowercase letters, digits or hyphens) on a credential, an agent or a key. A policy attached to a label applies to every object that carries it. A label never grants access. See the Labels API and Labels.

CommandBehaviour
label ls (list)Columns: label, credentials, agents, keys, policies. --json prints the raw server JSON
label set <kind> <id> <label>...Replace the set exactly
label add <kind> <id> <label>...Union with the current set. Prints "No change" if nothing changed
label rm <kind> <id> <label>... (remove)Remove. A label that has policies needs policies:write (exit 8), and a key or agent cannot remove one from itself or from a credential it holds

<kind> is credential (also cred, token), agent or key (also api_key). Labels are lower-cased, trimmed and de-duplicated before sending. The resulting set prints to stdout, one per line.

tvault label set credential github prod finance
tvault label set agent ci-bot prod

Policies

Attach an existing policy. Policies are created in the web app.

tvault policy attach 3f9c1ae2b7d44e0f8a21c5d6e9b07a13 --label prod
tvault policy attach 3f9c1ae2b7d44e0f8a21c5d6e9b07a13 --agent ci-bot --credential github
tvault policy detach 3f9c1ae2b7d44e0f8a21c5d6e9b07a13 --label prod
Flag (repeatable on attach and detach)Target
--labelA label
--credentialA credential name
--agentAn agent name or id
--keyA key name or id

At least one target is required. Detaching loosens controls, so it needs policies:write, and a signed-in human for protected policies. Alias: policies.

MCP servers

Alias: mcp. A credential can have up to 5 MCP servers. An agent given MCP access calls them through Token Vault without the value. Header templates mark the credential's place with the literal ${TOKEN}: single-quote it so your shell leaves it alone. Only the template is sent to Token Vault. See the MCP servers API.

tvault mcp-servers templates
tvault mcp-servers add github --preset github
tvault mcp-servers add github --name docs --url https://mcp.example.com/mcp \
  --header 'Authorization: Bearer ${TOKEN}' --header 'Accept: application/json, text/event-stream'
tvault mcp-servers ls github
tvault mcp-servers rm github docs
CommandFlagsNotes
mcp-servers add <service>--preset <id>, --name, --url, --header 'Name: value' (repeatable)Upserts by name. Header flags replace preset headers of the same name. One header must hold ${TOKEN} (${AGENT_SESSION} on a sign-in credential). Needs a recent sign-in; an admin terminal asks you to sign in again once. Prints the server's endpoint and the grant command
mcp-servers list <service> (ls)Columns: name, url, template, tools (count, pending or an error), endpoint. wide adds headers
mcp-servers rm <service> <name> (remove)--forceGrants that name the MCP server keep the stale name
mcp-servers templatesid, name, url of the presets

From an agent or key context, add and rm refuse (exit 9) when MCP servers already exist, because those callers see redacted lists and would overwrite them.

Connect Claude Code

tvault connect <agent> [<service>[=<uses>[:<servers>]]...]

Create the agent if needed, grant the services, and register Token Vault as an MCP server in Claude Code. Claude Code only. For other apps see Connect your apps.

FlagNotes
--server <service>/<server>Add one credential MCP server as its own Claude Code entry, with the MCP server URL
--name <entry>Entry name with --server. Default tokenvault-<service>-<server>
--printPrint the claude mcp add command and run nothing
--no-claudeDo not look for or touch Claude Code
--yesCreate the agent without asking
tvault connect my-agent github stripe
tvault connect my-agent github=mcp:github --server github/github

Default entry: claude mcp add --transport http --scope user tokenvault https://api.tokenvault.uk/api/agents/mcp. An entry that already has the URL is left alone. One with a different URL is never replaced: the CLI prints claude mcp remove and the add command. The agent's key is not printed. Finish in Claude Code: run /mcp, sign in, and pick the agent.

Session, vault and utilities

CommandNotes
login, logoutSee Contexts and login
whoami (who)Text to stderr. --format json prints {context, type, identity, apiUrl, principal, userId, kind, scopes, expiresAt} to stdout
context list (ls) / current / use <name> / rm <name> (delete)current prints the name to stdout (exit 2 if none). rm is local only
use <name>Same as context use
auth print-tokenadmin only. Prints the session access token to stdout. Treat it as a secret
vault lock / unlock / status (stat)The kill switch. admin only
explain <CODE>What an error code means and the fix. Case-insensitive. An unknown code lists the known ones. Output goes to stderr
versiontvault <version> (commit <sha>, built <date>)
completion <bash|zsh|fish|powershell>Print the completion script
completion install [shell]Write it where your shell loads it. --print-only shows the path. Never edits rc files, so zsh still needs the fpath= line it prints. PowerShell is not supported for install
completion uninstall [shell]

Dynamic completion calls the API to complete service, agent and context names.

Webhook helpers

Alias: webhook is wh.

CommandNotes
webhook bindBind the running webhook to your account without a browser
webhook status (stat)Token Vault's view of the webhook, plus a direct /v1/health check

For production use Self-host your webhook.

Notes

  • No proxy, folder or group commands. MCP servers replaced proxies; labels replaced folders. Convert old MCP connections in the web app (details).
  • tvault explain knows SIGNIN_NO_VALUE, SIGNIN_TOOLS_ONLY, SIGNIN_URL_ON_TOKEN_VAULT, MCP_KEY_RETIRED, PROXY_CREATE_REMOVED, PROXY_FROZEN and MCP_TOGGLE_REMOVED.
  • tvault rm and the other destructive commands refuse to run without a terminal unless you pass --force.
  • Argument-count errors print the command's help and exit 0.
  • Parallel tvault get calls from one admin login share a cached session, so a script that loops over get refreshes it once.

Ready to try it?

Sign in with Google or email. Your credentials stay on your own webhook, and the quickstart gets Claude Code making its first MCP tool call in about 15 minutes.

On this page