Skip to main content
Glama

memem

Persistent, self-evolving memory for Claude Code. Stop re-explaining your project every session.

CI memem MCP server License: MIT Python 3.11+

For LLM/AI tool discovery, see llms.txt.

  ███╗   ███╗███████╗███╗   ███╗███████╗███╗   ███╗
  ████╗ ████║██╔════╝████╗ ████║██╔════╝████╗ ████║
  ██╔████╔██║█████╗  ██╔████╔██║█████╗  ██╔████╔██║
  ██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║
  ██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║
  ╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝
  persistent memory for Claude Code

What is memem?

memem is a Claude Code plugin that gives Claude persistent memory across sessions. A background miner extracts durable lessons (decisions, conventions, bug fixes, preferences) from your completed sessions, stores them as markdown in an Obsidian vault, and automatically surfaces relevant ones as an Active Memory Slice working state. An explicit narrative assembly path still exists, but the default runtime context is slice-first.

It's local-first: no cloud services, no API keys required, no vendor lock-in. Everything lives in ~/obsidian-brain/memem/memories/ as human-readable markdown.

What's new in v1.1

  • Layered memory becomes real end-to-end. Every memory now lives in one of four layers (L0/L1/L2/L3) at save time, not just at mining time. memory_save accepts an optional layer param (Claude can override) and auto-classifies otherwise. The slice engine pins L0 (project identity) on every prompt and gates L3 (rare archival) behind explicit search.

  • Slice as universal recall format. memory_search, memory_get, memory_timeline, memory_recall, and context_assemble all return slice-formatted output via a single render_slice_markdown dispatcher. context_assemble composes via active_memory_slice rather than rolling its own briefing.

What's new in v1.0 (miner hardening)

A 16-module refactor closed the entire spawn-storm class of bugs that had previously taken down hosts. The miner now uses start_new_session=True + os.killpg for process-group cleanup on timeout, an inverted TransientError/PermanentError taxonomy with PermanentError as default, persisted attempt counters with DLQ at MAX_FAILURES, a SIGTERM-drained graceful shutdown, SQLite WAL state storage, a hand-rolled circuit breaker, structured JSON logs with RotatingFileHandler, and a 5-in-60s wrapper crash guard.

Related MCP server: Central Brain

When should I use memem?

Use memem if:

  • You use Claude Code daily and keep re-explaining your project to every new session

  • You want durable memory you can browse and edit as markdown

  • You like local-first tools with zero vendor lock-in

  • You already use Obsidian (memem plugs straight into your vault)

How is memem different from CLAUDE.md?

CLAUDE.md is a single hand-edited file per project. memem gives you:

  • Automatic extraction — no manual note-taking, the miner captures lessons from every completed session

  • Query-aware context — only the memories relevant to your current question get injected, not a static dump

  • Self-evolving — memories merge, update, and deprecate automatically as your project evolves

  • Cross-project — works across every Claude Code project you use, not scoped to one repo

  • Security scanning — every write is scanned for prompt injection and credential exfiltration

  • Browsable — Obsidian vault with graph view and backlinks for free

Architecture — slice-first runtime

memem uses layered recall plus a slice-first runtime kernel inspired by claude-mem and mem0. Instead of treating memory as one big briefing, it first turns recall results into an explicit working state:

   Session start / user prompt
   ┌─────────────────────────────┐
   │ Candidate generation        │
   │   • memories / graph        │
   │   • playbooks               │
   │   • runtime environment     │
   │   • current artifacts       │
   └──────────┬──────────────────┘
              │
              ▼
   ┌─────────────────────────────┐
   │ Activation judgement        │
   │   • goals                   │
   │   • constraints             │
   │   • decisions / failures    │
   │   • artifacts / tensions    │
   └─────────────────────────────┘
              │
              ▼
   ┌─────────────────────────────┐
   │ Active Memory Slice         │ → rendered markdown working state
   │ generate_prompt_context()   │    used by hooks, MCP, and CLI
   └─────────────────────────────┘

