Skip to main content
Glama

markdown-hierarchical-memory

An implementation of markdown-hierarchical-memory-spec.md v1.

  • MCP server (src/mdmem/): The mechanical execution layer providing file read/write, frontmatter management, a wikilink graph, keyword search with graph expansion, optimistic concurrency control (§16), bidirectional link consistency checks (§12), and a change log (§10/§17). Semantic judgments such as cohesion and importance (§9) are not implemented.

  • Claude Code subagent (.claude/agents/memory-manager.md): The Manager Agent defined in §10 of the specification. This is the component that makes semantic judgments by calling MCP tools.

Scope

  • Of the features in §15, only link graph + keyword search is supported (embedding vector search is not implemented. It can be added by replacing _score in src/mdmem/search.py).

  • The Manager Agent's decision-making logic does not make LLM calls internally within the server. The caller (Claude Code) is expected to make the decisions and pass the results as parameters to tool calls.

Related MCP server: AIBrain

Setup

pip install -e .
python -m pytest tests/

Registering with Claude Code

Copy .mcp.json.example to .mcp.json and replace <ABSOLUTE_PATH_TO_THIS_REPO> with the absolute path to this repository (.mcp.json is excluded by .gitignore because it contains a personal local path):

cp .mcp.json.example .mcp.json
# Edit .mcp.json and fill in the path

After restarting Claude Code (or reloading the MCP configuration), the mdmem server will be enabled, and the memory-manager subagent in .claude/agents/memory-manager.md will be able to call the mcp__mdmem__* tool set.

claude mcp list

This command can be used to verify that mdmem is recognized.

Registering with Cursor

After restarting Cursor (or reloading mdmem in Settings → Tools & MCP), you can share and use the same memory/ directory with Claude Code.

Directory Structure

memory/
 ├── index.md          # Pure registry (§14)
 ├── projects/
 ├── concepts/
 └── archive/
      └── _manager_log.md   # Change log (§10/§17)

The actual path of memory/ can be changed with the MDMEM_ROOT environment variable (default: memory/ in the current directory).

Main MCP Tools

Tool

Corresponding specification

get_index / list_memory_files / read_memory_file / search_memory / get_links

§14, §15, §11 (access_count)

create_memory_file

§3, §14

append_to_memory_file

§4 Step1, §16

link_memory_files

§12 (executes bidirectional linking as a single operation, with self-checking)

split_memory_file

§9/§10 splitting

summarize_and_archive_memory_file

§5/§9/§13 summarize and archive

move_to_archive

§13 forgetting model (content unchanged)

check_archive_candidates

§13 (suggestions only; does not execute them. §11)

get_change_log

§10/§17

All write tools accept expected_updated and return ConflictError if it differs from the value observed during reading (§16).

Known Limitations

  • Narrow race condition in concurrent writes: Optimistic locking with expected_updated only guarantees the sequence of "read, then validate, then write" within a single process. When Cursor and Claude Code share the same MDMEM_ROOT (a situation actually observed during development of this repository), there is a theoretical possibility that two processes read the same file at nearly the same time, both pass the check, and one update overwrites the other. This is not critical, but it is not a problem when writes are performed by a single process only.

  • Embedding vector search is not implemented (see the Scope section).

  • id only accepts ^[A-Za-z0-9_-]+$ (because it is used directly in file paths).

License

MIT

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.
    1
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    A personal, offline-first memory for AI assistants that enables them to read, search, and write to a shared folder of Markdown files, so they all remember you without needing a cloud.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Provides persistent, local-first memory for coding agents with Markdown as the source of truth, exposed via CLI, loopback API, MCP, and Codex hooks for context retrieval and durable writes.
    MIT
  • A
    license
    A
    quality
    B
    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