---
title: "7 tools that give your AI agent long-term memory"
slug: "ai-agent-memory"
description: "Seven verified tools that give AI agents long-term memory — an MCP server for Claude, embeddable libraries and self-hosted graph engines."
published: "2026-11-11"
verifiedAt: "2026-11-11"
picks: 7
canonical: "https://aifree.dev/best/ai-agent-memory"
---

# 7 tools that give your AI agent long-term memory

> Seven verified tools that give AI agents long-term memory — an MCP server for Claude, embeddable libraries and self-hosted graph engines.

Published 2026-11-11. Last checked 2026-11-11.

An agent that forgets starts over every morning. These seven open-source tools give it memory that survives the session: preferences, facts, decisions, code context.

Every pick pushed a commit in the last 90 days (checked 2026-11-11), has an install command from its own docs, and a license that lets you run it free. Ordered easy to advanced: a config file, then embeddable libraries, then servers and graph engines you self-host.

## The 7 tools at a glance

| Tool | What it does | Price | Install |
| --- | --- | --- | --- |
| Memory MCP server | Knowledge-graph memory inside Claude | Free · OSS (MIT → Apache-2.0) | config in `claude_desktop_config.json` |
| mem0 | Memory layer for any LLM app | Free · OSS (Apache-2.0) | `pip install mem0ai` |
| supermemory | Memory engine with hosted or self-hosted API | Free · OSS (MIT) | `npm install supermemory` |
| LangMem | Long-term memory for LangChain agents | Free · OSS (MIT) | `pip install -U langmem` |
| Letta Code | Agent harness with self-editing memory | Free · OSS (Apache-2.0) | `npm install -g @letta-ai/letta-code` |
| Graphiti | Temporal knowledge graph engine | Free · OSS (Apache-2.0) | `pip install graphiti-core` |
| cognee | Self-hosted graph + vector memory platform | Free · OSS (Apache-2.0) | `pip install cognee` |

## 1. Memory MCP server: Claude remembers you, zero code

[The Memory MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) is the MCP project's reference memory server. MCP (Model Context Protocol) is how Claude connects to tools; this one lets Claude remember facts about you across chats.

**What:** Entities, relations and observations live in a local knowledge graph Claude reads and writes through MCP.

**Why:** Setup is a JSON block in `claude_desktop_config.json` — no code, and the graph is a readable file on your disk.

**Use when:** You want persistent memory in Claude Desktop or Claude Code today.

**Install:**

```json
{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"],
      "env": { "MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl" }
    }
  }
}
```

**Catch:** Its README calls it a basic implementation: a flat graph in one JSONL file, with no semantic search. Set `MEMORY_FILE_PATH`, because the default file sits in the npx cache and a cache clear deletes it.

## 2. mem0: the memory layer you pip install

