CLI reference
Every subcommand of the mushroomdb binary. Each usage block is what mushroomdb --help
prints for it; the text under it is what the help leaves out.
Set up an assistant
install
mushroomdb install [--platform claude-code|cursor|codex|all] [--project|--user] [--db <path>]
[--command <path>] [--no-prewarm] [--delivery cli|mcp|both]
[--always-load|--no-always-load]
--delivery cli writes the skill and the hooks and registers no MCP
server: the skill teaches `mushroomdb <command>` instead (claude-code
only; cursor and codex are always registered as MCP servers)
--always-load marks the registered MCP server alwaysLoad, so the host
keeps its tools in context instead of deferring them; already the
default when --db names a store and a server is registered
(--delivery mcp|both) — --no-always-load opts out
Write the /mushroom skill + MCP server entry + the SessionStart and UserPromptSubmit hooks. Auto-detects platform and scope. --delivery cli writes no server entry: the skill teaches the binary instead. alwaysLoad on the server entry is on by default for an install that pins a store with --db. An install over a 0.6 one removes the hooks and git hook blocks 0.7 no longer ships
uninstall
mushroomdb uninstall [--platform claude-code|cursor|codex|all] [--project|--user] [--db <path>]
Remove exactly what install wrote (manifest-driven; leaves user files)
disable
mushroomdb disable [--platform claude-code|cursor|codex|all] [--project|--user]
turn an install off without removing it: hooks and MCP entry are
removed; the skill, the store and .gitignore stay
Turn an install off without removing it: strips the MCP entry, the hooks, and any git hook block a 0.6 install wrote. The skill, the store and .gitignore stay
enable
mushroomdb enable [--platform claude-code|cursor|codex|all] [--project|--user]
turn a disabled install back on
Turn a disabled install back on, re-resolving the command instead of replaying what disable removed
doctor
mushroomdb doctor [--project|--user] [--platform claude-code|cursor|codex|all]
verify an install: config entry, store, hooks, and a real stdio
handshake with the configured MCP command; exits 1 on any `fail`
Verify an install: config entry, npx reachability, store, lock, hooks, a 0.6 git hook left behind, a real stdio handshake, and duplicate-scope servers. Exit 1 on any fail
Serve a store
serve
mushroomdb serve <db-dir> [--addr 127.0.0.1:8080] [--token <secret>] [--role-token TOKEN:ROLE] [--ui <dist-dir>] [--no-ui] [--demo-if-empty] [--snapshot-every <secs>] [--shutdown-timeout-secs <secs>] [--restore-from <dir>] [--tls-cert <pem> --tls-key <pem>]
[--bolt-port <port>] [--bolt-tls | --bolt-plaintext] [--bolt-advertised-host <host>] [--bolt-advertised-port <port>]
[--bolt-database <name>] [--bolt-max-connections <n>] [--bolt-tx-timeout-secs <secs>] [--bookmark-timeout-secs <secs>]
[--tx-max <n>] [--tx-timeout-secs <secs>] [--tx-max-lifetime-secs <secs>]
--restore-from seeds an empty <db-dir> from the newest backup under <dir>
(or from <dir> itself if it is one); a no-op when <db-dir> already holds a store
MUSHROOMDB_RESTORE_FROM_S3=s3://bucket/prefix restores the newest backup there into an
empty <db-dir> before the port is bound, as a new lineage that keeps backing up beside
it; a prefix with no backup starts an empty store, any other failure exits 1
--tls-cert and --tls-key go together and need a build with the `tls` feature
--bolt-port (or MUSHROOMDB_BOLT_PORT) also serves Bolt on --addr's IP; off when unset
Bolt is TLS when --tls-cert is given, unless --bolt-plaintext (MUSHROOMDB_BOLT_TLS=on|off)
--bolt-advertised-host/-port (MUSHROOMDB_BOLT_ADVERTISED_HOST/_PORT) are the address ROUTE
hands drivers; a wildcard --addr needs the host. --bolt-max-connections (default 256,
MUSHROOMDB_BOLT_MAX_CONNECTIONS); --bolt-database names the store (default mushroomdb);
--bolt-tx-timeout-secs (default 30) ends an idle transaction; --bookmark-timeout-secs
(default 5) bounds a bookmark wait
--tx-max (default 100) open HTTP transactions at once; --tx-timeout-secs (default 30)
ends an idle one and --tx-max-lifetime-secs (default 300) any one; each flag wins over
MUSHROOMDB_TX_MAX, MUSHROOMDB_TX_TIMEOUT_SECS and MUSHROOMDB_TX_MAX_LIFETIME_SECS
Start the HTTP server + optional UI (default 127.0.0.1:8080; --token or an admin key on non-loopback; --role-token TOKEN:ROLE). The UI is served only by a build that embeds it (npx, Docker and the release binaries do; cargo install does not). --bolt-port also serves Bolt on --addr’s IP, with the same credentials, and TLS when --tls-cert is given; see Bolt protocol for the --bolt-* flags and their variables. --tx-max, --tx-timeout-secs and --tx-max-lifetime-secs set the limits on HTTP transactions, each winning over its environment variable
mcp
mushroomdb mcp <db-dir>|--auto [--all-tools]
--all-tools lists every served tool; the default lists the association tools on every store,
a store `ingest-git` built included (the rest stay callable, just unlisted)
Start a stdio MCP JSON-RPC server for agent tools. --all-tools lists all 25 served tools; the default lists 23
Ask a store
query
mushroomdb query <db-dir> [--query "MATCH ..."|--file <path>|--stdin] [--role <name>] [--namespace <ns>] <cypher…>
--file reads the statement from a file and --stdin from standard input,
so a quote or a backslash needs no shell escaping; a trailing newline
and one trailing `;` are dropped, and the statement comes from only one of the three places
--role answers as one of the store's roles and --namespace from one
namespace; together they intersect, so neither ever widens the other
and either one makes the query a read
Run a Cypher read or write (--query also accepted). Pass the statement in shell double quotes: single-quote Cypher strings; inside the double quotes backslash every dollar sign, double quote and backtick. --role <name> answers as one of the store’s roles and --namespace <ns> from one namespace; together they intersect, so neither widens the other, and either makes the query a read
asof
mushroomdb asof <db-dir> --commit N|--at <date> [--query "MATCH ..."|--file <path>|--stdin] [--namespace <ns>]
--at takes an RFC 3339 date (2026-06-19, or 2026-06-19T12:00:00Z)
and resolves to the last commit at or before it; exactly one of
--commit and --at
Read-only view at a WAL commit or at a date (2026-06-19, or RFC 3339): the last commit at or before it. Exactly one of the two. --namespace <ns> reads one namespace as it was then
why
mushroomdb why <db-dir> <a> <b>
every rule edge between two keys with the evidence that
derived it, or a note that there is none
Every rule edge between two keys with the evidence that derived it, or a note that there is none (the shell form of explain_association)
stats
mushroomdb stats <db-dir>
Print node/edge/rule counts, plus a namespaces: line once a store has more than the implicit default one
suggest
mushroomdb suggest <db-dir>
Rank candidate linking rules (scored top-k 32, KeyMatch 512)
algo
mushroomdb algo pagerank <db-dir> [--top N] [--dir out|in|both]
mushroomdb algo wcc <db-dir> [--top N]
mushroomdb algo degree <db-dir> [--top N] [--dir out|in|both]
mushroomdb algo communities <db-dir> [--edge-type T]... [--weight-prop P] [--min-weight X] [--top N]
pagerank/wcc/degree: PageRank, weakly-connected components, or degree centrality over manual + derived edges. These three subcommands do not accept --weight-prop or --min-weight.
communities: Louvain community detection with per-community cohesion and overall modularity; accepts --edge-type (repeatable), --weight-prop and --min-weight.
Build and maintain a store
demo
mushroomdb demo <db-dir>
Write a deterministic demo graph (10 Orgs, 20 Projects, 30 People)
ingest-git
mushroomdb ingest-git <db-dir> <repo-dir> [--exclude <pattern>]... [--max-commits-per-file N]
[--recurse-submodules] [--prs] [--no-structure] [--no-docs] [--ensure-gitignore]
graph a git repo (authors, commits, files, symbols, imports, calls, mentions); re-run to sync
--recurse-submodules also walks each initialised submodule
--prs links merged pull requests via gh (skipped when gh is unavailable)
--no-structure skips the working-tree pass (no hashes, symbols, imports or calls)
--no-docs skips Markdown bodies, headings and mentions
--ensure-gitignore adds the database directory to the repo's .gitignore
with no --exclude the defaults apply: target/ node_modules/ dist/ .git/ *.lock *.min.js
Graph a git repository: Author, Commit, File, Symbol nodes plus CO_CHANGED, KNOWS, IMPORTS, CALLS and MENTIONS rules. Re-run to sync. See docs/site/ingest-git.md
schema
mushroomdb schema indexes <db-dir>
mushroomdb schema constraints <db-dir>
mushroomdb schema apply <db-dir> <schema.json>
mushroomdb schema apply <db-dir> --memory-defaults
applies the built-in memory schema to an existing store;
full-text on a populated store builds the index at each open until the next snapshot carries it
mushroomdb schema apply <db-dir> --memory-identity
adds the identity preset: sixteen SAME_AS rules over each entity's aliases;
says what it will backfill, then backfills
Idempotently apply a schema file (rules, views, fulltext indexes), the built-in memory schema, or the identity preset; prints a diff
schema indexes and schema constraints print what SHOW INDEXES and SHOW CONSTRAINTS list, as a table with one row per index (name | type | label | property | state) or unique constraint (name | type | label | property) and the header alone when there are none. They open the store read-only: they write nothing and run while mushroomdb serve holds the store. Create and drop with the Cypher statements (mushroomdb query) or the HTTP routes.
build-index
mushroomdb build-index <db-dir> [--rule <name>]
drives a rule's vector index to completion a slice at a time, for an
operator who wants the build finished before traffic arrives; a rule
created over a large corpus derives no edges until its index is whole
Drive a rule’s vector index to completion a slice at a time, for an operator who wants the build finished before traffic arrives: a rule created over a large corpus derives no edges until its index is whole. After a restart, the first write or this command is what registers an unfinished build
snapshot
mushroomdb snapshot <db-dir> [--keep-wal|--truncate] [--retention N]
folds the WAL into snapshot.bin and archives it as wal.<N>.archive,
so node_history, edge_history, was_linked and asof keep reaching it;
--truncate discards it instead, --keep-wal leaves wal.bin whole
Write snapshot.bin and archive the WAL as wal.<N>.archive, so history reads still reach it. --truncate discards it; --keep-wal leaves wal.bin whole
keys
mushroomdb keys add <db-dir> <name> --tier admin|write|read [--role <name>]
issues an access key: prints a new random token once and stores only its
blake3 hash in <db-dir>/keys.json (created private, mode 0600); --tier read
needs --role, and reads that role's view without ever writing
mushroomdb keys hash
reads a token (at least 32 bytes) from stdin and prints the hash keys.json holds
keys add works on every platform (the token comes from the operating system’s random source). It writes a 32-byte random token to standard output, as 64 hex characters, and a note to standard error. The token is not stored and cannot be shown again; only its hash goes in keys.json. It refuses a repeated name and leaves the file as it was. The mode and owner check on keys.json applies on Unix only; Windows has none. See Access keys and the write tier for what each tier may do and how a running server reloads the file.
verify
mushroomdb verify <db-dir> validate CRC32 integrity of every snapshot section
Audit snapshot integrity: CRC32 every section plus an rkyv structural pass over the mmap’d ones, exit 2 on any mismatch
migrate
mushroomdb migrate <db-dir>
Migrate an older store format in place
backup
mushroomdb backup <db-dir> <dest> process-local consistent copy of the database to <dest>
WARNING: unsafe against a concurrently running serve process;
use POST /backup on the HTTP server for live-serve backups
Copy store files to <dest> and CRC-verify the copy. WARNING: unsafe against a running serve; use POST /backup for live-served stores
restore
mushroomdb restore --from s3://bucket/prefix [--at <commit | timestamp>] [--into <dir>]
restores a continuous backup (MUSHROOMDB_BACKUP_S3_URL) into <dir>, default ./restored,
which must be new or empty; every object is checked against its manifest first
--at N restores the store as it was right after commit N (as asof --commit counts);
--at 2026-10-01T12:00:00Z the last commit at or before that instant, from the
backup's commit times; an instant past the newest recorded time is refused
when later commits have none
the restored store starts a new backup lineage: back it up to a new prefix
r2:// and minio:// need AWS_ENDPOINT_URL; credentials come from the AWS_* variables
Restore a continuous S3 backup, the newest restore point or a point in time, into a new or empty directory. Every object is verified before anything is written there, and the restored store starts a new backup lineage. See Restoring from the backup
export
mushroomdb export <db-dir> <dest> --format jsonl|csv|cypher|parquet|graphml [--single-file] export all data
--single-file (jsonl only) writes one graph.jsonl of typed node, edge and rule lines
csv writes nodes.csv and relationships.csv (plus rules.jsonl when the store has rules);
cypher writes graph.cypher, one statement per line; both load back with `mushroomdb import` / `mushroomdb query`
graphml writes one file: <dest>/graph.graphml if <dest> is an
existing directory, otherwise <dest> is the file path itself
(nodes + edges only; rules have no GraphML analogue)
Export nodes, edges, and rules. JSONL is byte-identical across runs; Parquet is not across library versions. GraphML exports nodes and edges only, as a single .graphml file, for import into generic graph viewers and analysis tools. --format jsonl --single-file writes one graph.jsonl of typed node, edge and rule lines. JSONL, CSV and Cypher stream, so memory does not grow with the properties of the store. CSV (nodes.csv, relationships.csv) and JSONL load back with import and give the same store, rules included; Cypher (graph.cypher, one MERGE per line) is read by this engine’s own query, and says in its output what it could not write, such as a NaN or infinite float, or a property whose name or map key holds a line break (one line cannot carry it; the JSONL export does). The formats are described in Durability
import
mushroomdb import [--nodes <file>] [--relationships <file>] [--db <dir>] [--delimiter <c>]
[--nodes-jsonl <file|->] [--edges-jsonl <file|->] [--rules-jsonl <file|->] [--jsonl <file|->]
[--array-delimiter <c>] [--ignore-errors] [--batch-size N]
bulk-load CSV or JSONL files into <dir> (default ./mushroomdb-data), then write one snapshot
the JSONL files are the ones `export --format jsonl` writes; --jsonl reads the one file
`export --format jsonl --single-file` writes (typed node, edge and rule lines, nodes before the edges that use them);
`-` reads one of them from standard input
nodes need an :ID and a :LABEL column, relationships :START_ID, :END_ID and :TYPE;
other columns are properties, typed by a suffix: age:int weight:float active:boolean tags:string[]
one label per node: Person;Employee is refused; relationship properties are not supported
rules the store already has fire per batch; import first, then declare rules, to backfill once
an error stops the import at its file and line, batches already committed stay; --ignore-errors skips bad rows
Bulk-load CSV or JSONL files. --jsonl reads the single file export --format jsonl --single-file writes (an edge must come after its nodes, or it is an error at its line). --nodes-jsonl, --edges-jsonl and --rules-jsonl read the files export --format jsonl writes (and --rules-jsonl the one the CSV export writes), from a path or - for standard input, line by line in the same batches; a node line is {"key": …, "label": …, <properties>}, its key is not also stored as a property, derived edges are left to their rules, and the rules are created last so each backfills once. A CSV key column named :KEY is a key that is not also stored as the property id; date, localdatetime, datetime, duration and binary column types and json carry the newer types and nested values (a store that stores one of the newer types moves to the V11 format, which 0.9.x does not open). A CSV node row needs :ID (the key) and at most one :LABEL (an empty cell is a node with no label, as export writes one); a relationship row needs :START_ID, :END_ID and :TYPE, and both ids must be nodes in the nodes file or the store. Every other column is a property; a suffix types it (age:int, weight:float, active:boolean, tags:string[]), and a column without one, or with a suffix the importer does not know (which it warns about), is a string. An empty cell is an absent property. Each batch is one atomic WAL frame, so an import that is killed leaves every batch that committed and none of the one in flight; one snapshot is written last. Rules are never declared by the import: rules the store already has fire per batch like any write, so for the fastest load import into a store with no rules and declare them afterwards, which backfills once. Malformed quoting is found before anything is written and is fatal even with --ignore-errors, because the row boundaries cannot be trusted
Hook bodies
install wires these two into the assistant; they are not meant to be typed.
recall
mushroomdb recall <db-dir>|--auto hook body: reads a prompt payload on stdin, prints related graph facts
Hook body for the /mushroom skill’s UserPromptSubmit recall hook: reads a prompt payload on stdin and prints a recall digest for it (a question in ordinary words is enough) and nothing when the store has nothing to say. Wired automatically by install
brief
mushroomdb brief <db-dir>|--auto hook body: the store's schema in one block — labels,
edge types, history depth, roles and one worked call per
question kind; byte-stable, so a session host caches it once
The store’s schema in one block (labels, edge types, how deep its history runs, who may read it, and one worked call per question kind), capped at 4,000 bytes and byte-stable between runs. Hook body for SessionStart
Version and help
--version
mushroomdb --version
Print the CLI’s version and exit
--help
mushroomdb --help
Print the usage this page is generated from, and exit.
Defaults and resolution
The notes --help prints under its usage:
Default serve address is 127.0.0.1:8080. Non-loopback --addr requires --token, MUSHROOMDB_TOKEN, or an `admin` key in `<db-dir>/keys.json` (read and write keys alone do not count).
install defaults: --platform auto-detect; scope auto (project inside a git checkout, else user);
the MCP entry runs `npx -y mushroomdb@<version>` unless a `mushroomdb` on PATH is this binary, or
--command names one (a relative --command or --db is anchored to the current directory).
--no-prewarm means no network and no resolution: neither the one-off package fetch nor locating the
package's binary, so every hook keeps the slower `npx` form.
install and uninstall take out the code-graph hooks and git hook blocks a 0.6 install wrote.
uninstall resolves the same scope and falls back to the other one when the inferred scope has no
manifest; undoing a Codex install needs --platform codex.
A project install inside a git checkout writes --auto rather than a store path, so each `git
worktree` gets its own store; outside a checkout, and with --db, the store is pinned to an absolute
path instead.
--auto resolves the database as $CLAUDE_PROJECT_DIR/mushroom-memory, else mushroom-memory at the
root of the working tree the current directory is in, else ~/.mushroomdb/memory.
Running several at once
Every CLI write command, the hooks, and a running mushroomdb serve coordinate
through one advisory LOCK file in the store directory, so they are safe to run against the same
store at the same time. A writer that cannot get the lock within two seconds exits 3 with
another mushroomdb process is writing; retry, having written nothing. Readers never take the
lock and never wait; recall opens read-only (read_only: true) so an unattended hook can never
delay a writer or fail because one is running. What the lock does not give you: cross-process
transactions, and subscription events for a peer’s writes: a commit absorbed by refresh() is
visible on the next read but notifies nobody. Full model:
docs/site/concurrency.md.
The HTTP endpoints serve answers are in the HTTP API.