Skip to content

Command-line client

A command-line client for Corpus. Every path names its vault — work:notes/todo — so a command never acts on the wrong one. It sends each command to the MCP endpoint with an API key, so it can do what the key's scope allows. The commands below are generated from the CLI's own catalogue.

Install

Requires Node 22 or newer.

npm install -g @schupke/corpus-cli

Sign in

Create an API key in Integrations → API keys. corpus login asks for it without showing it, checks it against the server, and stores it with the server's address under a profile. --profile, --dev and --prod pick a profile for one command; corpus use makes one the default.

corpus login --url https://api.corpus.schupke.io
corpus whoami

Paths

A path starts with its vault: work:notes/todo. Only the first colon divides, so a note name may contain more. work:notes/todo.md is the same note, and paths are always printed without the extension. A trailing slash marks a folder, and work: alone is the vault's root. A path without a vault is refused.

Output

Listings and search results print one record per line on stdout, never coloured or aligned. -l switches to tab-separated long form, -0 to NUL-separated records for xargs -0, and --json to the raw payload. Errors go to stderr, and so do summaries when stderr is a terminal.

open prints a Markdown note's exact bytes and a spreadsheet as tab-separated values. A drawing has no text, so open refuses one.

Configuration

Profiles are stored in ~/.config/corpus/config.json (under XDG_CONFIG_HOME when it is set), readable only by you. CORPUS_URL and CORPUS_TOKEN override the stored values, and --url and --token override both. CORPUS_DEBUG turns on --verbose.

Exit codes

The exit status says what went wrong, so a script can tell a missing note from a failed connection.

CodeMeaning
0Done.
1Internal error.
2Usage: an unknown command or flag, or a folder given without -r.
3No API key, or the server rejected it.
4The API key has read scope and the command writes.
5The server refused the operation.
6Network failure, timeout, rate limit or server error.
7The config file is unreadable, malformed or written by a newer CLI.
8No note or folder at that path.
9Something already exists at the destination.
130Interrupted.

Global options

Every command accepts these, in any position.

FlagTypeDescription
--urlvalueserver origin, or the full /api/mcp endpoint
--tokenvaluecorpus_pat_… API key; also read from CORPUS_TOKEN
--profilevalueuse a named profile from the config
--localflagshorthand for --url http://localhost:4283
--devflaguse the 'dev' profile
--prodflaguse the 'prod' profile
--timeoutvalueper-request timeout in ms (default 30000; 0 disables)
--jsonflagprint the raw payload as JSON instead of formatted records
-0, --nullflagseparate output records with NUL, for xargs -0
-y, --yesflagassume yes for confirmations
-q, --quietflagsuppress the stderr summaries
--refreshflagignore the cached tool list
--no-colorflagnever colour stderr (NO_COLOR is honoured too)
--verboseflagprint diagnostics; also enabled by CORPUS_DEBUG
-h, --helpflagshow this help, or a command's help
-V, --versionflagprint the version

Commands

Vault

corpus vaults

list the vaults, and what others share with you, each as VAULT: — where paths start
corpus vaults [-l]
FlagTypeDescription
-l, --longflagprint name, id, and whether it is personal or shared with you

corpus ls

list the entries in a folder
corpus ls [VAULT:PATH] [-R] [-l] [-d|-f] [--depth N]
FlagTypeDescription
-R, --recursiveflagdescend into subfolders, printing full paths instead of basenames
-l, --longflagprint kind and path, tab-separated
-d, --dirs-onlyflaglist folders only
-f, --files-onlyflaglist notes only
--depthvaluehow many levels to descend

corpus tree

list a folder and everything under it, one path per line
corpus tree VAULT:[PATH] [--depth N] [-d]
FlagTypeDescription
--depthvaluehow many levels to descend
-d, --dirs-onlyflaglist folders only

corpus open

print a note's markdown to stdout byte for byte, or a spreadsheet as TSValias cat
corpus open VAULT:PATH... [--header] [--ignore-missing]
FlagTypeDescription
--headerflagprint a ==> path <== header before each note
--ignore-missingflagskip paths that do not exist instead of failing

corpus stat

report whether a path is a note or a folder
corpus stat VAULT:PATH

Takes no options of its own.

corpus create

create a note, making any missing folderswrite key
corpus create VAULT:PATH [--text S | --file F | -] [--force]
FlagTypeDescription
--textvaluetake the content from this argument
--filevaluetake the content from a local file (- for stdin)
--forceflagoverwrite the note when it already exists
--allow-emptyflagpermit empty content, which is otherwise refused

corpus mkdir

create a folder, making any missing parentswrite key
corpus mkdir VAULT:PATH... [-p]
FlagTypeDescription
-p, --parentsflagcreate missing parents, and succeed if it already exists