The lower-level recall tools still exist for explicit drilling:

  1. memory_search(query) -> compact index

  2. memory_get(ids=[...]) -> full content

  3. memory_timeline(id) -> chronological thread

  4. context_assemble(query, project) -> optional secondary narrative briefing

Memory layers (auto-classified at save AND mining time; Claude can override):

Layer

Purpose

Slice behavior

L0

Project identity — tech stack, repo structure, core conventions

Always pinned in every active slice for that project (anchor score 0.95)

L1

Generic conventions — testing, style, commit patterns

Ranked + scored alongside L2

L2

Domain-specific — most memories (default)

Ranked + scored (default search hits)

L3

Rare/archival — niche failure modes, one-off lessons

Excluded from auto-recall; only via explicit memory_search/memory_get

A heuristic (mining.py:classify_layer) assigns layers based on importance, structural tags, content length, and the per-project L0 cap. memory_save(content, ..., layer=N) accepts an explicit override (0-3) when Claude judges better than the heuristic.

Token efficiency: session start injects L0 verbatim plus a compact index for L1-L2 (~50 tokens per entry: ID + L + title + snippet). Claude drills into specific memories via memory_get(ids=[...]) only when it needs full detail.

Active Memory Slice runtime kernel:

For ongoing work, active_memory_slice(query, scope_id, ...) is the default runtime path. It uses memory_search/FTS/graph/playbooks/transcripts plus runtime environment and current artifacts as candidate generation, then activates a structured working state:

Memory Vault
→ Candidate Generation
→ Activation Judgement
→ Active Memory Slice
→ Delta Proposals
→ Memory Vault

The slice explicitly separates goals, constraints, background, decisions, preferences, failure patterns, artifacts, open tensions, and candidate deltas. If you pass session_id together with runtime context such as task_mode and repo_path, memem also carries forward continuity across slices and records slice history under ~/.memem/.

Default runtime behavior is still non-mutating. Delta proposals are validated and surfaced in the slice, but safe writeback only runs when you opt in via writeback_preview=True or auto_commit_safe=True.

Opt-in features:

  • MEMEM_SHOW_BANNER=1 — show a one-line status banner at session start (off by default)

  • MEMEM_PRETOOL_GATING=1 — enrich Read tool calls with memories about the target file (off by default)

  • MEMEM_TOPIC_SHIFT_THRESHOLD=0.3 — keyword overlap threshold for topic-shift re-firing (default 0.3)

How do I install memem?

Copy-paste:

claude plugin marketplace add TT-Wang/memem
claude plugin install memem@memem-marketplace

If you already added the marketplace once, future installs only need the second command.

Then:

  1. restart Claude Code if it was already open

  2. open any project

  3. send your first normal message

  4. memem will show a welcome/status message and offer the mining options

That's it. On first run, bootstrap.sh self-heals everything:

  1. Verifies Python ≥ 3.11 — or installs it via uv python install 3.11 if your system Python is too old

  2. Installs uv if missing (via the official Astral installer)

  3. Syncs deps into a plugin-local .venv (hash-cached against uv.lock)

  4. Creates and canary-tests ~/.memem/ and ~/obsidian-brain/

  5. Writes ~/.memem/.capabilities (used for degraded-mode decisions)

  6. Execs the real MCP server

First run: ~5 seconds. Every run after: ~100ms. No separate pip install step.

Nothing mines until you opt in. memem is strictly opt-in as of v0.9.0 — install does not start the miner or touch your sessions. Type /memem to see status and choose what to do next. You can start mining two ways:

  • /memem-mine — mine new sessions only (from now on)

  • /memem-mine-history — mine everything, including past history (uses Haiku API credits)

Or just tell Claude "start mining new sessions" / "start mining everything including history" — it knows what to do.

  • choose /memem-mine if you only want memory from new sessions going forward

  • choose /memem-mine-history if you want memem to process your old Claude Code sessions too

If you are unsure, start with /memem-mine. It is the safer and cheaper default.

What happens on my first Claude Code session?

At session start, the SessionStart hook tries to prime a slice-first working state for the current project scope. On each user prompt, the UserPromptSubmit hook regenerates the slice for the current query. If you just installed memem and have no relevant context yet, the hooks stay quiet and Claude proceeds normally.

