Myelin
<div align="center">
<img src="img/myelin.png" alt="Myelin" width="200"/>
<h1>Myelin</h1>
<strong>Neuromorphic long-term AI memory</strong> — brain-inspired persistent context for AI agents.
<p>
<a href="#quick-start">Quick Start</a> ·
<a href="#how-it-works">How It Works</a> ·
<a href="#benchmark-results">Benchmarks</a> ·
<a href="#cli--mcp-tools">CLI & Tools</a> ·
<a href="CONTRIBUTING.md">Contributing</a>
</p>
<p>
<a href="https://github.com/et-do/myelin/blob/main/LICENSE"><img src="https://img.shields.io/github/license/et-do/myelin?colorA=363a4f&colorB=b7bdf8" alt="License"></a>
<a href="https://pypi.org/project/myelin-mcp/"><img src="https://img.shields.io/pypi/v/myelin-mcp?colorA=363a4f&colorB=b7bdf8&label=pypi" alt="PyPI"></a>
<a href="https://github.com/et-do/myelin/actions/workflows/ci.yml"><img src="https://github.com/et-do/myelin/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
<a href="https://github.com/et-do/myelin/stargazers"><img src="https://img.shields.io/github/stars/et-do/myelin?colorA=363a4f&colorB=b7bdf8&style=flat" alt="Stars"></a>
<a href="https://github.com/et-do/myelin/issues"><img src="https://img.shields.io/github/issues/et-do/myelin?colorA=363a4f&colorB=b7bdf8" alt="Issues"></a>
<a href="https://github.com/et-do/myelin/commits/main"><img src="https://img.shields.io/github/last-commit/et-do/myelin?colorA=363a4f&colorB=b7bdf8" alt="Last Commit"></a>
<img src="https://img.shields.io/badge/python-≥3.11-b7bdf8?colorA=363a4f" alt="Python 3.11+">
</p>
<br />
<p>
Myelin gives AI tools (GitHub Copilot, Claude, Cursor) a local, private memory system<br />
modeled after how the human brain stores and retrieves information.<br />
It encodes context, strengthens with use, separates patterns, and prunes what fades —<br />
no LLM calls, no API keys, fully offline.
</p>
<p>
<strong>98.2% Recall@5 on LongMemEval</strong> — beats GPT-4o-based systems using only local 22M-parameter models.
</p>
</div>
<br />
## Table of Contents
- [Why Myelin](#why-myelin)
- [Quick Start](#quick-start)
- [Setup Guides](#setup-guides)
- [Teaching Your Agent](#teaching-your-agent)
- [Benchmarks](#benchmark-results)
- [How It Works](#how-it-works)
- [CLI & MCP Tools](#cli--mcp-tools)
- [Configuration](#configuration)
- [Upgrading](#upgrading)
- [Contributing](#contributing)
---
## Why Myelin
**The problem:** Every AI agent conversation starts from scratch. Context is lost between sessions, across tools, across projects. Agents repeat mistakes, forget decisions, and can't build on prior work.
**What Myelin does:**
- **Persistent memory across sessions** — decisions, patterns, and debugging insights survive after the chat window closes
- **Cross-agent context** — Copilot, Claude, and Cursor share the same memory. What one agent learns, all agents can recall.
- **Cross-project knowledge** — architectural patterns from project A inform decisions in project B
- **Self-organizing** — auto-classifies memory types (decisions, procedures, events), auto-infers recall filters, auto-prunes stale knowledge
- **Private and local** — all data stays on your machine (or your team's server). No API keys. No cloud dependency. No data leaving your network.
- **Gets better with use** — frequently co-recalled memories strengthen their association ([Hebbian learning](#post-recall)). The more you use it, the better recall gets.
- **98.2% Recall@5 on LongMemEval** — beats LLM-based systems using only local 22M-parameter models
---
## Quick Start
**Requirements:** Python 3.11+ · ~500 MB disk (models download on first run) · No GPU · No API keys
### Install
**Option A — uv (recommended, no admin required):**
**macOS / Linux:**
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install myelin-mcp
```
**Windows (PowerShell):**
```powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
uv tool install myelin-mcp
```
**Option B — pip:**
```bash
# --user installs to ~/.local/bin (Linux/macOS) or %APPDATA%\Python\...\Scripts (Windows)
# No admin rights required
pip install --user myelin-mcp
```
> [!NOTE]
> **After installing, run `myelin status` once before opening VS Code.** This downloads ~500 MB of embedding models and pre-warms them so your first tool call is instant. The MCP server starts without waiting for models, but the first `store` or `recall` will be slower if models haven't loaded yet.
> If `myelin` isn't found, your user bin dir isn't on `$PATH`. Add `~/.local/bin` to your shell profile (Linux/macOS), or find the correct path with `python -m site --user-scripts` (Windows).
### Configure your AI tool
Add Myelin as an MCP server.
**VS Code** — open `mcp.json` (`Ctrl+Shift+P` → `MCP: Open User Configuration`):
```json
{
"servers": {
"myelin": {
"command": "myelin",
"args": ["serve"]
}
}
}
```
> [!IMPORTANT]
> **`myelin` not found by VS Code?** MCP hosts launch in a clean environment and may not inherit your shell `$PATH`. Use the full path (e.g. `~/.local/bin/myelin` on Linux/macOS) or switch to `"command": "uvx"` with `"args": ["myelin-mcp", "serve"]` — `uvx` resolves the tool location automatically.
**Claude Code** — one command, in a terminal:
```bash
claude mcp add --transport stdio --scope user myelin -- myelin serve
```
`--scope user` makes Myelin available in every project. With `--scope project` the server is written to a `.mcp.json` file in the repository instead, which you can commit to share it with the team; Claude Code asks each person once before using it.
**Claude Desktop** — add the same block as for VS Code to `claude_desktop_config.json`, with `mcpServers` as the top-level key instead of `servers`.
### Verify
1. **Restart VS Code** (`Ctrl+Shift+P` → `Developer: Reload Window`).
2. Open **Output** panel (`Ctrl+Shift+U`) → **MCP: myelin** — you should see the server start and discover tools:
<p align="center">
<img src="img/vscode-mcp-output.png" alt="MCP output showing the Myelin server starting and discovering its tools" width="700"/>
</p>
3. Click **Configure Tools** (filter icon in Chat input bar) to verify Myelin's tools are listed:
<p align="center">
<img src="img/vscode-configure-tools.png" alt="Configure Tools button in VS Code Chat" width="400"/>
</p>
<p align="center">
<img src="img/vscode-myelin-tools.png" alt="Myelin tools listed in VS Code Configure Tools" width="600"/>
</p>
4. Ask your agent: *"Check myelin status"* — it should call the `status` tool and return memory counts.
In **Claude Code**, run `claude mcp list` in a terminal, or `/mcp` inside a session: `myelin` should be listed as connected. Then ask the same question.
**Next:** the agent can now use memory, but it will not do so on its own. [Teaching Your Agent](#teaching-your-agent) has the instructions to give it.
---
## Setup Guides
Myelin stores all data in a single directory (`~/.myelin` by default). How you deploy that directory determines the scope of memory.
### Personal (Cross-Project)
**Best for:** Solo developers who want one memory across all projects and agents.
This is the default setup. Follow the [Quick Start Install](#install) steps above — they set up user-level config by default.
All projects and agents share `~/.myelin/`. Use `project` metadata when storing to keep work organized — just tell your agent:
> *"Store this as project=backend, scope=auth"*
Recall can filter by project or search across everything.
### Per-Repository
**Best for:** Teams who want memory scoped to a single repo, committed alongside the code.
**1. Set `MYELIN_DATA_DIR` to a path inside the repo:**
Create a `.vscode/mcp.json` in the repo:
```json
{
"servers": {
"myelin": {
"command": "myelin",
"args": ["serve"],
"env": {
"MYELIN_DATA_DIR": "${workspaceFolder}/.myelin"
}
}
}
}
```
> [!TIP]
> Use `"command": "uvx"` with `"args": ["myelin-mcp", "serve"]` if `myelin` isn't on the PATH in your MCP host's environment.
**2. Decide whether to commit the data:**
- **Commit `.myelin/`** — the team shares accumulated knowledge (architectural decisions, conventions, debugging history). New contributors inherit project memory. Good for stable, curated knowledge. Read [Secrets and personal data](#secrets-and-personal-data) first: what is in the directory becomes part of the repository's history.
- **Gitignore `.myelin/`** — each developer builds their own memory. Add `.myelin/` to `.gitignore`. Good for personal workflow memory you don't want to share.
**3. Add agent instructions** (see [Teaching Your Agent](#teaching-your-agent) below).
### Multi-Agent (Shared Instance, Isolated Namespaces)
**Best for:** Multiple trusted agents sharing one Myelin data directory, each
working from its own memory pool.
Myelin filters recalls by `agent_id` at the database level:
| Recall called with | Returns |
|---|---|
| `agent_id="copilot"` | copilot's memories plus shared ones — never `ci-bot`'s |
| no `agent_id` | shared memories only |
The same boundary applies to the duplicate check (`store` and `overwrite` only
ever compare against, or replace, memories in the caller's own namespace) and
to pinned memories.
**However, `agent_id` is not authenticated.** The server accepts whatever
value the caller supplies. Any agent — or user — that knows another agent's
`agent_id` can read and write to that namespace. There is no credential,
token, or OS-level enforcement preventing this.
This means `agent_id` is a **namespace convention for cooperating agents**,
not an access-control boundary. It is appropriate when:
- Agents are trusted (same team, same deployment)
- The goal is preventing accidental cross-contamination between agent contexts
- You are not trying to hide memories from a potentially adversarial caller
If hard isolation is a requirement, run separate Myelin instances pointing at
separate data directories.
**To keep an agent in its own namespace**, set `MYELIN_AGENT_ID` in that
client's MCP config. Each client starts its own server process, so each can
have its own default, and the model does not need to remember anything:
```json
"env": { "MYELIN_AGENT_ID": "copilot" }
```
An `agent_id` passed on a `store` or `recall` call overrides the default.
Without either, memories are written to the shared namespace — visible to all
callers regardless of `agent_id`.
The shared namespace (no `agent_id`) is intentional for shared project context
that every agent should see, such as architectural decisions and conventions.
`myelin import`, `import-md`, `ingest` and the Obsidian/GitHub importers write
to it.
```bash
# Scope a debug-recall diagnostic to one namespace
myelin debug-recall "auth approach" --agent-id copilot
```
---
### Team / Cloud
**Best for:** Organizations that want shared memory across team members and CI environments.
Myelin itself is a local process — it reads/writes to a data directory. For team sharing, you point that directory at shared storage. This does not require deploying Myelin as a hosted service.
**Option A: Shared network drive or mounted volume**
Point `MYELIN_DATA_DIR` to a shared filesystem (NFS, SMB, EFS, GCS FUSE, etc.):
```bash
export MYELIN_DATA_DIR=/mnt/team-memory/myelin
```
SQLite uses WAL mode and file-level locking, which works on most network filesystems for light concurrency. For heavy concurrent writes, consider Option B.
**Option B: Sync via export/import**
Use the CLI to periodically export and import memory between environments:
```bash
# On one machine — export
myelin export team-memory.json
# On another machine — import
myelin import team-memory.json
```
This can be automated in CI (e.g., export after each deploy, import at dev environment setup).
**Seeding from existing docs**
Use `myelin ingest` to bulk-load existing documentation, notes, or wiki exports into memory:
```bash
myelin ingest ./docs/ --project myapp --source wiki
myelin ingest ./decisions/ --scope architecture --source adr
```
Markdown files with YAML frontmatter get their metadata (`project`, `scope`, `tags`, `memory_type`) automatically applied per file. JSON exports from other Myelin instances can also be ingested directly.
**Option C: Shared server (future)**
A dedicated Myelin server with HTTP transport is on the roadmap. For now, the export/import workflow covers most team use cases.
---
## Teaching Your Agent
Connecting the MCP server gives your agent the *ability* to store and recall — but it won't use memory automatically unless you tell it to.
### Agent Instructions
Copy the ready-made example for your tool into your project, or paste the block below into the instructions file you already have:
| Tool | File in your project | Ready-made example |
|---|---|---|
| Claude Code | `CLAUDE.md` (or `~/.claude/CLAUDE.md` for every project) | [`examples/CLAUDE.md.example`](examples/CLAUDE.md.example) |
| GitHub Copilot (VS Code) | `.github/copilot-instructions.md` | [`examples/copilot-instructions.md.example`](examples/copilot-instructions.md.example) |
| Other agents | their equivalent (many read `AGENTS.md`) | use the block below |
The same text works in all of them. Add a line of your own naming the `project` value to use, for example: *In this repository, use `project="myapp"`.*
```markdown
## Memory
You have a long-term memory (Myelin) through MCP tools. It persists across
sessions and is shared by every AI tool connected to it.
### Recall
- At the start of a task, `recall` what is known about the project and the
problem. Ask in plain words ("how do we handle auth tokens") and pass
`project`.
- Recall again before an architectural decision, and whenever the user refers
to earlier work ("like last time", "what did we decide").
- Time phrases work in the query: "yesterday", "last week", "3 days ago".
- A result marked `pinned` is standing context the user chose to always
include.
### Store
- Store decisions with their reason, the root cause of non-trivial bugs,
conventions and gotchas you discover, and preferences the user states.
- One fact or decision per memory, written so it makes sense on its own:
"We sign JWTs with RS256 so the gateway can verify without the signing
secret", not "We use JWT".
- Always pass `project`. Add `scope` for the area ("auth", "database") and
`tags` for cross-cutting topics. Leave `memory_type` unset unless you are
sure; it is inferred.
- A `rejected` result means the content was too short or is already known.
Carry on.
- When a fact changes, store the new version with `overwrite=true`. If the
old version still comes back in a recall, `forget` it by id.
### Do not
- Store secrets, credentials or personal data.
- Store code, or anything the repository and its git history already record.
Store the reasoning.
- Store trivia: typo fixes, one-off commands, a summary of the conversation.
- Call `forget`, `decay_sweep`, `pin_memory` or `unpin_memory` unless the
user asks. The server maintains itself.
```
### Tips for Effective Memory
- **Use `project` consistently.** It's the primary organizational axis. An agent working on "myapp" should always store with `project="myapp"` so recall can filter by project.
- **Pin critical context.** Use `pin_memory` for things every session should know (system architecture, active conventions, team preferences). Pinned memories are prepended to every recall result via the [Thalamus overlay](#post-recall).
- **Consolidation looks after itself.** It runs when the server starts, on every 50th store and before `myelin graph` draws; `myelin consolidate` runs it on demand. It builds the [semantic network](#consolidation-offline) — entity relationships that improve recall quality over time.
- **Run decay periodically.** `myelin decay` prunes memories that haven't been accessed in 90+ days with fewer than 2 accesses. Keeps the memory clean without manual curation.
- **Export before major changes.** `myelin export backup.json` creates a full backup you can restore with `myelin import`.
---
## Benchmark Results
### LongMemEval_S — 500 questions, zero LLM calls
[LongMemEval](https://github.com/xiaowu0162/LongMemEval) (ICLR 2025) tests long-term conversational memory: can the system find the right conversation session given a natural-language question? **R@k** measures whether *any* ground-truth session appears in the top-k results (binary hit).
| Metric | Myelin | MemPalace (GPT-4o) |
|--------|--------|---------------------|
| **R@1** | **91.2%** | — |
| **R@3** | **98.0%** | — |
| **R@5** | **98.2%** | 96.6% |
| **R@10** | **98.2%** | — |
| **NDCG@5** | **95.2%** | — |
| LLM calls | 0 | requires GPT-4o |
98.2% R@5 (491/500 questions) using only local models — no LLM calls. Exceeds MemPalace's 96.6% R@5 which relies on GPT-4o.
#### Per-Category Breakdown
| Category | Questions | R@1 | R@5 |
|----------|-----------|-----|-----|
| knowledge-update | 78 | 97.4% | **100.0%** |
| single-session-assistant | 56 | 100.0% | **100.0%** |
| single-session-user | 70 | 88.6% | **100.0%** |
| multi-session | 133 | 91.0% | 98.5% |
| temporal-reasoning | 133 | 90.2% | 96.2% |
| single-session-preference | 30 | 70.0% | 93.3% |
### LoCoMo — 1,986 questions, 10 conversations
[LoCoMo](https://github.com/snap-research/locomo) (Snap Research) tests memory over long conversations. Stricter metric: **R@k** = fraction of *all* evidence sessions found in top-k (not binary hit). Multi-evidence questions require retrieving multiple sessions simultaneously.
| Metric | Myelin | MemPalace hybrid v5 |
|--------|--------|---------------------|
| **R@5** | **88.9%** | — |
| **R@10** | **95.1%** | 88.9% |
| **R@20** | **95.1%** | — |
### Latency — 8-core CPU, no GPU
| Operation | n | Mean | Min | Max | Notes |
|-----------|---|------|-----|-----|-------|
| **store** | 100 | **94ms** | 47ms | 149ms | embed (15ms) + dedup check + gist + ChromaDB write |
| **store** | 500 | **67ms** | 43ms | 130ms | flat: HNSW dedup-query adds <5ms over 500 items |
| **recall** | 100 | **142ms** | 94ms | 171ms | 3-probe pipeline: embed + HNSW + CE rerank |
| **recall** | 500 | **130ms** | 116ms | 153ms | flat retrieval scaling confirmed |
| **recall** | 1000 | **134ms** | 104ms | 173ms | still flat at 10× scale |
| recall + project filter | 100 | **162ms** | 120ms | 224ms | similar to unfiltered at n=100; benefits grow with n |
| recall + scope filter | 100 | **149ms** | 76ms | 188ms | similar to unfiltered at n=100; benefits grow with n |
| [Hebbian](#post-recall) + [Thalamus](#post-recall) overhead | 100 | **+~10ms** | — | — | seeded Hebbian (~125 pairs); SQLite WAL reads/writes |
**Retrieval scales flat with collection size.** Recall averages 142ms at n=100, 130ms at n=500, and 134ms at n=1000 — all within the variance of each other. The bottleneck is fixed model inference: embedding the query (~15ms) and cross-encoder scoring the candidate pool (~60ms across 3 probes). HNSW index search adds <5ms at these scales. This means retrieval stays fast as memory grows — a user with 1000 memories pays the same latency as one with 100.
**Store variance is high.** The 47ms–149ms range reflects gist extraction cost, which varies with content length and semantic density. Short, single-topic memories hit the low end; anything requiring multi-chunk gists hits higher. Mean of ~80ms is well within the 500ms agent tool-call budget.
**Filters add negligible overhead at small n.** At n=100, project and scope filters show ~10–20ms higher means than unfiltered recall, but this is within measurement noise (stddev 24–38ms). Filter benefits appear at larger collection sizes where a filter can meaningfully reduce the cross-encoder candidate pool.
### Methodology
- **LongMemEval**: [LongMemEval_S cleaned](https://huggingface.co/datasets/xiaowu0162/longmemeval-cleaned) — 500 questions, 6 categories (ICLR 2025). Oracle mode, chunks deduplicated to sessions.
- **LoCoMo**: 10 conversations, 1,986 QA pairs. R@k = fraction of evidence sessions found in top-k.
- **Latency**: `pytest-benchmark` micro-timings, ephemeral ChromaDB, warm models, 8-core CPU, no GPU, n=100–1000 memories. Run `uv run pytest tests/benchmarks/test_latency.py -p no:xdist --override-ini="addopts="` to reproduce.
- **Models**: `all-MiniLM-L6-v2` (22M params) + `cross-encoder/ms-marco-MiniLM-L-6-v2` (22M params)
- **Hardware**: 8-core CPU, no GPU
- **LLM calls**: Zero in retrieval
---
## How It Works
### Core Concepts
| Concept | Neuroscience | Myelin Equivalent |
|---------|-------------|-------------------|
| **Cortical Region** | Specialized brain areas for different domains | `project` — each project is a distinct neural territory |
| **Engram Cluster** | Co-active neurons forming a memory trace | `scope` — related memories (auth, billing) share a cluster |
| **Memory System** | Distinct encoding/retrieval strategies | `memory_type` — episodic, semantic, procedural, prospective |
| **Association Fiber** | White matter connecting co-active regions | Hebbian links — built from co-retrieval patterns |
| **Gist Trace** | Meaning and detail stored in parallel | Vector embedding (gist) + raw content (verbatim) |
| **Sparse Code** | Only 1-5% of neurons fire per stimulus | Chunking — each segment is a focused representation |
### Memory Systems
| System | `memory_type` | What It Stores | Example |
|--------|---------------|----------------|---------|
| **Episodic** | `episodic` | Events with temporal context | "What happened when we deployed?" |
| **Semantic** | `semantic` | Decisions, facts, knowledge | "What did we decide for auth?" |
| **Procedural** | `procedural` | Habits, preferences, how-to | "How do we run migrations?" |
| **Prospective** | `prospective` | Future plans, recommendations | "What are the next steps?" |
### Pipeline Overview
```
STORE (fast, zero-LLM) RECALL (multi-probe)
content query
│ │
▼ ▼
Amygdala ─── reject noise Query Planner ─── auto-infer filters
│ │
▼ ▼
Prefrontal ── auto-classify Multi-probe (3 query variants)
│ │
▼ ▼
Chunking ──── pattern separation Per-probe retrieval
│ │ dual-path search + re-rank
▼ ▼
Entorhinal ── context coordinates Pool merge + cross-encoder re-score
│ │
▼ ▼
Perirhinal ── gist extraction Spreading activation + lateral inhibition
│ │
▼ ▼
Hippocampus ─ embed + store Return top-k
```
### Post-Recall
| Component | What It Does |
|-----------|-------------|
| **Hebbian Boost** | Co-retrieved memories strengthen mutual links |
| **Thalamus Overlay** | Prepends pinned memories, tracks recency |
| **Decay Sweep** | TTL pruning of unrehearsed, low-access memories |
| **Consolidation** | Entity extraction → semantic network (at server start and every N stores) |
#### Consolidation (offline)
Consolidation reads every stored memory, extracts the entities it mentions and rebuilds the entity graph from them. Two entities are linked when a memory mentions both, and the link's weight is the number of memories that do. Because the graph is rebuilt from what is currently stored, running consolidation again changes nothing, and entities that only a forgotten memory mentioned drop out. Relationships you assert yourself through the `relations` parameter of `store` are kept as they are.
> For the full step-by-step pipeline walkthrough, neuroscience mapping, and advanced configuration, see [docs/architecture.md](docs/architecture.md).
---
## CLI & MCP Tools
### CLI
```bash
myelin status # Health + integrity check
myelin stats # KPI dashboard: counts, types, age, Hebbian links
myelin serve # Start MCP server (stdio)
myelin decay # Prune stale memories
myelin consolidate # Replay episodes into semantic network
myelin export out.json # Export all memories to JSON
myelin import out.json # Import memories from JSON
myelin export-md ./exports/ # Export memories as Markdown files with YAML frontmatter
myelin import-md ./exports/ # Import memories from a directory of Markdown files
myelin obsidian-export ~/vaults/work # Export to an Obsidian vault (graph view)
myelin obsidian-import ~/vaults/work # Import from an Obsidian vault
myelin ingest ./docs/ # Bulk-load .txt/.md/.json files into memory
myelin debug-recall "your query" # Full pipeline breakdown for debugging
myelin graph # Launch browser admin dashboard (Graph | Overview | Memories)
```
`myelin stats` accepts `--project`, `--agent-id`, and `--json` flags for filtering and machine-readable output.
The `ingest` command bulk-loads content from files or directories:
```bash
myelin ingest ./docs/ # Recurse into directory
myelin ingest ./notes/arch.md # Single file
myelin ingest ./docs/ --project myapp --scope architecture
myelin ingest ./data/ --source wiki --no-recursive # Top-level only
```
Supported formats:
- **`.txt` / `.md`** — file body becomes one memory; YAML frontmatter between `---` delimiters is parsed for `project`, `scope`, `tags`, `memory_type`, `language`, `source` fields
- **`.json`** — list of objects in the same shape as `myelin export`; each must have a `"content"` key
The `export-md` / `import-md` commands round-trip memories as individual Markdown files with YAML frontmatter — useful for version-controlling memories in a git repo or editing them manually:
```bash
myelin export-md ./memory-backup/
# edit files...
myelin import-md ./memory-backup/
myelin import-md ./memory-backup/ --source restored
```
The `obsidian-export` command exports memories into an [Obsidian](https://obsidian.md) vault for graph-view visualisation. Each memory becomes a note with YAML frontmatter and `[[entity]]` wikilinks — Obsidian's graph view then clusters memories by shared entities, projects, and scopes:
```bash
myelin obsidian-export ~/vaults/work # export all memories
myelin obsidian-export ~/vaults/work --type semantic # decisions only
myelin obsidian-export ~/vaults/work --project myapp # one project
```
The resulting vault structure:
```
vault/
├── Memory Index.md
└── Memories/
├── semantic/ ← decisions, facts
├── episodic/ ← events, bug fixes
├── procedural/ ← preferences, how-tos
└── prospective/← plans, advice
```
To bring hand-edited or new notes back into myelin:
```bash
myelin obsidian-import ~/vaults/work
myelin obsidian-import ~/vaults/work --source obsidian
```
The `debug-recall` command runs a recall query and shows exactly what happened at each stage of the pipeline:
```
myelin debug-recall "what auth approach did we pick?" [-n N] [--project P] [--scope S] [--memory-type T] [--json]
```
Output includes:
- **Query plan** — what the PFC query planner inferred (memory type, scope, signals)
- **Amygdala gate** — whether the query would be accepted if stored
- **Results**, each with a headline and the list of ranking stages that touched it:
- `bi` — cosine similarity in the search that found the memory
- `ce` — the cross-encoder's raw score for the query and this memory
- `hebbian` — co-access weight accumulated from prior co-recalls
- `score` — the final score used for ranking
- one line per stage, in order, with the score that stage left behind. A number in brackets is what the stage measured (keyword overlap, the cross-encoder's score, co-access weight).
```
#1 score=1.0000 bi=0.6467 ce=8.6380 hebbian=0.000
5d0042934c0b… [search / — / episodic] access=2
Kai Tanaka owns the search indexing pipeline for Project Alpha
0.6467 embedding similarity
0.7632 shares topic keywords with the query [0.6000]
1.0000 cross-encoder blend [8.6380]
1.0000 kept from: the query as asked
1.0000 cross-encoder blend, merged candidates [8.6380]
```
The stages are recorded by the recall itself, so they show what happened in this run. A cross-encoder blend rescales every candidate's score to the range 0 to 1, which is why scores can drop at that step. With `--json`, each result carries the same list as `steps` (`stage`, `score`, `signal`).
> [!NOTE]
> If running from a dev checkout instead of an installed package, prefix with `uv run`: `uv run myelin status`
### MCP Tools
| Tool | Description |
|---|---|
| `store` | Encode a memory with context metadata (auto-classifies type, auto-chunks, 500K char limit). Pass `overwrite=true` to replace a near-duplicate instead of rejecting. Pass `agent_id` to store in an isolated namespace. |
| `recall` | Retrieve by semantic similarity (auto-inferred filters, multi-probe, [Hebbian boost](#post-recall), 10K char limit). Pass `agent_id` to also search that agent's namespace; without it only shared memories are returned. |
| `forget` | Remove a specific memory by ID |
| `pin_memory` | Pin a memory — always included in recall results |
| `unpin_memory` | Remove a pin |
| `decay_sweep` | Prune stale memories (access-based TTL) |
| `consolidate` | Replay episodes into the [semantic network](#consolidation-offline) |
| `status` | Memory system health check (counts, configuration) |
| `stats` | KPI dashboard: counts by type/project/scope/region, access health, age distribution, Hebbian links, decay candidates. Accepts `project` and `agent_id` filters. |
| `health` | Lightweight liveness probe (ok + version, no store initialization) |
| `ingest` | Bulk-load a file or directory into memory (`.txt`, `.md`, `.json`; supports YAML frontmatter metadata) |
### Data Storage
All data lives in `~/.myelin/` (configurable via `MYELIN_DATA_DIR`):
| File | Purpose |
|---|---|
| `chroma/` | Vector database (ChromaDB) — embeddings and metadata |
| `hebbian.db` | Co-access patterns between memories |
| `neocortex.db` | Semantic network — entities and relationships |
| `thalamus.db` | Pinned memories and recency tracking |
SQLite files use WAL mode for concurrent read performance. For more on inspecting these databases, see [docs/architecture.md](docs/architecture.md#inspecting-your-data).
### Secrets and personal data
Everything is stored locally, in plain text, in the data directory. Myelin does not send your memories anywhere; its only network access is downloading the two models from Hugging Face. But whatever is stored comes back in later recalls, and from there goes to whichever AI tool asked.
**Credentials are blanked out before a memory is stored.** Agents see terminals, `.env` files and pasted configuration, so sooner or later one tries to remember a token. The store replaces what it recognises with a placeholder and keeps the rest of the memory:
```
The release bot pushes tags with [REDACTED:github-token] from the CI runner
```
Recognised: private key blocks; GitHub, GitLab, Slack, AWS, OpenAI, Anthropic, Stripe, Google, Hugging Face, npm and PyPI tokens; JSON Web Tokens; `Authorization: Bearer` values; passwords inside URLs (`postgres://user:password@host`); and values labelled as secrets (`password=…`, `api_key: …`). The `store` response lists what was removed under `"redacted"`, never the value. Set `MYELIN_SECRET_SCAN` to `reject` to refuse such memories instead, or to `off` to store text as it is.
This catches common accidents. It is not a guarantee: an unusual token format or a password written in a sentence gets through. Still tell your agent not to store secrets ([Agent Instructions](#agent-instructions) does).
**Personal data is not filtered.** Remembering that "Kai owns the search pipeline" is the point of a memory, and names cannot be told from other words reliably. What may be stored about people is for you to decide, especially before sharing a data directory with a team. To remove something, `forget` it by id (`recall` shows ids), or search an export (`myelin export`) to find it.
Memories stored by a version without this check were not scanned.
---
## Configuration
All parameters use environment variables with a `MYELIN_` prefix. Defaults work out of the box — most users won't need to change anything.
### Common Parameters
| Parameter | Default | What It Controls |
|-----------|---------|-----------------|
| `data_dir` | `~/.myelin` | Where all data lives |
| `agent_id` | *(empty)* | Default namespace for `store`/`recall` tool calls that pass no `agent_id` (empty = shared) |
| `secret_scan` | `redact` | What `store` does with a credential in the content: `redact` blanks it out, `reject` refuses the memory, `off` stores it as it is. See [Secrets and personal data](#secrets-and-personal-data) |
| `default_n_results` | `5` | Results returned per recall |
| `max_memories` | `0` | Hard memory cap; 0 = unlimited. LRU eviction when exceeded |
| `consolidation_interval` | `50` | Auto-consolidate every N stores (0 = disabled) |
| `log_level` | `INFO` | Logging verbosity (structured JSON to stderr) |
### Storage Parameters
| Parameter | Default | What It Controls |
|-----------|---------|-----------------|
| `embedding_model` | `all-MiniLM-L6-v2` | Bi-encoder model (384-dim, 22M params) |
| `chunk_max_chars` | `1000` | Max characters per chunk |
| `chunk_overlap_chars` | `200` | Overlap between text chunks |
| `min_content_length` | `20` | Minimum chars to pass the input gate |
| `dedup_similarity_threshold` | `0.95` | Above this = near-duplicate, rejected |
### Recall Parameters
| Parameter | Default | What It Controls |
|-----------|---------|-----------------|
| `recall_over_factor` | `8` | Over-retrieval multiplier for re-ranking headroom |
| `multiprobe` | `true` | 3-probe retrieval (original + keywords + entity-expanded) |
| `neocortex_rerank` | `true` | Cross-encoder re-ranking |
| `neocortex_weight` | `0.6` | CE/bi-encoder blend (0.0–1.0) |
| `neocortex_min_spread` | `8.0` | When the cross-encoder's scores for the candidates differ by less than this, it has no real preference, and its say in the ranking shrinks in proportion (0 = always count it in full). Tuned for the default cross-encoder. |
| `cross_encoder_model` | `ms-marco-MiniLM-L-6-v2` | Cross-encoder model (22M params) |
| `lateral_k` | `1` | Max results per session/scope (0 = off) |
For advanced tuning parameters (boosting weights, spreading activation, maintenance thresholds), see [docs/architecture.md](docs/architecture.md#advanced-configuration).
---
### Optional: recognising people, organisations and places
The entity graph (`myelin graph`, and the related-entity boost in recall) is built without any extra models: capitalised or CamelCase identifiers and acronyms become `technology` entities, quoted terms become `concept`, and capitalised names such as "Kai Tanaka" or "Acme Corp" are kept but left untyped (`auto`).
To have names typed as `person`, `organization` or `location`, install the `ner` extra together with spaCy's small English model (about 12 MB):
```bash
uv tool install "myelin-mcp[ner]" \
--with "en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl"
# pip
pip install "myelin-mcp[ner]" && python -m spacy download en_core_web_sm
```
Then run `myelin consolidate` to re-type existing entities. The model is general-purpose, so expect some mistakes on technical text (it can label a product name as an organisation).
---
## Upgrading
```bash
# uv
uv tool upgrade myelin-mcp
# pip
pip install --upgrade myelin-mcp
```
Then run `myelin --version` and `myelin status` to verify. Your data directory is kept and, when a release needs it, migrated automatically (see [Data migrations](#data-migrations)). Upgrading Myelin also upgrades its dependencies to the newest versions it allows.
What changed in each release, including anything you need to do, is in the [changelog](CHANGELOG.md).
### Patch updates (the last number changes)
Bug fixes only. Upgrade and carry on.
### Major updates (the middle number while pre-1.0, the first after)
While Myelin is pre-1.0, the middle number is the major version: a `0.X.0` release may change behaviour or the data layout.
1. Read the **⚠ BREAKING CHANGES** entries in the [changelog](CHANGELOG.md) for every release you are skipping. Each one says what changed and what to do.
2. Back up your data directory (see [Backup](#backup)).
3. Upgrade, then run `myelin status`: `schema_version` should equal `schema_version_supported`.
### Data migrations
The data directory carries a schema version. When a release changes how memories are stored, it upgrades the directory automatically the first time it opens it and logs a `Migrated data to schema vN` line. Migrations are safe to interrupt and re-run, and safe when several server processes share one directory.
| Schema | Since | What the migration does |
|---|---|---|
| 2 | 0.4.0 | Marks memories stored without an `agent_id` as shared (`agent_id=""`). Metadata only — nothing is re-embedded. |
| 3 | 0.5.0 | Dates memories that have no `YYYY/MM/DD` tag by the day they were stored (`session_date`), so time-based recall ("3 days ago") and the recency boost apply to them. Metadata only. |
| 4 | 0.6.0 | Re-dates those memories by the local day they were stored instead of the UTC day, so "yesterday" means your yesterday. Uses the timezone of the machine that runs the upgrade. Metadata only. |
Downgrading is not supported once a directory has been migrated: an older release still opens it, but what it stores afterwards can be missing fields newer releases rely on. Restore your backup instead.
If a data directory was written by a newer release than the one running, Myelin logs a warning asking you to upgrade rather than modifying the data.
### Backup
Stop the server and copy the data directory (`~/.myelin` unless `MYELIN_DATA_DIR` is set). That copy is a complete backup: restore it by copying it back.
`myelin export backup.json` followed by `myelin import backup.json` is a portable alternative for moving memories between machines or into a fresh directory. It re-embeds the content and keeps project, scope, type, tags and `agent_id`, but not access counts, timestamps, pins or the entity graph.
### Embedding model changes
Myelin records the embedding model version in ChromaDB metadata. If a future release changes the default embedding model, existing vectors would need re-encoding to maintain recall quality. This has not happened yet — `all-MiniLM-L6-v2` has been the model since v0.1.0.
When a model change does ship, the release notes will include migration instructions. The safe path is always: `myelin export` → upgrade → `myelin import` (re-encodes all content with the new model).
---
## Contributing
Bug reports and feature requests are welcome in [GitHub Issues](https://github.com/et-do/myelin/issues).
To work on Myelin itself, start with [CONTRIBUTING.md](CONTRIBUTING.md). It covers the development environment (a Dev Container is included), branching and commit conventions, tests and quality checks, benchmarks, and how releases are made.
[`CLAUDE.md`](CLAUDE.md) and [`.github/copilot-instructions.md`](.github/copilot-instructions.md) in this repository are instructions for AI agents working on Myelin itself. To set up an agent in your own project, use the files in [`examples/`](examples/README.md) instead.
---
## Further Reading
- [Architecture & internals](docs/architecture.md) — pipeline walkthroughs, neuroscience mapping, data inspection, advanced configuration
- [Changelog](CHANGELOG.md) — release history
## License
MIT
TDQS
Scored across 11 tools
Most tools have clearly distinct purposes: store vs. ingest differ by single vs. bulk loading, recall is retrieval, forget is deletion, and pin/unpin are lifecycle controls. The main overlap is health vs. status, which both report system state, though their descriptions distinguish lightweight liveness from configuration and memory counts.
All names use snake_case, but the convention mixes single verbs (store, recall, forget), noun-like diagnostics (health, stats, status), and compound verbs (pin_memory, unpin_memory, decay_sweep). The pattern is readable but not a consistent verb_noun scheme throughout.
Eleven tools is well-scoped for a memory server, covering storage, retrieval, deletion, pinning, bulk ingest, maintenance, and diagnostics. Each tool appears to earn its place without excessive surface area.
The surface covers the core memory lifecycle: store, bulk ingest, recall, forget, pin/unpin, consolidation, decay, and status/stats. Minor gaps remain, notably no explicit update/edit-by-ID operation and no export tool despite ingest referencing myelin export output, but these are workaroundable.