# memory-lean [Health: Active]

**Category:** 🧠 Knowledge & Memory  
**Repository:** https://github.com/zamansheikh/memory-lean  
**GitHub Stars:** 4  
**npm Downloads (last month):** 1958  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/memory-lean

## Description
Token-lean memory for AI agents: a knowledge graph searched cheaply. Drop-in for server-memory.

## Tools
Capabilities this server exposes over MCP:

- **search_nodes** — Ranked list of entity names with counts and up to two matching snippets each. Every word must match the name, type, an observation, or the type of a relation touching the entity. Entities that match only in archived facts are named after them, with a snippet each when nothing current matches.
- **open_nodes** — The full entities you name, as compact text, with every relation touching them and their archive count. With `related: true`, related rules and pending work come first, each with its first fact. A name that is right but for its case or separators still opens; other unknown names come back with "did…
- **read_graph** — An index: entity names grouped by type, with observation counts. Never the observations. In a large graph the biggest types are given as a count; `entityType` lists one.
- **create_entities** — Creates entities; existing names are skipped.
- **create_relations** — Creates relations between existing entities; duplicates are skipped.
- **add_observations** — Adds facts to an entity, enforcing the length limit and the per-entity cap.
- **replace_observation** — Replaces one fact in place. The old fact is named by its exact text or by a part of it (8+ characters) that no other fact of the entity contains. *Not in the reference server.*
- **delete_observations** — Removes observations, named by exact text or by such a part.
- **delete_relations** — Removes specific relations.
- **delete_entities** — Removes entities and every relation touching them. Their archived facts stay on disk, marked as deleted, and are not passed on to a later entity of the same name.
- **rename_entity** — Renames an entity, keeping its observations, relations and archive. *Not in the reference server.*
- **archived_observations** — Lists what was archived for an entity, optionally filtered, and restores chosen facts. *Not in the reference server.*

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "memory-lean": {
    "command": "npx",
    "args": ["-y","memory-lean"],
    "env": {
      "MEMORY_FILE_PATH": ""
    }
  }
}
```

**Requires environment variables:** `MEMORY_FILE_PATH` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What memory-lean does

memory-lean provides persistent memory for AI coding agents through the Model Context Protocol. It models information as entities, relations, and observations, allowing an agent to record projects, dependencies, shipped versions, pending work, and learned rules. The graph is stored in a local JSONL file and can be shared by multiple agents and sessions.

The server is designed as a drop-in alternative to the reference memory server. It uses the same memory file and familiar tool names while making read responses more compact. Search results contain ranked entity names, match counts, and a small number of matching snippets rather than returning every entity in full.

## How it works

The graph is created on the first write. By default, memory-lean uses `~/.claude/memory-graph/memory.jsonl`; `MEMORY_FILE_PATH` can relocate it. Facts are kept short and limited per entity. Additional facts move into an archive, which keeps routine graph reads smaller while retaining older information for inspection and restoration.

Search matches words in entity names, types, observations, and relation types connected to an entity. Opening an entity returns its compact details, relations, and archive count. The graph index groups names by type and reports observation counts without including observation text. Writes use a lock for parallel sessions, and daily backups are maintained locally. The server does not use network access.

A separate web UI can display the graph, group entities by type, highlight relations, search content, and edit the same data. Changes made by agents appear in the UI shortly after they occur.

## Setup and configuration

Node.js 18 or newer is required. Install globally with:

```bash
npm install -g memory-lean
```

Or run it without a global installation:

```json
{
  "mcpServers": {
    "memory": { "command": "npx", "args": ["-y", "memory-lean"] }
  }
}
```

For agent guidance, generate protocol instructions with `npx -y memory-lean --protocol` and place the output in the rules file used by the agent. The web interface starts with `npx -y memory-lean --ui`; `--ui --demo` opens a sample graph.

Claude Code can install the supplied plugin, which also adds setup instructions and a `/memory-ui` command. An existing session must be restarted or reconnected after updating the server.

## Tools and capabilities

- `search_nodes` finds ranked entities and matching snippets using token-saving results.
- `open_nodes` returns selected entities, their relations, and archive counts; related rules and pending work can be prioritized.
- `read_graph` provides a type-based entity index and observation counts.
- `create_entities` and `create_relations` add graph structure while skipping duplicates.
- `add_observations` records facts subject to length and per-entity limits.
- `replace_observation`, `delete_observations`, `delete_relations`, and `delete_entities` modify stored data.
- `rename_entity` preserves an entity's facts, relations, and archive while changing its name.
- `archived_observations` lists archived facts and can restore selected entries.

The last three capabilities—replacement, renaming, and archived-fact management—are additions beyond the reference server's tool set.

## Limitations and notes

Search is intentionally lexical: every search word must match an entity name, type, observation, or touching relation type. A large graph may show only counts for its biggest types in the index. Deleting an entity removes its relations and keeps its archived facts marked as deleted, preventing those facts from being inherited by a later entity with the same name.

The default storage path is local and shared across agents using it. Moving the file requires setting `MEMORY_FILE_PATH` consistently for each client. A narrow search produces less benefit from response reduction than a broad search because there is less output to trim.

_Full upstream README: https://allmcps.com/mcp/memory-lean/readme_

