0gm-memory
OfficialClick on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@0gm-memory why did we move the dev server to port 47831 instead of 8080?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
0gm-memory
Long-term memory for coding agents. Your agent's past sessions are saved to 0GM-2.0's in-model memory (0GM-CMSA), and when it needs history it gets the exact past messages back, quoted word for word with their dates.
Claude Code · Codex · OpenCode · Hermes Agent · Cursor · Cline · any MCP client
Agents forget. Every new session starts blank, so decisions, reverted attempts and their reasons get lost.
This remembers for them. Finished sessions are saved automatically, secrets stripped on your machine first, into a wallet that holds up to 120M tokens of memory.
It returns evidence, not a summary.
ask_memoryhands back dated, verbatim quotes, so the agent reasons over what was actually said.
Quick start · Install per agent · How it works · Results · Privacy · FAQ
In 15 seconds
sequenceDiagram
autonumber
participant A as Coding agent
participant P as 0gm-memory (your machine)
participant W as 0GM-CMSA memory
A->>P: session ends (hook or plugin)
P->>P: redact secrets, buffer locally
P->>W: save once the buffer passes about 70K tokens
Note over A,W: days later, in a fresh session
A->>P: ask_memory("why is the dev server on 47831?")
P->>W: find the relevant past messages
W-->>P: verbatim quotes with session dates
P->>P: check each date against a local index
P-->>A: [2026-11-24] User: "the Zebra scanner bridge hard-codes 8080 ..."The same question in a fresh session, in the invented warehouse project (pallet-ledger) used for the real-session
tests:
You: Why is the dev server on port 47831 and not 8080?
Agent: PORT defaults to 47831 in config.py, but nothing in the code says why. It may have been chosen to
avoid a conflict. Shall I change it back to 8080?
You: Why is the dev server on port 47831 and not 8080?
Agent (calls ask_memory):
[2026-11-24] User: "Move the dev server off port 8080. Reason: the Zebra scanner bridge on the dock PCs hard-codes 8080, so 'pallet-ledger serve' collides with it on every dock PC. We decided on port 47831."
It moved because the scanner bridge on the dock PCs owns 8080; changing it back would break every dock PC.
The quote is verbatim from a real Claude Code session on 24 Nov 2026; the answers are shortened.
Related MCP server: agent-recall
What each agent gets
Agent | Ask ( | Auto-save | How sessions are saved | Tested in a real session |
Claude Code | yes | yes |
| yes, 24 Nov 2026 |
Codex CLI | yes | yes, once its hooks are trusted |
| yes, 24 Nov 2026 |
OpenCode | yes | yes | plugin on the session idle hook; | yes, 24 Nov 2026 |
Hermes Agent | yes ( | yes | memory provider, after every turn | yes, 24 Nov 2026 |
Cursor | yes | no, ask only | its chat history is not in a format this package reads | no (manifests checked only) |
Cline | yes | no, ask only | none | no |
Other MCP clients | yes | no, ask only |
| no |
Sessions saved from one agent can be asked about from any other agent on the same key.
Quick start
You need uv (or pipx) and an API key from pc.0g.ai for a wallet that will hold only this project's memory. uv fetches Python 3.10 or later if needed.
uv tool install 0gm-memory # or: pipx install 0gm-memory
export ZGM_MEMORY_KEY=<key from pc.0g.ai>
0gm-memory status # free, no network: shows the wallet and an empty bufferOr run it without installing: uvx 0gm-memory status.
Connect your agent. For Claude Code:
claude mcp add 0gm-memory -e ZGM_MEMORY_KEY="$ZGM_MEMORY_KEY" -- 0gm-memory serveand merge integrations/claude-code/hooks/hooks.json into
.claude/settings.json so sessions are saved. Already have history? 0gm-memory save --claude (or --codex,
--opencode) saves this folder's past sessions. Then ask your agent about something you decided earlier.
Install per agent
Each block assumes the command is installed as in the quick start. To run it without installing, use
uvx 0gm-memory in place of 0gm-memory (the save hooks are faster with the installed command).
claude mcp add 0gm-memory -e ZGM_MEMORY_KEY="$ZGM_MEMORY_KEY" -- 0gm-memory serveMerge hooks/hooks.json into .claude/settings.json. To keep the key
per project, put { "env": { "ZGM_MEMORY_KEY": "<key>" } } in .claude/settings.local.json (not committed).
Or install the plugin, which sets up both in one go: /plugin marketplace add 0gfoundation/0gm-memory, then
/plugin install 0gm-memory@0gm-memory. Details, timeouts and safety nets:
integrations/claude-code.
codex mcp add 0gm-memory --env ZGM_MEMORY_KEY="$ZGM_MEMORY_KEY" -- 0gm-memory serveMerge hooks.json into ~/.codex/hooks.json and trust the hooks: Codex skips
untrusted hooks silently, and codex exec never asks. How to trust them, and the env_vars list for
config.toml: integrations/codex.
In the project's opencode.json:
{ "mcp": { "servers": { "0gm-memory": { "type": "local", "command": ["0gm-memory", "serve"],
"environment": { "ZGM_MEMORY_KEY": "{env:ZGM_MEMORY_KEY}" }, "timeout": { "execution": 300000 } } } } }Copy plugins/0gm-memory.js to .opencode/plugins/ to save
sessions, and run 0gm-memory save --opencode once for past ones. Details:
integrations/opencode.
hermes plugins install 0gfoundation/0gm-memory/integrations/hermes
hermes memory setup # choose 0gm-memory, paste the keyThe provider imports the 0gm-memory package, which Hermes installs from PyPI as a declared dependency. See integrations/hermes.
In .cursor/mcp.json:
{ "mcpServers": { "0gm-memory": { "command": "0gm-memory", "args": ["serve"],
"env": { "ZGM_MEMORY_KEY": "${env:ZGM_MEMORY_KEY}" } } } }Or use the one-click Add to Cursor link and the Cursor plugin. Details: integrations/cursor.
In cline_mcp_settings.json (or ask Cline to install this repository; it follows llms-install.md):
{ "mcpServers": { "0gm-memory": { "command": "0gm-memory", "args": ["serve"],
"env": { "ZGM_MEMORY_KEY": "<key>" }, "timeout": 300 } } }{ "mcpServers": { "0gm-memory": { "command": "0gm-memory", "args": ["serve"],
"env": { "ZGM_MEMORY_KEY": "<key>" } } } }"command": "uvx", "args": ["0gm-memory", "serve"] needs no install step. Docker:
integrations/docker.
How it works
flowchart LR
A[Session ends<br/>or compacts] -->|hook or plugin| B[Read transcript]
B --> C[Drop memory lookups,<br/>redact secrets]
C --> D[(Local buffer)]
D -->|over ~70K tokens| E[One multi-turn call<br/>to the 0G router]
E --> F[(0GM-CMSA memory)]
G[ask_memory] --> H[0GM-2.0<br/>quotes past messages]
F -.-> H
H --> I[Dates checked<br/>against local index]
I --> J[Dated verbatim quotes,<br/>plus buffer matches]0GM-2.0 writes memory when its server compacts a conversation, which it does by itself once a plain multi-turn call
passes 65,536 tokens. So the package buffers sessions locally and sends them as one call at about 70K estimated tokens, and
the server archives them into the wallet. Each message carries its session date, and every quote that comes back is
checked against a local index of what was saved, so a wrong date is corrected and marked. Until a session is saved,
ask_memory also searches the local buffer and lists those matches separately. Calls to the memory tools, and answers
that only restate memory, are never saved back, so old answers do not echo into new ones.
Tools and commands
MCP tool | What it does | Cost and time |
| Returns verbatim quotes of the relevant past messages with their session dates, or | A few cents a call (about $0.07 measured on 0GM-2.0). Seconds on a small wallet, up to about 100 s on one of millions of tokens |
| Redacts and buffers a transcript; saves to the wallet once the buffer is big enough. Re-saving adds only new messages | Free while buffering; see Cost |
| What is buffered and saved, memories used of 64, last save, spend | Free, no network |
Command | What it does |
| Run the MCP server on stdio |
| The same as |
| Save transcripts (Claude Code, Codex, an OpenCode export, or JSONL of role and content) |
| Save this folder's past sessions from that agent. |
| Buffer, saves, spend and the hook log path. No network |
| For agent hooks: reads the hook JSON and saves in the background |
| Delete this machine's buffer and logs, or every memory in the wallet (asks for the wallet id) |
Exit codes: 0 ok, 1 bad input, 2 configuration (for example no key), 3 the router call failed (save keeps the buffer
and sends it again next time). With no network a call fails at once; rate limits and server errors are retried with
backoff.
Recommended project rule
Agents call ask_memory when you mention past work, but not by themselves before a routine change such as "move the
port back to 8080". To make them check first, add this line to the project's CLAUDE.md or AGENTS.md:
Before changing configuration, dependencies or an earlier decision, call ask_memory to check for a past decision; if it conflicts, stop and ask the user before changing it.Configuration
Variable | Default | What it does |
| API key for this project's wallet | |
| macOS: name of a keychain item holding the key | |
| Used if nothing above is set | |
|
| |
| platform data folder | Local state: |
|
| Estimated tokens per save. Larger saves mean fewer, bigger saves |
|
| Seconds per call |
|
| Retries on 429 and 5xx, with backoff |
|
| How much of each tool result is kept |
|
| |
|
| OpenCode's database, read by |
|
| OpenCode command, used only if its database cannot be read |
|
| Router |
|
| Model id; the default is one constant ( |
The key is read in this order: ZGM_MEMORY_KEY, ZGM_MEMORY_KEY_SERVICE, a key entered in plugin settings,
ZG_API_KEY. It is only sent in the Authorization header and never logged; local state is filed under a one-way hash
of it.
Upgrading from 0gm-msa-memory. The package was renamed. The old names keep working for now:
Every
ZGM_MEMORY_*variable falls back to its old nameMSA_MEMORY_*(andZGM_MEMORY_KEY_SERVICEtoMSA_KEY_SERVICE); when both are set, the new name wins.On first run, local state in the old
0gm-msa-memorydata folder is copied to the new0gm-memoryfolder. The old folder is left untouched; delete it once you are happy.A
.msamemoryignorefile is still read;.0gmmemoryignorewins when both are present.0gm-msa-memorystill runs as a deprecated alias of the0gm-memorycommand.
Results
Measured on test wallets. Small samples and single runs, so read them as indications, not rankings. Methods and raw
results: FINDINGS and
eval/beam/ in the demos repository.
BEAM at 10M tokens (Mem0's long-conversation benchmark): 40 questions, one run, questions answered correctly.
xychart-beta
title "BEAM-10M: correct answers out of 40 (one run)"
x-axis ["0GM-2.0 (preview)", "This plug-in", "GPT-5.1 + RAG", "Mem0 + GPT-5", "Perfect context"]
y-axis "Correct (of 40)" 0 --> 40
bar [22, 22, 21, 19, 34]Setup | Correct of 40 |
0GM-2.0 (preview), a plain question to the wallet | 22 |
This plug-in (quoting lookup, v2) | 22 |
GPT-5.1 with embedding retrieval (RAG) | 21 |
Mem0 with GPT-5 | 19 |
Ceiling: the right evidence placed in the prompt | 34 |
The first four are within noise of each other on 40 questions, and the gap to the ceiling shows that finding the evidence is still the hard part. What this package offers is not a higher score but nothing to host, and answers that come back as dated quotes.
Real agent sessions (24 Nov 2026, invented project, test wallet):
Check | Result |
Fresh Claude Code session, memory tools only, three questions about past decisions | 3 of 3 answered with verbatim, correctly dated quotes (34 s and $0.022 for the lookup) |
Fresh Codex, OpenCode and Hermes sessions | Each recalled decisions from earlier sessions, from the wallet, with dates |
Synthetic history spanning 17 Sep to 24 Nov | Quotes carried the right session dates |
Fake keys, passwords and | 0 found on disk or in any request |
Time | A lookup took 6 to 45 s on a small wallet; a save took 18 to 31 s |
Privacy and data
What is sent, after redaction: user and assistant message text, tool calls (cut to 400 characters), tool results (cut to 1,500) and your
ask_memoryquestions. They go to 0G's router (router-api.0g.ai) and are stored in your wallet. Nothing is sent while sessions are only buffered.What is never sent: thinking blocks, subagent side chains, system reminders, calls to the memory tools, and the output of tool calls that touched
.env, key or credential files.Redaction runs on your machine before anything is buffered, and again on the exact request body: API keys and tokens in known formats, private keys, secret-looking assignments, passwords said in a sentence and random-looking strings. It is a strong filter, not a guarantee; see SECURITY.md.
Opt out, or add rules, per project with a
.0gmmemoryignorefile in the project or any parent folder:* # save nothing from this project Acme Corp # or: redact this string everywhere re:CUST-\d{6} # and this pattern path:legal/** # and drop tool output for these files
Retention and how to wipe everything: PRIVACY.md.
Cost
Measured on 4 Dec 2026 with 0GM-2.0: a save (about 70K tokens of sessions) cost $0.28, and a question $0.07.
A typical week | Saves | Questions | About |
Busy: 1M tokens of sessions | 14 | 30 | $6 |
Light: 300K tokens of sessions | 4 | 10 | $2 |
0GM-2.0 pricing on 0G Private Computer: memory writes are $3.00 per million newly written tokens, including the first
30 days of storage; stored memory renews at $3.00 per million tokens per 30 days, and using it resets the 30 days.
Unused memory expires after 30 days. Check pc.0g.ai for current prices. memory_status shows what has
been spent from its state folder (Hermes keeps its own folder, so it reports its own share).
Limits
A save needs about 70K tokens. The most recent sessions wait in the local buffer until there is enough;
ask_memorystill finds them there.Up to 120M tokens of memory per wallet. If a save is ever refused with
429 "Automatic session quota reached", raiseZGM_MEMORY_FLUSH_TOKENSso each save carries more, and open an issue.Memories expire after 30 days without use, under 0GM-2.0's memory pricing. See PRIVACY.md.
Slow on big wallets. Seconds on a small wallet; 55 to 101 s per lookup on wallets of 1M to 12M tokens.
Recall is not complete. Ask one specific question per call: a lookup that bundled five questions missed a fact that a specific question then found.
No per-fact delete. You can wipe a whole wallet, not one session.
One wallet per project. Everything in a wallet can turn up in any answer (see the FAQ).
Backfills cost per save.
save --claudeon a long history saves once per ~70K tokens.
FAQ
What is a wallet? The account that holds the memory. You create it with an API key from pc.0g.ai and pay for use with credit on that key; nothing else is needed.
Why one wallet per project? With two long conversations in one wallet, 7 of 20 answers about the first brought in material from the second; loaded one per wallet, the same 40 questions scored 0.664 against 0.593. The package keeps a separate buffer per key, but only separate wallets keep memories apart.
Is this RAG? No index is built: the model reads its own memory. On the benchmark above it scored about the same as embedding retrieval. The trade is different: nothing to host, and evidence comes back as dated quotes.
What happens if a save fails? Nothing is lost: the buffer is kept and sent again with the next save. save exits
with 3, and memory_status counts the failure.
Can I delete memories? 0gm-memory forget --wallet deletes every memory in the wallet (it asks you to confirm
with the wallet id). forget --local deletes this machine's buffer and logs.
Does it work offline? Buffering does; saving and asking need the router.
Will it slow my agent down? The save hooks return in about 0.1 s and do the work in the background. A lookup takes seconds, and runs only when the agent asks.
Contributing
From source:
git clone https://github.com/0gfoundation/0gm-memory && cd 0gm-memory
uv run --extra dev pytest # unit tests, no network
uv run --extra dev ruff check .
ZGM_MEMORY_KEY=... uv run python scripts/live_e2e.py all --out e2e-results # live, costs under $0.50Issues and pull requests are welcome; see CONTRIBUTING.md and the Code of Conduct. Security reports: SECURITY.md.
Licence
Available Tools
3 toolsask_memoryAsk project memoryARead-only
Search this project's long-term memory (0GM-CMSA memory holding past agent sessions). Returns VERBATIM quotes of the relevant past messages, each with its session date, or NO RELEVANT MESSAGES. It does not answer: reason over the quotes yourself. Slow (seconds on a small wallet, up to about 100 s on a large one) and costs about $0.003 to $0.03 per call, so ask one specific, self-contained question rather than many small ones. Recent sessions may still be buffered locally; matches from the buffer are listed separately.
Inputs: query (required).
memory_statusMemory statusARead-only
What is buffered locally, what has been saved to wallet memory, the quota used and the last save. Free: no network call.
Inputs: no named parameters.
save_sessionSave a session transcriptAIdempotent
Add a session transcript (Claude Code or Codex JSONL, or JSONL of {role, content, timestamp}) to this project's memory buffer. Secrets are redacted first. The buffer is written to wallet memory once it passes about 70K tokens; the reply says what was buffered and what was saved. Safe to call twice on one file: only new records are added.
Inputs: transcript_path (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools map cleanly onto read (ask_memory), write (save_session), and inspect (memory_status) operations with no functional overlap. The descriptions explicitly differentiate them, including noting that ask_memory does not reason and that memory_status is free and local.
ask_memory and save_session follow a consistent verb_noun pattern, but memory_status breaks it with a noun_noun form. It is still readable and clearly part of the same family, so only a minor deviation.
Three tools is on the lean side but covers the core memory lifecycle (search, ingest, status) without redundancy. Each tool earns its place; nothing feels like filler.
Search, save, and status cover the main loop, but there is no way to delete or forget memories, list saved sessions/entries, or force a flush of the buffer to wallet memory. These are notable gaps that could cause dead ends for agents managing memory hygiene.
Maintenance
Related MCP Connectors
Long-term MCP memory for coding agents: store, search and recall memos across sessions.
Memory for coding agents: the decisions, the dead ends, and where the last session stopped.
Long-term memory for AI coding agents: durable project facts, recalled by every MCP client.
Your coding agents' past sessions as memory: search them, open the turn, see where agents failed.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables infinite searchable memory for coding agents across sessions, allowing them to recall past decisions and context.47 npm16MIT
- AlicenseNot gradedqualityBmaintenanceEnables persistent memory for AI coding agents, allowing them to remember people, decisions, and context across sessions through a knowledge graph and automated briefings.77 PyPI15MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI agents with persistent memory across sessions, enabling recall of decisions, clients, and deadlines with verifiable citations.MIT
- AlicenseBqualityDmaintenanceEnables programming agents to capture errors and conversation signals, reflect on root causes, consolidate reusable skills, and retrieve relevant context for future tasks, providing a self-learning memory loop.15MIT