Skip to content

Reference

CLI

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.

Note

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.

Install the surreal launcher with the Agent Memory component:

macOS and Linux
curl -sSf https://install.surrealdb.com | sh -s -- --with memory

With surreal already installed, add the component on its own:

surreal install memory

The launcher installs, upgrades and pins every component, so the CLI has no upgrade command of its own:

surreal upgrade memory

Managing components covers versions and pinning. surreal memory --version prints the installed version.

Most surreal memory subcommands accept:

FlagEnvironment variableDescription
--url / -uSURREAL_MEMORY_URLContext host base URL (for example https://<your-context-host>), shown in the SurrealDB Studio API keys view
--api-key / -aSURREAL_MEMORY_API_KEYContext API key
--context-id / -cSURREAL_MEMORY_CONTEXT_IDContext 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 dev

login saves these values for later commands.

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 --reveal

Without --reveal, api_key is shown as <hidden>.

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.

FlagEffect
--json / -jPrints the server's whole response as one JSON document. A failed command prints nothing on stdout and a JSON error on stderr.
--plainDisables tables, spinners and relative times.
--colorauto, always or never.
--quiet / -qHides progress and confirmation lines.
--yes / -yAccepts every confirmation.
--no-inputNever 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:

StatusExit code
Usage error2
4013
4034
4045
409 or 4126
400, 413 or 4227
4298
5xx, or the server cannot be reached9
CommandREST 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.

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.

surreal memory sessions list
surreal memory entities show Person/alice
surreal memory traces show <trace_id>

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.

CommandDescription
surreal memory tuiFour-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 replInteractive 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.

Interactive mode supports structured triple writes:

/fact entity=Person/Alice attr=role val=CTO

Uses the same triple syntax as surreal memory remember --triple (infer=triples).

Run surreal memory --help for the full command tree.

Was this page helpful?