Agent Memory and Context Tools Compared: claude-mem vs ai-memory vs Context7
Coding agents start every session with a blank slate. “Memory” tools fix that in different ways: some record what past sessions did, some share one memory across agents and machines, some fetch current library docs, and some shrink what the agent reads so more fits. The five tools in our directory each solve one of those problems. Below: which one to pick, a side-by-side table that shows where your data goes, a minimal setup from each project's own docs, and the free options to set up first. Every version and fact links to an official source.
Published Last verified
Which memory tool should your agent use?
- claude-mem if you work alone in Claude Code, Codex or OpenCode and want past sessions remembered automatically.
- ai-memory if you switch between agents or machines, or want a team's agents to share one project memory, with no LLM bill.
- Context7 if your agent keeps guessing library APIs and you want current, version-specific docs on demand.
- Headroom if long logs and tool outputs fill the context window and you want them compressed, reversibly.
- MCP Memory server if you want a tiny local fact store the agent writes on purpose, with no services or model calls.
No rules file in your repo yet? Start with the free, file-based options.
Four problems that all get called memory
Most “best memory” lists rank tools that solve different problems against each other. Name the problem first:
- The agent forgets past sessions. Session memory records what happened and loads a summary next time: claude-mem, or Claude Code's built-in auto memory.
- Each agent and machine has its own memory. A shared memory server keeps one project memory for every agent and teammate: ai-memory.
- The agent guesses library APIs. That is missing knowledge, not memory: fetch current docs with Context7, or crawl them into the repo.
- The context window fills with noise. Long logs and tool outputs push out what matters: compress them with Headroom.
A fifth, simpler option sits underneath all of them: facts the agent saves on purpose, as in the MCP Memory server. And none of it replaces a short rules file you write yourself. Independent research is a useful brake: in VibeMemBench, eleven of twelve pairings of coding agents with existing memory systems did no better than running without memory. Sources: Claude Code memory docs (opens in new tab), VibeMemBench (arXiv) (opens in new tab).
Agent memory comparison table
Versions are the latest release on each package registry or repository on 17 Nov 2026. Each tool's section below links the source for every cell.
claude-mem
Session memory plugin · 15.19.0
- What it solves
- Remembers what past sessions did and decided
- How it captures
- Automatic: lifecycle hooks record tool use, and a model writes observations and summaries
- Where it lives
- Local SQLite plus a Chroma vector index in ~/.claude-mem; optional Cloud Sync to cmem.ai
- Needs a model
- Yes: the hosted observer, your Anthropic plan, or your Codex, Gemini or OpenRouter access
- Works with
- Claude Code, Codex, Cursor, OpenCode and 11 more; Copilot CLI, Goose, Roo Code, Warp and Zed can search only
- What leaves your machine
- Nothing with --provider claude or host, apart from a numbers-only usage summary; the hosted observer and Cloud Sync send data to cmem.ai
- Cost
- Free and open source; you pay model tokens, or a hosted-observer subscription after a 30-day trial
ai-memory
Shared memory server · 3.4.7
- What it solves
- One project memory and handoffs across agents, machines and teammates
- How it captures
- Automatic: hooks capture prompts, tool calls and session boundaries, consolidated into wiki pages at session end
- Where it lives
- A server you run (laptop, homelab or shared host); git-backed markdown is the source of truth
- Needs a model
- No by default: capture, search and handoffs work with no LLM calls and no API key
- Works with
- 20+ harnesses, including Claude Code, Codex, Cursor, Gemini CLI, OpenCode, Devin and Kiro
- What leaves your machine
- Sanitised prompts and tool calls go to the server you run, not to a third party
- Cost
- Free and open source, team features included
Context7
Docs context (MCP or CLI) · 0.12.1 · 4.7.1
- What it solves
- Current, version-specific library docs instead of guessed APIs
- How it captures
- On request: the agent calls resolve-library-id, then query-docs (or the ctx7 CLI through a skill)
- Where it lives
- Upstash's hosted index; the API backend and crawler are private
- Needs a model
- No model of yours; a free API key (created by OAuth during setup) raises rate limits
- Works with
- Any MCP client; ctx7 setup targets Cursor, Claude Code and OpenCode
- What leaves your machine
- Your lookup query and the library name; Upstash says not your code or conversation
- Cost
- Free: 1,000 API calls a month. Pro: $10 per seat a month with 2,000 calls per seat, then $5 per 1,000
Headroom
Context compression proxy · 0.44.0
- What it solves
- More room in the context window by shrinking tool outputs and logs
- How it captures
- Inline: a proxy or wrapper compresses tool outputs, logs and JSON before they reach the model
- Where it lives
- Local: originals are cached so the model can fetch them back with headroom_retrieve
- Needs a model
- No extra model calls
- Works with
- headroom wrap for Claude Code, Codex, Copilot, Cursor, Aider, OpenCode, Cline, goose and more; any OpenAI-compatible client through the proxy; MCP
- What leaves your machine
- Compression runs locally; an anonymous usage beacon is on by default (HEADROOM_TELEMETRY=off)
- Cost
- Free and open source; it lowers your token bill rather than adding to it
MCP Memory server
Knowledge-graph MCP server · 2.1.1
- What it solves
- Facts the agent chooses to save, as a small knowledge graph
- How it captures
- Manual: the agent calls create_entities, create_relations and add_observations
- Where it lives
- One local JSONL file (set MEMORY_FILE_PATH to an absolute path)
- Needs a model
- No
- Works with
- Any MCP client
- What leaves your machine
- Nothing: a local file
- Cost
- Free and open source
claude-mem
thedotmackSession memory pluginApache-2.0
A plugin that runs a second agent beside your coding agent and takes notes while it works. Hooks capture each step, a model compresses it into an observation, and the next session opens with a short index of what matters. The agent pulls full details through MCP search tools only when it needs them.
Pick it if you work alone in Claude Code, Codex or OpenCode and want past sessions remembered automatically.
Best for: One developer on long projects who keeps re-explaining decisions and dead ends, and wants memory to happen with no manual saves.
Standout features
- Nothing to remember to do: capture and the session-start index are automatic.
- Layered search (a compact index first, full observations by ID) keeps the injected context short.
- One npx command finds the agents on your machine and installs for each one you pick.
- <private> tags keep secrets and client data out of storage.
Limits
- Summarising every step costs model tokens on whichever provider you choose.
- Browser setup in versions 15.2.0 to 15.8.2 uploaded the last 30 days of prompts to cmem.ai without asking. v15.8.3 (2 Nov 2026) added a consent step, and earlier uploads are not removed.
- A heavy stack: Node.js 20.19+ or 22.12+, Bun, uv, SQLite, Chroma and a background worker.
- npm install -g claude-mem installs only the SDK, not the plugin.
Skip it if you switch between agents or machines and need one shared memory (ai-memory), or you'd rather not run a background worker that calls a model.
Install with memory on your own plan (bash)
# Summarise on your Anthropic plan and skip the cmem.ai sign-in
npx claude-mem install --provider claude
# Or a local observer through the agent you're already logged in to
npx claude-mem install --provider host
# One agent only
npx claude-mem install --ide opencode
# Check hooks and the worker
npx claude-mem doctor
# Keep sensitive text out of memory
<private>client names, keys, anything you never want stored</private>From the official README and installation guide (Node.js 20.19+ or 22.12+; Bun and uv are installed if missing). Source: claude-mem installation guide (opens in new tab)
ai-memory
akitaonrailsShared memory serverMIT
A Rust memory server that wires MCP, hooks and skills into each agent it finds. What sessions learn becomes plain markdown pages in a git-backed wiki you can read and edit. When you switch tools mid-task, the next agent gets a typed handoff saying what is done, what failed and what is still open.
Pick it if you switch between agents or machines, or want a team's agents to share one project memory, with no LLM bill.
Best for: Developers who use more than one coding agent or machine, and small teams who want every agent to share what one person's sessions learned.
Standout features
- Cross-agent handoffs: quit Claude Code, run ai-memory run codex, and Codex continues where you stopped.
- Memory you own as markdown files, with the database only an index rebuilt from them.
- Zero LLM calls on the default path, so no extra token bill.
- A cross-project profile (package manager, test layout, habits) follows you to new repos.
Limits
- You run and secure a server; hooks capture prompts and tool calls, so treat it like any store of source context.
- More setup than a single plugin: a binary, a service and per-agent wiring.
- The quick install pipes a script into sh (it checks the release checksum first).
Skip it if you only use one agent on one machine (claude-mem or your agent's built-in memory is simpler).
Install, wire your agents, hand off (bash)
curl -fsSL https://github.com/akitaonrails/ai-memory/releases/latest/download/install.sh | sh
ai-memory setup --plan # shows which agents it will wire, changes nothing
ai-memory setup # data dir, per-user service, MCP, hooks, skills
# Quit Claude Code mid-task, then continue in Codex with the handoff
ai-memory run codex
# In any wired agent: "What do you remember about this project?"From the official README and install guide (Linux and macOS; Windows, Docker, AUR and rpm are documented too). Source: ai-memory install guide (opens in new tab)
Context7
UpstashDocs context (MCP or CLI)MIT (MCP server and CLI)
Not memory of your work but memory of the world your code depends on: Context7 looks up current documentation and code examples for the library you're using and puts them in the agent's context. It runs as an MCP server at mcp.context7.com or as a CLI the agent calls through an installed skill.
Pick it if your agent keeps guessing library APIs and you want current, version-specific docs on demand.
Best for: Anyone whose agent writes code against fast-moving libraries and keeps inventing or using outdated APIs.
Standout features
- One-command setup (npx ctx7 setup) that installs the skill or MCP server for you.
- Version-aware: name the version in your prompt to get docs for it.
- Only the lookup query and library name are sent, per Upstash's privacy FAQ.
- Pro adds private repositories for internal docs.
Limits
- Docs come from Context7's own index of community-contributed libraries; private repositories need Pro.
- Free accounts are blocked after 1,000 calls a month, with 20 bonus calls a day until the reset.
- Hosted only unless you buy Enterprise (self-hosted).
Skip it if the library is niche, internal or pinned to an old version (crawl its docs into the repo instead) or you can't send queries to a hosted service.
Set up and prompt (bash)
npx ctx7 setup # or: npx ctx7 setup --cursor | --claude | --opencode
# Remove later with: npx ctx7 remove
# Manual MCP: https://mcp.context7.com/mcp
# with header Authorization: Bearer YOUR_API_KEY
# Prompt
How do I set up a Next.js 16 proxy? use context7From the official README (the ctx7 CLI needs Node.js 22.13 or newer). Source: upstash/context7 README (opens in new tab)
Headroom
Headroom LabsContext compression proxyApache-2.0
The other half of context: not adding knowledge but removing noise. Headroom sits between the agent and the model as a proxy, library or MCP server and compresses repetitive payloads such as logs, search results and JSON. Originals stay cached locally, so nothing is lost if the model needs the full text.
Pick it if long logs and tool outputs fill the context window and you want them compressed, reversibly.
Best for: Heavy agent sessions where long tool outputs crowd out the context window or drive up the bill.
Standout features
- headroom wrap claude (or codex, cursor, opencode) routes an agent through the local proxy in one command; headroom unwrap undoes it.
- Reversible: the model can call headroom_retrieve for any original.
- headroom savings shows what it saved on your own traffic.
Limits
- Savings depend on how repetitive your traffic is; the project's own benchmarks range widely, so measure on your work.
- The anonymous beacon is on until you turn it off.
- headroom wrap is session-scoped: its proxy exits with the agent, so launch each session through it.
Skip it if your problem is the agent forgetting past sessions (a memory tool) or not knowing a library (Context7), rather than context bloat.
Install and wrap an agent (bash)
uv tool install --python 3.13 "headroom-ai[all]"
export HEADROOM_TELEMETRY=off # optional: turn off the anonymous beacon
headroom wrap claude # undo: headroom unwrap claude
headroom doctor
# Or a drop-in proxy for any OpenAI-compatible client
headroom proxy --port 8787
headroom savingsFrom the official README. Source: headroomlabs-ai/headroom README (opens in new tab)
MCP Memory server
MCP steering groupKnowledge-graph MCP serverMIT, moving to Apache-2.0
The official reference memory server: entities, the relations between them and atomic observations, stored in one local file. The agent decides what to save and searches it with search_nodes and open_nodes. It is maintained as an educational example rather than a product.
Pick it if you want a tiny local fact store the agent writes on purpose, with no services or model calls.
Best for: Learning how agent memory works, or a tiny, transparent store of facts about you and your projects with no services and no model calls.
Standout features
- Nine plain tools (create, add, delete, read, search, open) that any MCP client understands.
- A JSONL file you can read, diff and back up; writes from several clients take turns through a lock file.
- Runs with npx or Docker, no account.
Limits
- Nothing is captured unless the agent or your prompt saves it.
- Plain search over names, types and observations: no embeddings or ranking.
- The default file lives inside node_modules, where reinstalling or clearing the npx cache can delete it; always set MEMORY_FILE_PATH.
- Needs Node.js 24 or later through npx.
Skip it if you want memory that fills itself (claude-mem or ai-memory).
Add to your MCP client (json)
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"],
"env": { "MEMORY_FILE_PATH": "/Users/you/memory.jsonl" }
}
}
}From the official README (Node.js 24+; keep the file outside node_modules). Source: Memory server README (opens in new tab)
Set up the free layer first
Before installing anything, give the agent context it can read every session. These cost nothing, travel with the repo through git, and make every tool above work better:
- Write one AGENTS.md that every coding agent reads if you haven't written down build commands and conventions yet. It costs nothing and every agent reads it.
- Claude Code's CLAUDE.md and auto memory if you use Claude Code alone on one machine: auto memory is on by default and needs no install.
- Turn a docs site into agent context if the library is niche, internal or pinned, so Context7 doesn't cover it well.
- Give your agent a conventions file if you use Aider, which loads whatever conventions file you pass it.
Claude Code reads an AGENTS.md only when there is no CLAUDE.md, and loads the first 200 lines or 25KB of its auto memory each session (Claude Code memory docs (opens in new tab)).
How to choose agent memory
- Start with a rules file and your agent's built-in memory. Add a tool only when you notice the same re-explaining every session.
- Then count agents and machines. One agent on one laptop: claude-mem. Several agents, machines or teammates: ai-memory.
- Decide where summarising runs. claude-mem needs a model; pick your own plan or a local observer if prompts must not leave your machine. ai-memory and the MCP Memory server need none.
- Fix knowledge gaps separately. Outdated APIs need docs, not memory: Context7 for popular libraries, or turn a docs site into agent context for niche ones.
- Keep the context lean. If sessions slow down or cost more as they grow, compress tool output with Headroom before adding more memory.
- Still choosing the agent itself? See coding agents compared: Claude Code, Codex CLI, opencode and more.
Keep agent memory safe
Memory tools store your prompts, decisions and code context, and feed them back to a model. Whatever you pick:
- Check the “What leaves your machine” row before installing, and choose a local provider where there is one.
- Keep secrets out: use claude-mem's <private> tags, and never paste keys or client data into a session that is being recorded.
- Update memory plugins promptly: claude-mem's v15.8.3 fixed an installer that uploaded prompts without asking.
- Treat stored memory as untrusted input. A poisoned note is replayed into every future session, so review what gets saved now and then.
- Run any self-hosted memory server behind authentication, like any store of source code.
Agent memory FAQ
What is agent memory?
Anything that carries knowledge from one agent session to the next. It comes in layers: rules files you write (AGENTS.md, CLAUDE.md), notes the agent writes itself (Claude Code's auto memory), session memory captured by a plugin (claude-mem, ai-memory), facts the agent saves on purpose (the MCP Memory server) and external knowledge fetched on demand (Context7). Most setups need the first layer and one or two of the others.
claude-mem vs ai-memory: which should I use?
Pick claude-mem if you work alone and want automatic, model-written summaries with the least setup. Pick ai-memory if you switch between agents or machines, or share a project with teammates: it keeps one git-backed markdown memory on a server you run, adds typed handoffs between agents, and makes no LLM calls by default.
What is the best memory for Claude Code?
Start with what Claude Code ships: a short CLAUDE.md for rules and auto memory, which is on by default and loads the first 200 lines or 25KB of its notes each session. Add claude-mem if you want every session captured and summarised automatically, or ai-memory if you also use Codex, Cursor or another agent on the same project.
Is claude-mem safe to use?
It can be run locally: use --provider claude or --provider host and nothing but a numbers-only usage summary goes to cmem.ai. The hosted observer and Cloud Sync send data to cmem.ai. Browser setup in versions 15.2.0 to 15.8.2 uploaded 30 days of prompts without asking; v15.8.3 (2 November 2026) added a consent step, so update, and wrap secrets in <private> tags.
Is Context7 memory?
Not memory of your work. Context7 fetches current, version-specific library documentation into the agent's context when it needs it. It solves a different failure, outdated or invented APIs, and pairs well with a session memory tool.
Is Context7 free?
Yes, with limits. The Free plan includes 1,000 API calls a month on public libraries; after that you're blocked, with 20 bonus calls a day until the month resets. Pro costs $10 per seat a month with 2,000 calls per seat, then $5 per 1,000, and adds private repositories.
Do memory tools make coding agents better?
Sometimes. In VibeMemBench (2026), injecting verified past experience helped most agents, but when four existing memory systems had to build and retrieve that experience themselves, eleven of twelve agent and system pairings did no better than no memory. Treat memory as a way to save re-explaining, keep it small, and check it on your own work.
Where does agent memory store my data?
On this page: claude-mem in ~/.claude-mem unless you choose its hosted observer or Cloud Sync; ai-memory on the server you run; the MCP Memory server in one JSONL file; Headroom caches originals locally. Context7 stores nothing about you but receives your lookup queries.
What about Mem0, Zep and Letta?
They are memory layers and runtimes mainly for agents you build into your own app, through an SDK or API. We haven't reviewed them yet, so they aren't compared here. If you're building your own agent, start with our agent SDK comparison.
How we checked
Versions and dates come from npm, PyPI and GitHub releases. Features, licences, defaults, prices and snippets come from each project's own docs, repositories and pricing pages. We don't make or sell a memory tool, and no recall scores are claimed: published memory benchmarks mostly come from the tools' own makers. We only compare tools that have a MoreLime.AI entry; Mem0, Zep, Letta, Supermemory, agentmemory and Basic Memory aren't covered yet. Building an agent of your own? See agent SDKs compared. Giving your agent a browser? See browser agents compared. Last verified .
Newsletter
Get the best new A.I. picks in your inbox
The best new agent workflows and tools we’ve vetted, with a clear verdict on each. Short, occasional, useful.