Persistent memory for Claude Code with hybrid search.
Melchizedek
Persistent memory for Claude Code. Automatically indexes every conversation and provides production-grade hybrid search (BM25 + vectors + reranker) via MCP tools. 100% local, zero config, zero API keys, zero invoice.
Why Melchizedek?
Claude Code forgets everything between sessions - and knows nothing about your other projects. Melchizedek fixes both.
It runs silently in the background - indexing your conversations as you work - then gives Claude the ability to search across your entire history, across all projects: past debugging sessions, architectural decisions, error solutions, code patterns.
No cloud. No API keys. No config. Plug and ask.
How it works
~/.claude/projects/**/*.jsonl (your conversation transcripts - read-only)
|
v
SessionEnd hook (auto-triggers after each session)
|
v
+-----------------+
| Indexer | Parse JSONL -> chunk pairs -> SHA-256 dedup
| (better-sqlite3)| FTS5 tokenize -> vector embed (optional)
+-----------------+
|
v
~/.melchizedek/memory.db (single SQLite file, WAL mode)
|
v
+-----------------+
| MCP Server | 16 search & management tools
| (stdio) | Hybrid: BM25 + vectors + RRF + reranker
+-----------------+
|
v
Claude Code (searches your history via MCP)
Search pipeline - 4 levels of graceful degradation
Every layer is optional. The plugin works with BM25 alone and gets better as more components are available.
| Level | Component | What it adds | Dependency |
|---|---|---|---|
| 1 | BM25 (FTS5) | Keyword search with stemming | None (always active) |
| 2 | Dual vectors (sqlite-vec) | Semantic search - text (MiniLM 384d) + code (Jina 768d) | @huggingface/transformers (optional) |
| 3 | RRF fusion | Merges BM25 + text vectors + code vectors via Reciprocal Rank Fusion | Vectors enabled |
| 4 | Reranker | Cross-encoder re-scoring of top results | Transformers.js or node-llama-cpp (optional) |
Performance
Measured with npm run bench - 100 sessions, 1 000 chunks, on a single SQLite file.
| Metric | Result | Target |
|---|---|---|
| Indexation (100 sessions) | ~80 ms | < 10 s |
| BM25 search (mean) | ~0.2 ms | < 50 ms |
| DB size (100 sessions) | ~1.4 MB | < 30 MB |
| Tokens per search | ~125 | < 2 000 |
Quick Start
npm (recommended)
npm install -g melchizedek
Add the MCP server to Claude Code:
claude mcp add --scope user melchizedek -- melchizedek-server
npx (no install)
claude mcp add --scope user melchizedek -- npx melchizedek-server
From source
git clone https://github.com/louis49/melchizedek.git
cd melchizedek && npm install && npm run build
claude --mcp-config .mcp.json
Claude Code plugin marketplace *(coming soon)*
Plugin review pending. In the meantime, use npm or npx install above.
claude plugin install melchizedek # not yet available
Setting up hooks (automatic indexing)
The MCP server provides search tools, but hooks trigger automatic indexing. Without hooks, you'd need to manually index sessions.
For marketplace installs, hooks are configured automatically. For npm/npx/source installs, add hooks to ~/.claude/settings.json.
See docs/installation.md for the full JSON configuration, hook reference, and troubleshooting.
After setup, restart Claude Code. Indexing starts automatically.
MCP Tools
Search (start here)
| Tool | Description |
|---|---|
m9k_search |
Search indexed conversations. Returns compact snippets. Current project boosted. Supports since/until date filters and order (score, date_asc, date_desc). |
m9k_context |
Get a chunk with surrounding context (adjacent chunks in the same session). |
m9k_full |
Retrieve full content of chunks by IDs. |
Progressive retrieval pattern - search returns ~50 tokens/result, context ~200-300, full ~500-1000. Start with m9k_search, drill down only when needed. 4x token savings vs loading everything.
**Context-aware ran
Tools (3)
m9k_searchSearch indexed conversations with support for date filters and ordering.m9k_contextGet a chunk with surrounding context from the same session.m9k_fullRetrieve full content of chunks by IDs.Configuration
{"mcpServers": {"melchizedek": {"command": "npx", "args": ["-y", "melchizedek-server"]}}}