You work normally. The miner daemon runs silently in the background. When your session ends and settles for 5 minutes, the miner extracts memories from the transcript using Claude Haiku and writes them to your vault.

During the session: every user prompt goes through active_memory_slice, which builds a structured working-state briefing from the relevant memories, playbooks, transcripts, graph neighbors, environment facts, and current artifacts. The hooks automatically pass session id and working directory, and the prompt hook infers a task mode when the host does not provide one, so ongoing work can carry constraints, artifacts, and tensions forward across slices. You see an active slice prompt with goals, constraints, background, decisions, failure patterns, open tensions, and artifacts. Claude starts with the current working state instead of a generic briefing.

30-Second Setup

claude plugin marketplace add TT-Wang/memem
claude plugin install memem@memem-marketplace

Then in Claude Code:

/memem

And choose one:

/memem-mine

or

/memem-mine-history

What does memem save?

It saves durable knowledge, not session logs:

  • Architecture decisions with rationale ("we use RS256 JWTs because HS256 can't be verified by third parties without sharing the secret")

  • Conventions ("tests go in tests/ not spec/", "commit messages use imperative mood", "never import from internal/ outside its package")

  • Bug fixes you might forget ("bcrypt.compare is async — must await", "timezone math must use dayjs.utc() or DST shifts the result by an hour")

  • User preferences ("prefer single commits, not stacked PRs", "terse responses — no trailing summaries", "ask before running migrations in prod")

  • Known issues & workarounds ("JWT_SECRET defaults to 'secret' if unset — tracked in #123", "pnpm install hangs on corporate VPN, use --network-timeout=600000")

  • Environment & tooling facts ("project uses Poetry, not pip", "CI runs on Node 20 but local defaults to 22 — pin with nvm use", "Redis must be running on :6380 not :6379")

  • Project structure & invariants ("auth middleware requires Redis", "all DB writes go through repo/ layer, never raw SQL in handlers")

  • Failure patterns & post-mortems ("mocking the DB hid a broken migration last quarter — integration tests must hit a real DB", "don't ship on Fridays after the 2025-11 rollback incident")

  • Third-party quirks ("Stripe webhooks retry for 3 days — idempotency key is mandatory", "OpenAI streaming drops the final token if client closes early")

  • Domain knowledge ("a 'merchant' in our schema is what the legal team calls a 'counterparty'", "revenue is recognized at ship time, not order time")

It does NOT save:

  • Raw session transcripts (those are searchable via transcript_search, not stored as memories)

  • Trivial or obvious facts

  • Session outcomes ("today I worked on X")

Where does memem store my memories?

Store

Path

Purpose

Memories