corpus write

overwrite a note's body from stdin, --text, or --filewrite key
corpus write VAULT:PATH [--text S | --file F] [--allow-empty]
FlagTypeDescription
--textvaluetake the content from this argument
--filevaluetake the content from a local file (- for stdin)
--allow-emptyflagpermit empty content, which is otherwise refused

corpus append

append to a notewrite key
corpus append VAULT:PATH [--text S | --file F | -] [--no-newline]
FlagTypeDescription
--textvaluetake the content from this argument
--filevaluetake the content from a local file (- for stdin)
--no-newlineflagdo not insert a newline before the appended text

corpus replace

substitute text inside a notewrite key
corpus replace VAULT:PATH FIND SUB [--regex] [--ignore-case] [--count N] [--dry-run] [-l]
FlagTypeDescription
--regexflagtreat the pattern as a regular expression, matched per line
--ignore-caseflagmatch without regard to case
--countvaluestop after this many replacements
--dry-runflagreport what would change without writing
-l, --longflagprint each replacement as path<TAB>line<TAB>text

corpus mv

move or rename notes and folders within a vaultalias movewrite key
corpus mv VAULT:SRC VAULT:DEST   |   corpus mv VAULT:SRC... VAULT:DESTDIR/
FlagTypeDescription
-l, --longflagprint each move as from<TAB>to
--from-stdinflagread the paths to act on from stdin, one per line

corpus rm

move notes and folders to the trashalias deletewrite key
corpus rm VAULT:PATH... [-r] [-f] [-i] [--file | --dir]
FlagTypeDescription
-r, --recursiveflagallow deleting a folder and everything under it
-f, --forceflagignore paths that do not exist, and never prompt
-i, --interactiveflagconfirm before each deletion
--fileflagtreat the path as a note, instead of inferring its kind
--dirflagtreat the path as a folder, instead of inferring its kind
--from-stdinflagread the paths to act on from stdin, one per line

corpus versions

list a note's saved versions, newest first
corpus versions VAULT:PATH

Takes no options of its own.

corpus show-version

print the stored body of one saved version
corpus show-version VERSION_ID

Takes no options of its own.

corpus restore

make a saved version current againwrite key
corpus restore VERSION_ID

Takes no options of its own.

corpus save-version

keep a note as it is now as a version in its historywrite key
corpus save-version VAULT:PATH

Takes no options of its own.

corpus tags

list and manage the tags of one vault
corpus tags VAULT [-l] | corpus tags VAULT add NAME [--color C] | corpus tags VAULT rm NAME | corpus tags VAULT rename OLD NEW | corpus tags VAULT color NAME C|none
FlagTypeDescription
-l, --longflagprint name, colour and use counts, tab-separated
--colorvaluehex colour for add, e.g. '#3b82f6'
--unusedflaglist only tags nothing carries

corpus tag

show or change the tags on one note or folderwrite key
corpus tag VAULT:PATH [-a NAME]… [-r NAME]… [--set NAMES] [-d|-f]
FlagTypeDescription
-a, --addvalueadd a tag, creating it if new; repeatable, or comma-separated
-r, --removevalueremove a tag from this note or folder; the tag itself stays in the vault
--setvaluereplace the whole set with this comma-separated list
-d, --dirs-onlyflagtreat PATH as a folder
-f, --files-onlyflagtreat PATH as a note

corpus star

star noteswrite key
corpus star VAULT:PATH...

Takes no options of its own.

corpus unstar

unstar noteswrite key
corpus unstar VAULT:PATH...

Takes no options of its own.

corpus starred

list starred notes in every vault, most recently edited first
corpus starred [-l]
FlagTypeDescription
-l, --longflagprint kind and path, tab-separated

corpus usage

show what the account stores against its storage limit
corpus usage [--human]
FlagTypeDescription
--humanflagprint sizes in KiB/MiB/GiB instead of bytes

Auth and profiles

corpus login

store an API key for a corpus server
corpus login [--url URL | --local] [--dev | --prod | --profile NAME] [--token PAT]

Takes no options of its own.

corpus logout

revoke a stored API key and forget it
corpus logout [--dev | --prod | --profile NAME] [--all]
FlagTypeDescription
--allflagremove every stored profile, not just the current one

corpus status

show the configured server and API key, without contacting it
corpus status [--dev | --prod | --profile NAME]

Takes no options of its own.

corpus whoami

report what this API key can do (cached; --refresh to re-check)
corpus whoami [--dev | --prod | --profile NAME] [--refresh]

Takes no options of its own.

corpus profiles

list stored profiles
corpus profiles

Takes no options of its own.

corpus use

make a profile the default
corpus use PROFILE

Takes no options of its own.

corpus tools

list the tools this API key is granted
corpus tools

Takes no options of its own.