MemorySync
Command line

CLI

Add, search and manage memory from your terminal, with a JSON mode built for AI agents and exit codes a script can branch on.

Install

BASH
npm install -g memorysync-cli

Or run it without installing, which is the easier path inside a container or a one-off script:

BASH
npx memorysync-cli help

Needs Node 18 or newer. The package has no dependencies, so there is no transitive tree to audit and nothing is compiled at install time.

Authenticate

init asks for a key, verifies it against the API before saving anything, and records a default user and project.

BASH
memorysync init

For CI or any non-interactive shell, pass the values instead. Without a terminal there is no prompt, and the command fails with the flag to add rather than hanging on stdin.

BASH
memorysync init --api-key ms_live_xxx --user alice --force

Or skip stored credentials entirely and set MEMORYSYNC_API_KEY, which takes precedence over anything on disk.

Quick start

BASH
# Store a fact
memorysync add "I prefer TypeScript over JavaScript" --user alice
# Search it back
memorysync search "language preference" --user alice
# Recent memories, as a table
memorysync list --user alice -o table
# Pipe something in
echo "Ships on Fridays" | memorysync add --user alice

Commands

Every command accepts every output format, and memorysync help <command> prints its flags and examples.

Every CLI command
CommandWhat it doesUses quota
initStore a credential, pick a default user and project.
addStore a fact. Reads stdin, so it composes with pipes.add
searchNatural-language search.retrieval
listRecent memories for a user.retrieval
getOne memory, including ingestion state.
deleteDelete memories. Previews unless you pass --yes.
importBulk load JSON or JSONL, validated before anything is sent.add
exportWrite memories out as json, jsonl or csv.retrieval
quotaPlan usage and when the cycle resets.
statusCredential, API reachability and active scope.
doctorDiagnose setup problems and say what to fix.
whoamiThe identity and scope in use.
projectList projects, or set the default for a profile.
sourceInspect and control connected knowledge sources.
eventTrack asynchronous ingestion, including a blocking wait.
configLocal configuration and profiles.
mcpConnect MemorySync MCP to your AI clients.
completionShell completion for bash, zsh, fish and PowerShell.
helpCommand help. With --json, the whole tree.

Use it inside an agent

Put --json (or --agent) before the command name. Every command then answers with one envelope on stdout, whether it succeeded or failed, with no colour and no spinners.

BASH
memorysync --json search "preferences" --user alice | jq '.data[].text'
JSON
{
"status": "success",
"command": "search",
"duration_ms": 134,
"scope": { "user": "alice", "profile": "default" },
"count": 2,
"data": [
{ "id": "m_60632", "text": "Prefers TypeScript", "score": 0.97 }
],
"quota": {
"metric": "retrieval_requests",
"used": 12,
"limit": 1000,
"exhausted": false
}
}

Results are always an array under data, for every command, so .data[] works everywhere. Failures use the same envelope with status: "error" and a non-zero exit, so one code path handles both outcomes.

memorysync help --json returns the entire command tree, so an agent can discover the surface for itself rather than being told about it in a prompt.

Exit codes

Distinct per cause, so a script can branch without parsing stderr.

Exit codes
CodeMeaningRetry?
0Success.
1Unclassified failure.Maybe
2Usage: unknown command, bad flag, missing argument.No
3Authentication: missing, wrong, expired or revoked key.No
4Plan limit reached. Nothing was stored or returned.Not until reset
5Network: unreachable, or timed out.Yes
6Not found.No
130Interrupted.
BASH
memorysync add "$FACT" --user "$USER_ID"
case $? in
0) echo "stored" ;;
3) echo "credential problem"; exit 1 ;;
4) echo "out of quota - nothing was stored"; exit 1 ;;
5) echo "network problem, retrying"; sleep 5 ;;
esac

Output formats

Set with -o. Every command accepts all five, so a script never has to remember which command refuses which format.

text
Human-readable, with colour when the terminal supports it. The default.
table
Aligned columns, with long values truncated to keep rows on one line.
json
The raw structured result, for piping to jq.
yaml
The same data, easier to read at a glance for nested objects.
quiet
Nothing on stdout. Use the exit code.

Profiles

For more than one environment or account, without juggling exported variables in separate shells.

BASH
memorysync init --profile staging --api-key ms_live_xxx --user alice
memorysync config profiles
memorysync config use-profile staging
memorysync --profile production status

Precedence, highest first: explicit flags, environment variables, the profile, then defaults. Environment beats the profile deliberately, so a CI image cannot be steered by a config file that happens to be baked into it.

Deleting

delete previews by default and changes nothing until you pass --yes. The preview is the server's own dry run, so what it lists is exactly what a confirmed run removes.

BASH
memorysync delete m_60632 --user alice # previews, deletes nothing
memorysync delete m_60632 --user alice --yes # performs it
memorysync delete --all --user alice # previews the whole scope

Connected sources

Inspect and drive the connectors feeding memory — GitHub, Slack, Notion, Google Drive, OneDrive, Granola, Amazon S3 and crawled sites — without opening the dashboard.

BASH
memorysync source list
memorysync source status github
memorysync source sync github
memorysync source pause slack

Connecting a new source needs a browser round trip for OAuth, so that stays in the dashboard. A CLI that half-connected a source would be worse than one that does not try.

Shell completion

BASH
# bash
memorysync completion bash > /etc/bash_completion.d/memorysync
# zsh
memorysync completion zsh > "${fpath[1]}/_memorysync"
# fish
memorysync completion fish > ~/.config/fish/completions/memorysync.fish
# PowerShell — add to your profile
memorysync completion powershell | Out-String | Invoke-Expression

Start a new shell afterwards for it to take effect.

When something is wrong

Start with doctor. It checks the credential and where it is stored, file permissions, DNS, API reachability, quota headroom, the project binding and your Node version, then prints what to fix. It exits 0 even when checks fail, because diagnosing is what it was asked to do.

BASH
memorysync doctor
Common problems
SymptomCauseFix
Exit 3, "No API key found"No credential in the environment, the keychain or the config directory.Run memorysync init, or set MEMORYSYNC_API_KEY.
Exit 2, "This command needs an end user"Memory is scoped per user and none was given.Pass --user, or set a default during init.
Exit 4, or writes that store nothingA plan limit is reached, and the API degrades silently by design.Run memorysync quota to see usage and the reset date.
add succeeds but search finds nothingEmbedding is asynchronous, so a new memory is briefly not searchable.Use add --wait, or memorysync event wait <id>.
add returns a status of skippedExtraction discarded it as filler, or merged it into a near-duplicate.Not a failure and not worth retrying. Store a concrete, durable statement.
Exit 5 on every commandThe API is unreachable: DNS, a proxy, or an egress rule.memorysync doctor separates DNS from the API call.

Environment variables

Environment variables
VariableEffect
MEMORYSYNC_API_KEYCredential. Overrides anything stored.
MEMORYSYNC_BASE_URLAPI base URL.
MEMORYSYNC_USER_IDDefault end user.
MEMORYSYNC_PROJECT_IDDefault project.
MEMORYSYNC_PROFILEProfile to use.
MEMORYSYNC_OUTPUTDefault output format.
MEMORYSYNC_TIMEOUTPer-request timeout, in milliseconds.
MEMORYSYNC_CONFIG_DIRConfig location. Defaults to ~/.memorysync.
NO_COLORDisable colour.

Where to go next

MemorySync MCP
Give an assistant the same memory through the Model Context Protocol, instead of shelling out.
SDKs
Call the API from your own code, in Python or TypeScript.
API reference
Every endpoint the CLI wraps, with request and response shapes.