~/obsidian-brain/memem/memories/*.md

Source of truth (human-readable markdown)

Playbooks

~/obsidian-brain/memem/playbooks/*.md

Per-project curated briefings

Search DB

~/.memem/search.db

SQLite FTS5 index (machine-fast lookup)

Graph DB

~/.memem/graph.db

Rebuildable typed/scored memory-edge index

Telemetry

~/.memem/telemetry.json

Access tracking (atomic writes)

Event log

~/.memem/events.jsonl

Append-only audit trail

Capabilities

~/.memem/.capabilities

Degraded-mode flags written by bootstrap

Bootstrap log

~/.memem/bootstrap.log

First-run diagnostics

You can point memem elsewhere via MEMEM_DIR and MEMEM_OBSIDIAN_VAULT env vars.

What are the MCP tools Claude can call?

All recall tools return slice-formatted markdown via a unified render_slice_markdown dispatcher (introduced in v1.1) so output structure is consistent across tools.

Tool

What it does

memory_save(content, title, tags, layer?)

Store a lesson. Security-scanned for prompt injection and credential exfil before writing. layer is optional (0-3); auto-classifies via classify_layer if omitted.

memory_search(query, limit, scope_id)

[L1] Compact index slice — IDs + layer + title + 1-line snippet. Use first to narrow candidates.

memory_get(ids, scope_id)

[L2] Full content slice for specific memory IDs. Use after memory_search.

memory_timeline(memory_id, scope_id)

[L3] Chronological thread via related[] graph + same-project window.

memory_recall(query, scope_id, limit)

Legacy alias — search + full content in one slice.

memory_list(scope_id)

List all memories with stats, grouped by project.

memory_import(source_path)

Bulk import from files, directories, or chat exports.

transcript_search(query)

Search raw Claude Code session JSONL logs (not the mined memories).

context_assemble(query, project)

Composite briefing: calls active_memory_slice 1-2 times (project + general scope when sparse), merges into one assembled slice.

memory_graph(memory_id)

Inspect typed/scored graph neighbors for one memory.

memory_graph_audit()

Report graph quality issues: orphans, dead links, hubs, stale edges.

memory_graph_rebuild(scope_id)

Rebuild the graph side index from the Obsidian vault.

active_memory_slice(query, scope_id, session_id?, task_mode?, repo_path?, writeback_preview?, auto_commit_safe?)

Build a structured runtime working state for current work, with optional continuity and controlled writeback.

How do I inspect slices or writeback manually?

Use the CLI when you want raw slice JSON, continuity debugging, or explicit writeback preview:

python3 -m memem.server slice "continue auth rollout" --scope memem --session-id sess-42 --cwd "$PWD" --task-mode coding --json --no-llm
python3 -m memem.server slice "continue auth rollout" --scope memem --session-id sess-42 --cwd "$PWD" --task-mode coding --writeback-preview --json --no-llm
python3 -m memem.server slice "continue auth rollout" --scope memem --session-id sess-42 --cwd "$PWD" --task-mode coding --auto-commit-safe --json --no-llm

Semantics:

  • default slice is read-side and non-mutating

  • --writeback-preview runs the delta pipeline in dry-run mode

  • --auto-commit-safe commits only deltas classified as auto-safe

What slash commands does memem add?

  • /memem — welcome, status, help

  • /memem-status — memory count, projects, search DB size, miner health

  • /memem-doctor — preflight health check with fix instructions for any blocker

  • /memem-mine — start the miner daemon manually (normally auto-starts)

  • /memem-mine-history — opt-in: mine all your pre-install Claude Code sessions

What if the claude CLI isn't on my PATH?

memem enters degraded mode — it still works, just without Haiku-powered context assembly and smart recall. You get FTS-only keyword recall instead of query-tailored briefings. Every session shows [memem] N memories · miner OK · assembly degraded (claude CLI missing — FTS-only recall) at the top of the context, so you know why.

This is by design: missing optional dependencies should degrade, not fail.

How do I diagnose problems?

Run /memem-doctor. It runs the same preflight the bootstrap shim runs (Python version, mcp importable, claude CLI on PATH, directory writability, uv available), then prints a report labelled HEALTHY, DEGRADED, or FAILING with explicit fix instructions for each blocker.

For deeper debugging:

tail -f ~/.memem/bootstrap.log   # first-run shim log
tail -f ~/.memem/miner.log       # miner daemon log
cat ~/.memem/events.jsonl        # memory operation audit trail
python3 -m memem.server --status   # detailed status dump

How does the mining pipeline work?

Session ends → miner daemon sees the JSONL file in ~/.claude/projects/
  → Waits 5 minutes for the file to "settle" (no more writes)
  → Filters to human messages + assistant prose (strips tool calls, system reminders)
  → One Haiku call with the full context: "extract durable lessons"
  → Haiku returns JSON array of memory candidates
  → Each candidate runs: security scan → dedup check → contradiction detection → save
  → Index rebuilt, per-project playbooks grown and refined
  → Session marked COMPLETE in ~/.memem/.mined_sessions

How does the recall pipeline work?

First message in a new session → auto-recall.sh hook fires
  → Reads ~/.memem/.capabilities for status banner
  → Builds an active memory slice from recall candidates + graph/playbook/transcript context
  → Emits a structured "Active Memory Slice" prompt block
  → If the slice engine is unavailable → falls back to compact recall
  → Either way, Claude starts its reply with active work-state context already loaded

Architecture

memem is split into small, focused modules:

  • models.py — data types, path constants

  • security.py — prompt injection + credential exfil scanning

  • telemetry.py — access tracking, event log (atomic writes, fcntl-locked)

  • search_index.py — SQLite FTS5 index

  • graph_index.py — typed/scored related-memory graph side index

  • active_slice.py — MemoryItem + ActiveMemorySlice schemas, render_slice_markdown dispatcher

  • activation.py — heuristic + bounded LLM activation judgement

  • boundaries.py — scope/deprecated/budget/redundancy filters

  • delta.py — non-mutating candidate delta proposals

  • active_slice_engine.py — candidate generation, layer-aware (L0 anchors + L3 gating), build_slice public entry

  • obsidian_store.py — memory I/O, dedup scoring, contradiction detection, layer auto-classification on save

  • recall.py — slice-format recall tools (memory_search/memory_get/memory_timeline/memory_recall)

  • playbook.py — per-project playbook grow + refine

  • assembly.py — context_assemble composes via active_memory_slice

  • capabilities.py — runtime feature detection for degraded mode

  • storage.py — server-lifecycle helpers (PID management, miner auto-start)

  • server.py — thin MCP entrypoint (FastMCP imported lazily)

  • cli.py — command dispatcher for non-MCP entrypoints

  • mining.py — session mining pipeline (Haiku extraction)

  • miner_daemon.py — long-running daemon with structlog JSON output, semaphore concurrency cap, heartbeat

  • miner_protocol.py — exit codes (FATAL=75 / TRANSIENT=20) and status constants

  • miner_errors.py — TransientError / PermanentError taxonomy (PermanentError default)

  • miner_circuit_breaker.py — hand-rolled CB; opens after 5 consecutive PermanentErrors, 5min cooldown

  • session_state.py / session_state_db.py — SQLite WAL state for the miner (auto-migrates from JSONL on first run)

Multi-signal recall scoring:

  • 50% FTS relevance

  • 15% recency (0.995^hours decay)

  • 15% access history (usage reinforcement)

  • 20% importance (1-5 scale from Haiku)

Related-memory graph:

The Obsidian markdown files remain the source of truth. The related: [...] frontmatter stays intentionally simple so memories are portable and readable. memem also builds ~/.memem/graph.db, a local SQLite side index with typed, scored edges such as same_topic, supports, depends_on, supersedes, and contradicts. Recall uses this graph when available and falls back to the Markdown related field if the graph has not been built yet.

Useful maintenance commands:

memem graph rebuild
memem graph audit
memem graph stats
memem graph neighbors <memory-id>

Memory schema (markdown frontmatter):

---
id: uuid
schema_version: 1
title: "descriptive title"
project: project-name
tags: [mined, project-name]
related: [id1, id2, id3]
created: 2026-04-13
updated: 2026-04-13
source_type: mined | user | import
source_session: abc12345
importance: 1-5
status: active | deprecated
valid_to:                     # set when deprecated
contradicts: [id1]            # flagged conflicts
---

Configuration

Env var

Default

Purpose

MEMEM_DIR

~/.memem

State directory (PID files, search DB, logs)

MEMEM_OBSIDIAN_VAULT

~/obsidian-brain

Vault location

MEMEM_EXTRA_SESSION_DIRS

(none)

Colon-separated extra session dirs to mine

MEMEM_MINER_SETTLE_SECONDS

300

Seconds to wait before mining a completed session

MEMEM_SKIP_SYNC

0

Bootstrap skips uv sync when set to 1 (dev only)

memem works without Obsidian — it just writes markdown. But Obsidian gives you graph view and backlinks for free:

  1. Download: https://obsidian.md (free)

  2. Open ~/obsidian-brain as a vault

  3. Memories appear in memem/memories/, playbooks in memem/playbooks/

  4. Use Graph View to see how memories link via the related field

Requirements

  • Claude Code

  • Python ≥ 3.11

  • uv (auto-installed by bootstrap.sh on first run)

  • claude CLI on PATH (optional — required for Haiku-powered assembly; degraded mode works without it)

Development

git clone https://github.com/TT-Wang/memem.git
cd memem
pip install -e ".[dev]"
pytest             # 428 tests
ruff check .       # lint
mypy memem         # type check

See CONTRIBUTING.md for the PR process and CHANGELOG.md for version history.

Works great with

  • forge — Structured planning, parallel execution, and deep validation for Claude Code. memem + forge is the recommended pairing: forge plans and executes multi-file changes, memem remembers what worked across runs. Forge's memory_save patterns land in memem's recall index, so next week's run starts with last week's lessons already loaded.

License

MIT

Available Tools

6 tools
context_assembleA

Assemble a query-tailored context briefing from all available knowledge.

This is the highest-value Cortex tool. It gathers the relevant subset of memories, the project's playbook, and related session transcripts, then uses Claude Haiku to synthesise a focused markdown briefing for the given query. The result is a ready-to-read summary, NOT a raw memory dump — usually 300-800 tokens of distilled relevant knowledge.

Behaviour:

  • Read-only with respect to the Cortex memory store. Bumps access telemetry on memories it reads (same as memory_recall).

  • No authentication required by Cortex itself. The optional Haiku synthesis step shells out to the local claude CLI, which may use Claude Code credentials the user already has signed in — Cortex does not handle those credentials directly.

  • Rate limits: depend on the claude CLI backend in the healthy path. In degraded mode (claude CLI missing), there are no rate limits at all — Cortex just returns raw materials.

  • Data access scope: reads ~/obsidian-brain/cortex/memories/, ~/obsidian-brain/cortex/playbooks/.md, ~/.cortex/search.db, and ~/.claude/projects/ transcripts. If the claude CLI is invoked, the gathered materials (up to 50KB) are sent to Haiku via that subprocess — which in turn sends them to Anthropic's API under the user's existing Claude Code session. In degraded mode nothing leaves the machine.

  • Latency: 3-15 seconds with Haiku; <500ms in degraded mode.

  • Not idempotent at the Haiku level: the same query can produce slightly different briefings across calls due to Haiku sampling. The underlying memory retrieval step IS deterministic.

  • Failure modes: returns "" on genuinely empty vaults. Never raises to the caller; Haiku failures silently fall back to returning the raw materials.

Use context_assemble when:

  • Starting a new session and you want the assistant loaded with context before the first real question (the auto-recall hook does this on UserPromptSubmit, but you can also call it manually)

  • Onboarding to a project mid-session — ask "what do I know about X?"

  • Before making a decision in an area where prior decisions exist

Do NOT use for:

  • Simple keyword lookups (use memory_recall — faster, no LLM call)

  • Listing memories (use memory_list)

  • Finding a specific past conversation (use transcript_search)

Degraded mode: if the claude CLI is not available on the host, this tool falls back to returning the raw materials (playbook + ranked memories) without Haiku synthesis, so it always returns SOMETHING useful.

Returns: A markdown briefing tailored to the query. Length is typically 300-800 tokens, with headers, bullet lists, and cross-references to memory IDs where relevant.

Example: context_assemble( query="help me fix the auth flow on staging", project="my-webapp", ) → returns a brief covering: the RS256 JWT decision, the known bcrypt.compare gotcha, a link to the staging-specific env var issue from last month, etc.

Inputs: query (required), project. Returns: result

memory_importA

Bulk-import memories from a file, directory, or chat export.

Use this to seed Cortex with existing notes, CLAUDE.md content, documentation excerpts, or chat logs you want to make searchable. Each imported item runs through the same security scan and deduplication as memory_save, so clean imports even from messy sources.

Behaviour:

  • MUTATION. Writes one or more memory markdown files, updates FTS5 index, _index.md, and events.jsonl. Same atomic + fcntl-locked write path as memory_save.

  • No authentication required.

  • No rate limits, but latency scales with source size — importing a 100-item directory can take several seconds.

  • Data access scope: reads the supplied source_path from the local filesystem. Guarded against path traversal: the resolved path must be inside $HOME; anything outside is rejected. Nothing is sent over the network.

  • Not idempotent: re-importing the same source triggers the dedup check, which rejects duplicates with a summary count.

  • Failure modes: invalid or non-existent source paths return a string error. Individual rejected items are counted in the summary and do not abort the whole import.

Use memory_import for:

  • Initial bootstrap from an existing CLAUDE.md or notes folder

  • Absorbing a team-wide decision log into a project scope

  • One-off batch captures from a conversation export

Do NOT use for:

  • Incremental per-conversation saves (use memory_save for single items)

  • Mining Claude Code session logs (the background miner handles that automatically; no manual import needed)

Returns: A summary like "Imported 12 memories from 18 candidates (rejected 6 duplicates)". Errors are returned as human-readable messages.

Example: memory_import( source_path="/home/alice/notes/team-decisions.md", scope_id="my-webapp", )

Inputs: source_path (required), scope_id. Returns: result

memory_listA

List every memory in a scope, with counts and source breakdown.

Use this when you want to see the full inventory of what Cortex has stored — e.g. to audit which projects have the most memories, to check if a specific memory you wrote earlier is still present, or to find a memory whose exact title you remember but whose keywords are ambiguous.

Behaviour:

  • Read-only. No mutations at all, not even telemetry bumps.

  • No authentication required.

  • No rate limits. Latency scales linearly with memory count; typical sub-second on corpora up to ~10k.

  • Data access scope: reads ~/obsidian-brain/cortex/memories/ markdown files via filesystem glob. Nothing leaves the machine.

  • Idempotent and deterministic for a given filesystem state.

  • Failure modes: returns "No memories in scope: " for an empty scope. Never raises.

Use memory_list when:

  • You want to see everything, not a ranked subset

  • You need to audit the current memory inventory

  • You're about to run a cleanup/purge operation and want a preflight

  • You suspect memory_recall is missing something and want to confirm

Do NOT use for:

  • Searching for specific content (use memory_recall — faster, ranked)

  • Assembling a context briefing (use context_assemble)

Returns: A markdown listing with the total memory count, source type breakdown (mined/user/import), and one line per memory showing its short ID, title, and project. Memories are sorted newest-first by creation date.

Example output: 47 memories Sources: mined:32, user:12, import:3

- [63d6570e] JWT algorithm — RS256 only in prod | project:my-webapp
- [a8b12c44] Pytest fixtures must use tmp_path | project:default
- ...

Inputs: scope_id. Returns: result

memory_recallA

Search Cortex memories for durable knowledge relevant to a query.

Use this when you need to recall prior decisions, conventions, bug fixes, user preferences, or lessons learned from past Claude Code sessions. It searches the full Obsidian-backed memory store via SQLite FTS5, ranks results with a multi-signal scorer (relevance + recency + usage + importance), and expands related-memory links.

Behaviour:

  • Read-only. Does not modify any memory, index, or sidecar file. Only side effect is a bump to the access-count telemetry sidecar (~/.cortex/telemetry.json), which influences future ranking.

  • No authentication required. Cortex is local-first; there are no credentials, tokens, or API keys.

  • No rate limits. Typical latency is under 100ms on corpora up to ~10k memories; pathological queries can take up to ~500ms.

  • Data access scope: reads from ~/obsidian-brain/cortex/memories/ and ~/.cortex/search.db. Nothing leaves the local machine.

  • Idempotent: calling twice with the same query returns the same results (modulo the access-count telemetry bump).

  • Failure modes: returns "No memories found for: " on empty result sets. Never raises to the caller; internal errors fall back to a slower file-scan path.

Use memory_recall when:

  • You need specific facts ("what auth library did we pick?")

  • You want to check if a topic has prior context before making a decision

  • You're debugging and want to find if this bug was fixed before

Do NOT use for:

  • Session-level what-I-did-today logs (use transcript_search instead)

  • On-demand query-tailored briefings (use context_assemble instead)

  • Listing every memory (use memory_list instead)

Returns: Markdown-formatted memory entries, grouped under a "### Memories" header. Each entry has the memory title and body excerpt. If no matches are found, returns "No memories found for: ".

Example: memory_recall(query="jwt auth algorithm", limit=5) → returns the top 5 memories mentioning JWT auth, such as a memory documenting the decision to use RS256 in production.

Inputs: query (required), limit, scope_id. Returns: result

memory_saveA

Save a durable lesson, decision, or convention to persistent memory.

Use this to capture knowledge that should survive across Claude Code sessions: user preferences, architecture decisions with rationale, environment quirks, non-obvious bug fixes, or anything you'd otherwise have to re-explain in the next session.

Behaviour:

  • MUTATION. Writes a new markdown file under /obsidian-brain/cortex/memories/, appends to the FTS5 index (/.cortex/search.db), updates ~/obsidian-brain/cortex/_index.md, and writes an append-only entry to ~/.cortex/events.jsonl. Writes are atomic (tmp + fsync + os.replace) and fcntl-locked.

  • No authentication required. Local-first; no credentials.

  • No rate limits. Typical latency 50-200ms including the security scan, dedup check, and write sync.

  • Data access scope: writes stay entirely on the local filesystem. Nothing is sent over the network.

  • Not idempotent: calling twice with identical content triggers the dedup check and the second call returns a "Memory already exists" error instead of a duplicate write.

  • Failure modes: rejected inputs return a string error ("Memory already exists", "Memory rejected: "); they never raise to the caller.

Every save goes through:

  1. Prompt-injection + credential-exfil security scan (rejects matches)

  2. Fuzzy deduplication against existing memories (word+bigram+trigram overlap — rejects near-duplicates with clear reason)

  3. Automatic related-memory linking (adds related frontmatter field)

  4. Write to Obsidian markdown file + FTS5 index + _index.md

Use memory_save for:

  • "We decided to use X because Y" (decision + rationale)

  • "User prefers small focused PRs, not big bundled ones" (preference)

  • "Database connection pool must be at least 20 for prod" (invariant)

  • "bcrypt.compare is async — always await" (gotcha)

Do NOT use for:

  • "Today I worked on X" (session logs — use transcript_search to find those)

  • Trivial facts easily re-discovered from reading code

  • Speculative or unverified claims

  • Duplicates of existing memories (the dedup check will reject them anyway)

Returns: A confirmation like "Memory saved: 63d6570e... 'JWT auth uses RS256'" on success, or an error message (starting with "Memory already exists" or "Memory rejected") on failure.

Example: memory_save( content="Use RS256 (not HS256) for JWT in production. HS256 " "requires sharing the signing secret across services " "which leaked via an env var export last quarter (#1247).", title="JWT algorithm — RS256 only in prod", tags="auth,jwt,security,postmortem", scope_id="my-webapp", )

Inputs: content (required), tags, title, scope_id. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.9/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a distinct purpose: context_assemble synthesizes briefings, memory_import bulk-imports, memory_list lists, memory_recall searches, memory_save saves, and transcript_search searches transcripts. They are clearly differentiated with no overlap.

    Naming Consistency5/5

    All tool names follow a consistent pattern: [domain]_[action] using snake_case (e.g., memory_save, memory_recall, context_assemble). The naming is predictable and uniform.

    Tool Count5/5

    With 6 tools, the server covers core functionalities (save, search, list, import, context assembly, transcript search) without being excessive or minimal. The scope is well-balanced.

    Completeness4/5

    The tool set covers creation, search, listing, and import, but lacks explicit update or delete operations for memories. While this may be intentional, it's a minor gap that could cause agent limitations.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Persistent memory for Claude Code — a self-evolving knowledge layer that survives across sessions, grows from every conversation, and surfaces relevant context automatically.
      14
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Persistent memory + intelligent context for Claude Code. Save and reuse solutions, decisions, and patterns across projects.
      43
      7
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Gives Claude Code persistent cross-session memory with semantic search over facts, decisions, and lessons, plus automatic tracking of user corrections and behavioral patterns. Enables a Claude that evolves reusable frameworks over time — promoting what works and retiring what doesn't — all locally through MCP tools and hooks.
      6 npm
      MIT