← /projects

Memory Server

Hybrid BM25 + vector search MCP for querying personal knowledge across all memory files.

INFRAAISource ready; public repo pending.

The Problem

AI agents working across sessions lose context after compaction. Without a way to search accumulated personal knowledge — session logs, project docs, research notes — agents re-ask questions or miss historical context that would change their answers.

What I Built

An MCP server that ingests all my memory files (30 files, 481 chunks across 4 domains), chunks markdown at line boundaries (~1600 chars per chunk, 320 char overlap), embeds chunks via OpenAI text-embedding-3-small (cached by content hash), and serves a hybrid search tool combining BM25 (FTS5) + KNN vector search (sqlite-vec). Results merge as a weighted union (70% vector / 30% BM25), normalized across both algorithms. The indexer auto-detects file changes via fs.watch with 2-second debounce and re-indexes only changed files. Graceful degradation if the vector backend fails.

Notable

The hybrid merge normalizes both scoring systems to a 0–1 scale before weighting — BM25 uses FTS5's rank magnitude, vector uses inverted distance — allowing two fundamentally different scoring systems to combine reliably. Embeddings cached by chunk content hash, so re-indexing is cheap. sqlite-vec requires BigInt for primary keys; the insert path uses explicit casts.

Stack

Node.jsTypeScriptbetter-sqlite3sqlite-vecFTS5OpenAI text-embedding-3-smallMCPfs.watch

Status

Source ready; public repo pending.