π§ MeMex β Zero-RAG Personal Knowledge Base
The Karpathy LLM Wiki pattern, production-ready.
No embeddings. No vector databases. No infrastructure. Just markdown, git, and your LLM.
Quick Start β’ MCP Server β’ Prompts β’ Schema β’ Examples
"The human's job is to curate sources, direct the analysis, ask good questions, and think about what it all means. The LLM's job is everything else." β Andrej Karpathy
Based on Karpathy's LLM Wiki pattern, extended with:
- π« Zero hallucination enforcement β every claim must cite a source
- π€ MCP server β expose your wiki to Claude Code, Codex, OpenClaw, Cursor
- π₯ Multi-agent support β multiple AI agents, one shared wiki, git handles conflicts
- π Human-in-the-loop conflict resolution β LLM flags contradictions, you decide truth
- π Confidence tracking β per-claim certainty scores, quarantine mode for low-confidence pages
- π Knowledge graph β interactive force-directed visualization of all [[wikilinks]] (optional)
Why Not RAG?
Traditional RAG retrieves document chunks every query. Your LLM rediscovers knowledge from scratch. Every. Single. Time. Nothing compounds.
MeMex compiles knowledge once. Your LLM reads your sources and builds a structured, interlinked wiki. Every new source makes the whole wiki richer. Knowledge grows β it doesn't reset.
RAG: Source β [retrieve] β LLM β Answer (rediscovers every time)
MeMex: Source β [compile] β Wiki β LLM (compounds over time)
flowchart LR
subgraph Input
R["raw/ sources"]
end
subgraph Processing
L["LLM reads & extracts"]
end
subgraph Knowledge
W["wiki/ compiled knowledge"]
end
subgraph Output
O["outputs/ reports"]
end
R --> L
L --> W
W --> O
W -->|compounds over time| W
Key Principles
Quick Start
1. Clone
git clone https://github.com/JPeetz/MeMex-Zero-RAG.git my-wiki
cd my-wiki
2. Add a source
Drop any document into raw/:
cp ~/Downloads/interesting-article.md raw/
3. Tell your LLM to ingest it
Open Claude Code, Cursor, Codex, OpenClaw, or any AI coding agent and paste:
Read SCHEMA.md. Then ingest raw/interesting-article.md following the ingest workflow.
The LLM will:
- Read the source and discuss key takeaways with you
- Create a summary in
wiki/sources/ - Create or update entity and concept pages
- Update
wiki/index.md - Log the operation in
wiki/log.md
4. Query your knowledge base
Read wiki/index.md. Based on the knowledge base, answer: [YOUR QUESTION].
Cite which wiki pages informed your answer.
5. Run the MCP server (optional)
Expose your wiki to Claude Code, OpenClaw, or any MCP-compatible agent:
pip install mcp
python mcp/server.py --wiki wiki/
# SSE for remote/multi-agent access
pip install uvicorn starlette sse-starlette
python mcp/server.py --transport sse --port 3001
That's it. No setup scripts. No API keys. No database migrations.
Directory Structure
your-wiki/
βββ L1/ # π Auto-loaded, git-ignored (private)
β βββ identity.md # Your preferences, context
β βββ rules.md # Hard constraints, gotchas
β βββ credentials.md # API keys (NEVER committed)
β
βββ raw/ # π₯ Source documents (immutable)
β
βββ wiki/ # π LLM-maintained knowledge base
β βββ index.md # Master catalog
β βββ log.md # Operation history
β βββ contradictions.md # Pending conflict resolutions
β βββ sources/ # One summary per ingested source
β βββ entities/ # People, orgs, tools, projects
β βββ concepts/ # Ideas, frameworks, patterns
β βββ synthesis/ # Analyses, comparisons, insights
β
βββ outputs/ # π€ Generated reports, slides
βββ mcp/ # π MCP server (stdio + SSE)
βββ scripts/ # CLI tools (memex ingest/search/lint)
βββ SCHEMA.md # π§ The brain β how the wiki works
βββ PROMPTS.md # π Copy-paste prompts for all operations
βββ README.md # This file
The L1/L2 Architecture
Inspired by CPU cache hierarchy:
L1 is git-ignored. It contains sensitive context that should never be committed.
L2 is the wiki. Versioned, shareable, grows over time.
Zero Hallucination Protocol
MeMex enforces citation discipline at every level:
- Every claim must have a source:
[Source: filename.md] - Lint catches violations: Unsourced claims are π΄ ERROR, not warnings
- Quarantine mode: Pages with >20% unsourced claims get
status: quarantine - GitHub Actions: Broken links, missing citations, orphan pages checked on every PR
β
Correct: "Project X uses Redis [Source: architecture.md]"
β Rejected: "Project X uses Redis" (no source β lint error)
Conflict Resolution
When sources contradict each other:
- LLM flags the conflict in
wiki/contradictions.md - LLM stops and asks you which claim is authoritative
- You decide β the LLM never auto-resolves truth
- Decision is logged with rationale
MCP Tools
When running python mcp/server.py, your agent gets these tools:
Lifecycle management (wiki_flag / wiki_revalidate / wiki_read_by_slug)
MeMex pages carry a status field (draft | active | stale | quarantine) so
agents and plugins (e.g. memex-hermes-plugin) can round-trip knowledge lifecycle
state without a translation layer. See SCHEMA.md
for the full field reference.
wiki_flag(page, reason)β quarantines a page (status: quarantine), stamping the reason and a UTC timestamp into frontmatter. Refuses to flag a page written withis_immutable: true.wiki_revalidate(page, outcome, new_body?, new_sources?, rationale?)β resolves a quarantined page:outcome: confirmβ clears quarantine, setsstatus: active, keeps existing content.outcome: updateβ replaces the body withnew_body(required) and optionally appendsnew_sourcescitations, then setsstatus: active.outcome: retireβ setsstatus: staleand clears flag metadata (reason/timestamp).
wiki_read_by_slug(slug)β looks up a page by bare slug across all four type directories (entities/,concepts/,sources/,synthesis/) so callers don't need to know a page's type prefix ahead of time. Returns{"found": false}when missing, or{"found": false, "ambiguous": true, "candidates": [...]}when the slug matches more than one type directory.
Claude Code config (~/.claude/mcp.json)
{
"mcpServers": {
"memex": {
"command": "python",
"args": ["mcp/server.py", "--wiki", "wiki/"]
}
}
}
OpenClaw config
{
"plugins": {
"mcp": {
"servers": [{ "name": "memex", "transport": "stdio",
"command": "python3 mcp/server.py --wiki wiki/" }]
}
}
}
Knowledge Graph Visualization
MeMex includes an optional knowledge graph that visualizes every [[wikilink]] in your wiki as an interactive, searchable force-directed graph.
# Enable when starting the MCP server
python3 mcp/server.py --enable-graph
The wiki_graph MCP tool builds graph/graph.html β open it in any browser.
The graph auto-rebuilds on every wiki_write when enabled.
Does not require --enable-graph to use the rest of MeMex β the graph is
an entirely self-contained optional feature.
Multiple AI agents can write to the same wiki simultaneously using git worktrees:
# Each agent gets its own branch/worktree
git worktree add ../wiki-agent-1 feat/agent-1
git worktree add ../wiki-agent-2 feat/agent-2
# Agents commit with attribution
# wiki_write tool commits as: wiki(agent-name): add/update type/slug
Git handles authorship, history, and conflict detection natively. See GUIDE.md for the full multi-agent setup.
CLI Tooling
# Add to PATH
export PATH="$PATH:/path/to/memex/scripts"
memex ingest paper.pdf # PDF with academic metadata
memex ingest https://example.com # Web page
memex search "machine learning" # BM25 + semantic search
memex lint --fix # Check wiki health
memex graph # Generate wikilink graph
memex serve # Start MCP server
Requirements
- Any AI coding agent: Claude Code, Cursor, Codex, OpenClaw, Gemini CLI, etc.
- Git for version control
- Python 3.9+ for MCP server (optional)
- That's it β no databases, no APIs, no infrastructure
Optional Enhancements
Credits
- Vannevar Bush β Original Memex concept (1945)
- Andrej Karpathy β LLM Wiki pattern
- MehmetGoekce/llm-wiki β L1/L2 cache architecture inspiration
- rohitg00's LLM Wiki v2 β Lifecycle and consolidation patterns
Author
Joerg Peetz β with contributions from Molty, Coconut, Marvin (AI collaborators on the MeMex team)
License
MIT β Use it, fork it, adapt it, share it.
Start small. Ingest one source. Ask one question. Watch the wiki grow.
Part of the AgentForge Ecosystem
Copyright (c) 2026 Joerg Peetz. All rights reserved.