AI · Local-first RAG · MCP

Alexandria

AI context that compounds instead of evaporating.

The problem

Every AI conversation starts from zero. The reasoning behind decisions, the context behind strategies, the evolution of ideas across hundreds of sessions with Claude, ChatGPT, and Gemini — all of it disappears the moment the session ends. I built Alexandria to make my own thinking persistent, queryable, and reusable, without sending any of it to a third party.

How it works

1

Capture

A prompt template extracts structured signals — decisions, patterns, context — as JSON at the end of any AI session.

2

Vectorize

Signals are embedded locally via multilingual sentence transformers and stored in a disk-based vector index alongside SQLite.

3

Query

Hybrid search (text + semantic) retrieves candidates. A ranking arbiter classifies the result as single, combined, or none — preventing noisy injections.

4

Inject

The retrieved context block is handed back into the next session, giving the model memory of prior reasoning.

5

MCP Server

Three tools (query, save, suggest_model) expose Alexandria directly to Claude Desktop and Gemini CLI mid-conversation.

Architecture decisions

01

Local-first by design

No cloud dependency, no API keys for the core loop. Embeddings run locally via Xenova/transformers. The vector index and database both persist to disk. This was a deliberate tradeoff: slower to scale across devices, but the data never leaves the machine.

02

Machine-bound encryption

Stored signals are encrypted with AES-256-GCM keyed to the machine ID. The data is personal context — I wanted it to be meaningless if the files were ever copied elsewhere.

03

A ranking arbiter, not top-k

The retrieval layer doesn't just return the closest match. It classifies the query as single (one clear winner), combined (two distinct topics), or none (low confidence — don't inject noise). This single decision is what keeps the context layer trustworthy instead of just searchable.

Stack

FrontendNext.js 14, TypeScript, React
APINext.js API routes (7 endpoints)
Vector searchVectra (local disk), multilingual embeddings
DatabaseSQLite via better-sqlite3
EncryptionAES-256-GCM, machine-ID keyed
MCP ServerNode.js, 3 tools
AI integrationsClaude Desktop, Gemini CLI