The SurrealDB Agent Memory CLI is the memory component of the surreal command-line tool, run as surreal memory. It covers remember, recall, chat, documents and the other operations of the REST API.
Until version 0.3.0 the CLI was a separate program called agent-memory, and before that spectron. The commands and connection flags are the same under surreal memory. The old SPECTRON_* environment variables still work, with a warning that names each replacement, and the first run copies a saved login from ~/.config/spectron and ~/.spectron.
Installing the CLI
Install the surreal launcher with the Agent Memory component:
curl -sSf https://install.surrealdb.com | sh -s -- --with memoryWith surreal already installed, add the component on its own:
surreal install memoryThe launcher installs, upgrades and pins every component, so the CLI has no upgrade command of its own:
surreal upgrade memoryManaging components covers versions and pinning. surreal memory --version prints the installed version.
Connection flags (client)
Most surreal memory subcommands accept:
| Flag | Environment variable | Description |
|---|---|---|
--url / -u | SURREAL_MEMORY_URL | Context host base URL (for example https://<your-context-host>), shown in the SurrealDB Studio API keys view |
--api-key / -a | SURREAL_MEMORY_API_KEY | Context API key |
--context-id / -c | SURREAL_MEMORY_CONTEXT_ID | Context id in /api/v1/{context_id}/... |
A flag takes precedence over its environment variable, and the environment variable over a saved login.
surreal memory login --url https://<your-context-host> \
--api-key "$SURREAL_MEMORY_API_KEY" \
--context-id devlogin saves these values for later commands.
Local config and secrets
surreal memory login and surreal memory config set save to ~/.surrealdb/memory/config.toml with owner-only permissions (0600 on Unix). The folder follows SURREAL_CLI_HOME when the launcher uses another home, and SURREAL_MEMORY_CONFIG_DIR names another folder. config set prints the key name, never the value. To display a stored secret:
surreal memory config get api_key --revealWithout --reveal, api_key is shown as <hidden>.
Output and exit codes
The CLI uses the same output flags as the other surreal components. --json, --plain, --yes and --no-input can also be set with SURREAL_MEMORY_JSON, SURREAL_MEMORY_PLAIN, SURREAL_MEMORY_YES and SURREAL_MEMORY_NO_INPUT.
| Flag | Effect |
|---|---|
--json / -j | Prints the server's whole response as one JSON document. A failed command prints nothing on stdout and a JSON error on stderr. |
--plain | Disables tables, spinners and relative times. |
--color | auto, always or never. |
--quiet / -q | Hides progress and confirmation lines. |
--yes / -y | Accepts every confirmation. |
--no-input | Never reads from the terminal: repl, tui and interactive chat exit with code 2 instead. |
Results go to stdout and progress and confirmation messages to stderr, so surreal memory mcp > mcp.json writes a valid file. A failed request sets the exit code from its HTTP status:
| Status | Exit code |
|---|---|
| Usage error | 2 |
| 401 | 3 |
| 403 | 4 |
| 404 | 5 |
| 409 or 412 | 6 |
| 400, 413 or 422 | 7 |
| 429 | 8 |
| 5xx, or the server cannot be reached | 9 |
Commands
Unified verbs
| Command | REST equivalent |
|---|---|
surreal memory remember "…" | POST /api/v1/{ctx}/facts |
surreal memory recall "…" | POST /api/v1/{ctx}/query |
surreal memory context "…" | POST /api/v1/{ctx}/context |
surreal memory chat [message] | POST /api/v1/{ctx}/chat |
surreal memory reflect "…" | POST /api/v1/{ctx}/reflect |
surreal memory forget "…" | POST /api/v1/{ctx}/forget |
forget supports --dry-run to preview matches without expiring records.
remember flags: --infer full|triples|preview|none, --from-file, --transcript, --scope org/acme/user/alice, --extract whole_conversation|per_message (batch).
recall flags: --limit, --mode hybrid|vector|bm25|graph, --include facts,passages. Pass lens on the REST /query body - the CLI does not expose --scope on recall today.
Unsupported CLI flags (rejected with a clear error): remember --confidence, --trust, --location; recall --min-trust; surreal memory lifecycle expire --older-than (expiry thresholds are configured per Context, not per CLI invocation). Use the REST API where those controls exist.
Documents
surreal memory documents upload ./manual.pdf --scope org/acme/team/eng --label team=eng
surreal memory ingest ./folder --scope org/acme/team/eng --label team=eng
surreal memory documents list
surreal memory recall "return policy" --include passages--scope on upload narrows tagging to a path within the caller's memory:write region (same semantics as remember --scope). --label may be repeated for key=value tags stamped on the document and chunks. Omit --scope to use the full write region.
Sessions, entities, traces
surreal memory sessions list
surreal memory entities show Person/alice
surreal memory traces show <trace_id>MCP server
The MCP server is served at /mcp on the same host as the REST API - no CLI step is needed to run it. surreal memory mcp prints ready-to-paste config snippets for Claude Desktop, Cursor and Claude Code, using the URL, key and Context id from your connection settings. Point your client at that endpoint, or run install-mcp. See the MCP server install guide.
Terminal workbench
| Command | Description |
|---|---|
surreal memory tui | Four-pane workbench: input, entity tree, trace timeline, inspector (Tab cycles panes). --session <id> pins a session; --replay <path> plays a recorded jsonl without HTTP. |
surreal memory repl | Interactive REPL: bare lines and /remember write facts (infer: full); /recall, /chat, /inspect, /scope, /as-of, /upload, /forget, /record; tab completion from prior responses. Colour is on when stdout is a terminal; pass --ascii for plain output (same flag as surreal memory tui). |
Scope in the REPL and TUI uses slash paths (org/acme/user/alice), matching the wire ScopeSet.
REPL triple syntax
Interactive mode supports structured triple writes:
/fact entity=Person/Alice attr=role val=CTOUses the same triple syntax as surreal memory remember --triple (infer=triples).
Run surreal memory --help for the full command tree.