[Mem0](https://github.com/mem0ai/mem0) adds a memory layer to AI assistants and agents: it remembers user preferences and updates them over time. It has 68,000+ GitHub stars (2026-11-11).

**What:** Two calls — `add()` to store, `search()` to recall — backed by extraction and consolidation instead of raw chat logs.

**Why:** It drops into Python or Node apps (`npm install mem0ai` for Node).

**Use when:** You are adding memory to an existing chatbot or agent without changing frameworks.

**Install:**

```bash
pip install mem0ai
```

**Catch:** The library has no UI. A dashboard needs the self-hosted server or the paid cloud platform.

## 3. supermemory: one API, hosted or self-hosted

[Supermemory](https://github.com/supermemoryai/supermemory) is a memory engine with the same API locally and on its hosted platform. You switch between them by changing one `baseURL`.

![Supermemory's plugin manager: Claude Code connected with persistent memory for coding context across sessions, next to OpenCode and ClawdBot](https://f.aifree.dev/media/best/ai-agent-memory/57929b72f2901b99.webp#w=1280&h=734)

**What:** A memory engine behind an API, with Docker images for self-hosting and connectors for coding agents.

**Why:** Starting on the cloud tier does not lock you in.

**Use when:** You want memory as a service now and the option to move it in-house later.

**Install:**

```bash
npm install supermemory
```

**Catch:** Self-hosting means running its Docker compose stack plus an LLM provider key.

## 4. LangMem: memory inside LangChain

[LangMem](https://github.com/langchain-ai/langmem) is LangChain's memory library. It extracts important facts from conversations, refines prompts and keeps long-term memory.

**What:** Functional primitives that work with any storage, plus native integration with LangGraph's storage layer.

**Why:** Agents can save memories mid-conversation, or a background job consolidates them later, all inside LangChain.

**Use when:** Your agents already live in LangGraph and memory should too.

**Install:**

```bash
pip install -U langmem
```

**Catch:** Extraction runs an LLM on your conversations — budget those API calls.

## 5. Letta Code: agents that edit their own memory

[Letta Code](https://github.com/letta-ai/letta-code), from the team behind MemGPT, is a stateful agent harness. Its agents rewrite their own memory, skills and prompts over time, instead of an outside service deciding what to keep.

**What:** A CLI agent where memory blocks are part of the agent's state, tracked in git.

**Why:** The MemGPT lineage — memory as a first-class object the agent can rewrite.

**Use when:** You are building agents from scratch and want memory management built in, not bolted on.

**Install:**

```bash
npm install -g @letta-ai/letta-code
```

**Catch:** It is a whole agent, not a library you import into yours. Remote computers need a Letta account.

## 6. Graphiti: a temporal knowledge graph engine

[Graphiti](https://github.com/getzep/graphiti) is Zep's framework for temporal knowledge graphs. Each fact carries a validity window, so memory shows what was true at the time.

**What:** A Python core plus an MCP server, backed by a graph database you choose.

**Why:** When facts change (roles, prices, plans), old ones are marked invalid instead of competing with new ones.

**Use when:** Your domain's facts expire or get superseded and stale memory is a bug.

**Install:**

```bash
pip install graphiti-core
```

**Catch:** Bring your own graph database — Neo4j, FalkorDB or Amazon Neptune — and run it.

## 7. cognee: the self-hosted memory platform

[Cognee](https://github.com/topoteretes/cognee) is an open-source memory platform that turns documents, code and conversations into a self-hosted knowledge graph your agents can search.

![cognee demo: two Claude Code terminals side by side, one plain and one wired to cognee memory](https://f.aifree.dev/media/best/ai-agent-memory/afb34c28c224e0df.webp#w=1200&h=390)

**What:** Pipelines that build a graph plus vector index, with reference MCP and REST servers.

**Why:** The whole memory pipeline in one package, from raw documents to queryable memory.

**Use when:** You want an all-in-one self-hosted platform rather than composing libraries.

**Install:**

```bash
pip install cognee
```

**Catch:** It runs on small local CPU models with no API key, but generated answers need an LLM key.

## Which one to try first

Want Claude to remember you tonight → #1. Adding memory to an existing app → #2. Memory as an API with a cloud escape hatch → #3. Already on LangGraph → #4. Agents that manage their own memory → #5. Facts that change over time → #6. One self-hosted platform for everything → #7.

## Picks

1. [Memory MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/memory)
2. [mem0](https://github.com/mem0ai/mem0)
3. [supermemory](https://github.com/supermemoryai/supermemory)
4. [LangMem](https://github.com/langchain-ai/langmem)
5. [Letta Code](https://github.com/letta-ai/letta-code)
6. [Graphiti](https://github.com/getzep/graphiti)
7. [cognee](https://github.com/topoteretes/cognee)

## Frequently asked questions

### How do I give Claude Desktop persistent memory?

Add the official Memory MCP server to claude_desktop_config.json with npx -y @modelcontextprotocol/server-memory. Claude then reads and writes a local knowledge graph — entities, relations and observations — stored in a JSONL file on your disk.

### Is mem0 free?

Yes, the Apache-2.0 library is free with pip install mem0ai, and a free self-hosted server adds a dashboard. Mem0's managed cloud platform is the paid option.

### Do I need a memory layer if I have a vector database?

A vector database stores and retrieves embeddings; a memory layer extracts facts from conversations, consolidates them over time and decides what to recall. Many setups pair the two — a memory layer on top of a vector or graph store.

## Sources

- https://github.com/modelcontextprotocol/servers/tree/main/src/memory
- https://github.com/mem0ai/mem0
- https://github.com/supermemoryai/supermemory
- https://github.com/langchain-ai/langmem
- https://github.com/letta-ai/letta-code
- https://github.com/getzep/graphiti
- https://github.com/topoteretes/cognee
- https://github.com/modelcontextprotocol/servers

HTML page: https://aifree.dev/best/ai-agent-memory
