Skip to main content
Glama

memory-mcp

A local MCP server that manages an agent's long-term memory. Memory is treated not as something to "store and retrieve" but as a lifecycle in which it is born, recalled, amended, judged, and sinks.

Core idea

An agent's memories are of two kinds. Memories with ground truth (such as code indexes) can rely on hash synchronization, but assertion memories without ground truth — user utterances, decisions, and lessons — need state, version, confidence, and a verdict gate. memory-mcp combines the two with a dual structure:

  • source — human-readable markdown files managed with git (<store>/memories/*.md, frontmatter metadata). Lifecycle state, supersede chains, and confidence live here.

  • derivatives — a SQLite index (FTS, ranking, conflict ledger). It can be discarded at any time and rebuilt entirely from the source with a single memory_reindex call.

Designed by analyzing three sources (evidence trails in §12 of docs/design/architecture.md):

Source

What was adopted

codebase-memory-mcp hands-on analysis

source–derivative separation, stat-gate → hash → partial reindexing, coverage honesty, store = directory isolation

Codebase-Memory paper (arXiv:2603.27277)

token economy (return path and excerpt only), confidence attached to derived links, path containment

MemOS paper (arXiv:2507.03724)

state machine + archived staging layer, non-destructive supersede version chain, trust × state × heat ranking

AX workspace memory lifecycle policy

verdict gate (no automatic overwrite), pair-hash idempotency, latest-wins signal, distillation-first compaction, entity dictionary

Related MCP server: AI-MemoryHub MCP Server

How it works

remember ──► active ◄─────────── 본문 수정 시 자동 복귀
               │ supersede 되면 자동
               ▼
            archived ──forget(deprecate, reason 필수)──► deprecated
               │                                            │
               └────────── forget(purge, confirm 필수) ──────┘
                            (파일 삭제 — git 이력이 백스톱)
  • Conflict gate: when memory_remember detects neighboring memories, it returns the verdict material (shared entity, time gap, latest_wins_eligible) in the response. The verdict belongs to the calling agent (and the user) — no automatic overwrite without a verdict. Surfaced pairs are recorded by pair-hash so they are not presented again.

  • Weathering: old, unused memories are not deleted but sink in the ranking — score = text × trust × state × (1 + freshness + heat). When memory_status proposes aging episodes as compaction candidates, the agent summarizes them into a knowledge memory and supersedes the originals.

  • reconcile: no daemon. At the entry of every tool invocation, a stat-gate (mtime + size) → sha256 → only the changed parts are reindexed. Manually edited files also converge on the next invocation. If the body of an archived memory is edited directly, it automatically returns to active (latest intent wins).

  • Korean search: without embeddings, a query planner combines word FTS (prefixes absorb postpositional variants) + trigram FTS (phrases) + a LIKE fallback for unterminated 2-char or smaller queries. So "보안을 끄는" ↔ "보안을 끄고" match.

  • Honesty: recall/status always report index freshness, unparseable files, and unresolved conflicts. A lack of report ≠ completeness.

Tools (7)

Tool

Role

memory_remember

Create a memory (with supersedes). Duplicates are idempotent, conflicts are returned as verdict material.

memory_recall

Hybrid search — path, pay-TM*, and score components only (no body injection).

memory_read

Full text by id/path, supersede chain, conflict history.

memory_index

edit / supersede / set_state / link / resolve_conflict.

memory_forget

archive / deprecate (reason required) / purge (confirmation required). No automatic deletion.

memory_status

aggregates, unresolved conflicts, reviews due, compaction candidates, unparseable files, index freshness.

memory_reindex

full derivative rebuild (disaster recovery) / conditional re-hash audit of everything.

Installation

Node ≥ 22.5 (node:sqlite built-in — no external native dependencies).

pnpm install && pnpm build

Register via Claude Code:

claude mcp add memory-mcp -- node /path/to/memory-mcp/dist/main.js

Or via .mcp.json:

{
  "mcpServers": {
    "memory-mcp": {
      "type": "stdio",
      "command": "node",
      "args": ["/path/to/memory-mcp/dist/main.js"],
      "env": { "MEMORY_MCP_ROOT": "/path/to/your/store" }
    }
  }
}

The default store is ~/.memory-mcp/default (replace with the MEMORY_MCP_ROOT env var, or per-store invocation). If you manage the store in git, the git history becomes the backstop for purge.

Memory file format

---
id: 01JD2K3A9FZQ4W8XVBH5T6N7RM
type: fact | preference | decision | episode | reference | knowledge
state: active | archived | deprecated
trust: user-stated | agent-inferred | imported
entities: [ads-genisys, pacing]
source: "2026-08-24 세션, 사용자 교정"
created: 2026-08-24T14:03:00Z
updated: 2026-08-24T14:03:00Z
review_after: 2026-11-01
---
# 제목 한 줄

본문. 첫 문단이 recall 발췌로 쓰인다.

Adding a <store>/dictionary.md normalizes entity notation (- 정식명: 설명 (aka: 동의어, 약어)).

Development

pnpm typecheck   # tsc --noEmit
pnpm test        # node --test (29 tests)
pnpm lint        # biome
pnpm build       # dist/

Documentation

License

MIT

Available Tools

7 tools
memory_forgetForget (state transition, never silent deletion)A

archive: sink from default recall (recoverable). deprecate: judged wrong — requires a reason, preserved for opt-in reads. purge: delete the file — only from archived/deprecated and only with confirm=true; if the store is a git repo, history is the backstop.

Inputs: id (required), mode, store, reason, +1 more.

memory_readRead memoryB

Full content plus provenance: frontmatter, supersede chain in both directions, conflicts, usage.

Inputs: id, path, store.

memory_recallRecallA

Hybrid lexical search (word/trigram FTS + CJK-aware fallbacks). Returns paths, excerpts, and score components — read the file (or memory_read) for full content; nothing is auto-injected. Ranking: text * trust * state * (1 + freshness + heat); old unused memories sink, never vanish.

Inputs: limit, query, store, types, +3 more.

memory_reindexReindexA

rebuild (default): drop all derivatives and reconstruct them from the memory files — originals own the content, so this is disaster recovery (only usage heat is lost). verify: full re-hash audit that ignores the stat gate and reports drift (files whose content no longer matches the index).

Inputs: store, verify.

memory_rememberRememberA

Create a memory (markdown original + derived index). Returns possible_conflicts with judgment material (shared entities, age gap, latest_wins_eligible) — the caller judges: supersede, keep both, or correct itself. Nothing is ever overwritten automatically. Identical content is idempotent (returns the existing id).

Inputs: content (required), type, store, trust, +4 more.

memory_statusStatusB

The honesty surface: counts by state/type/trust, pending conflict judgments, review-due memories, distillation (compaction) candidates, unparseable files, index freshness, dictionary state.

Inputs: store.

memory_updateUpdate memoryA

edit: revise wording/metadata in place (state preserved — meaning-changing revisions should use supersede instead). supersede: id wins over other_id (non-destructive version chain). set_state: explicit lifecycle transition. link: relate two memories. resolve_conflict: record a keep-both judgment for a surfaced pair.

Inputs: id (required), action (required), type, state, +8 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: reindex for maintenance, remember for creation, recall for search, read for retrieval, update for modifications, forget for deletion/lifecycle changes, and status for system overview. No two tools overlap in function; even update's multiple sub-actions are clearly delineated within a single tool.

    Naming Consistency5/5

    All tools follow a consistent 'memory_' prefix with a descriptive verb (remember, recall, read, update, forget, status, reindex). The naming pattern is uniform and predictable, making it easy to infer tool behavior from names alone.

    Tool Count5/5

    Seven tools is an ideal scope for a memory management server. It covers all core CRUD operations, search, maintenance, and status reporting without redundancy or bloat. Each tool occupies a necessary role in the lifecycle.

    Completeness5/5

    The tool set covers the full memory lifecycle: create (remember), retrieve (recall/read), update (update with edit/supersede/state changes), delete (forget with archive/deprecate/purge), plus maintenance (reindex) and oversight (status). Conflict resolution and linking are also supported, leaving no obvious gaps.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides persistent long-term memory for AI assistants with tag-based retrieval, wiki-style linking, and source references, storing memories as markdown files with SQLite index.
      2
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Provides AI agents with persistent, long-term memory via OKF-formatted markdown and SQLite indexing, enabling stateful storage, retrieval, and search across sessions.
      6
      223
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to maintain a persistent, queryable memory stored as user-owned Markdown files, with dual-channel retrieval (FTS5 and optional semantic search) and an audited write pipeline.
      11
      MIT