RecipesImport from Mem0

Import from Mem0

The CLI has an importer for Mem0 exports: mnemo import <file> --from mem0. It sends the file to POST /import, which converts each record into a fact.

Get your memories as a JSON array

The importer expects one JSON array of records. How you export it is up to Mem0’s own tooling. From each record it reads these fields:

Mem0 fieldBecomes
memory, or textThe fact’s statement
user_id, or agent_idThe fact’s subject. Default general
metadataCopied into the fact’s metadata
idmetadata.sourceId
[
  {
    "id": "m_001",
    "memory": "Acme prefers communication in Spanish.",
    "user_id": "acme",
    "metadata": { "source": "onboarding" }
  }
]

A record with neither memory nor text is dropped and is not counted.

Run the import

export MNEMO_URL=http://localhost:3939
export MNEMO_KEY=mns_live_...
 
gzip -k mem0-export.json
npx -y @mnemo-ai/cli import mem0-export.json.gz --from mem0 --conflict-resolution skip

import takes the file as a positional argument. The server URL and the workspace come from MNEMO_URL and MNEMO_KEY: the key decides the workspace, and it needs the memory:write scope.

Gzip the file as shown, or send it as plain text: with from set, the route reads the body as one JSON array, pretty-printed or not.

Read the result

The command prints the server’s summary:

{
  "imported": { "fact": 1 },
  "skipped": 0,
  "skippedByReason": {},
  "errors": 0,
  "workspaceId": "7c1f0b52-3e0a-4a51-9d0e-2f6a8f1f4b10",
  "sourceWorkspaceId": "7c1f0b52-3e0a-4a51-9d0e-2f6a8f1f4b10",
  "totalLines": 2
}

imported.fact is the number of facts written. skippedByReason says why each skipped line was skipped, for example duplicate.

What an imported fact looks like

  • Kind other, scope global, confidence 0.33.
  • metadata.importedFrom is "mem0" and metadata.sourceId holds the Mem0 id.
  • Mem0 timestamps are not carried over.
  • Text goes through the same ingest checks as remember: a line that fails the poisoning check is skipped, and detected PII is redacted.
  • The import route stores the fact without calling the embedding provider.

Running it again

Importing the same file twice does not duplicate facts. With --conflict-resolution skip, which is the default, a record that was already imported is skipped. The other values are overwrite and newest.

What does not map

Only facts are created. Decisions, entities, relations and strategies are not derived from a Mem0 export.

The manual route

To write the memories through the normal remember path instead, loop over the records with the TypeScript client:

import { readFileSync } from "node:fs";
 
const records = JSON.parse(readFileSync("mem0-export.json", "utf8"));
 
for (const record of records) {
  await memory.remember({
    statement: record.memory,
    subject: record.user_id,
    metadata: { importedFrom: "mem0", sourceId: record.id },
  });
}

This is slower, and each write needs an embedding provider or a vector of your own.

The importer has two more formats: --from zep, which turns each message into an episode, and --from claude, which creates facts. There are no other vendors.