A privacy-first AI system that reads, searches, and writes to your personal notes.
Living Knowledge turns your local Obsidian vault into a living, searchable memory that an AI can access and extend. It runs entirely on your own hardware—your notes never leave your machine—while still being accessible from your phone or any device through a secure tunnel.
This project combines:
- LibreChat — A self-hosted ChatGPT-style interface
- devrag — Semantic search over markdown files using local embeddings
- Model Context Protocol (MCP) — Lets the AI read and write files directly
- Cloudflare Tunnel — Secure access from anywhere without exposing ports
The result: Ask an AI about your notes. It searches semantically, finds relevant context, and can create new notes on your behalf.
Most AI tools require uploading your data to someone else's servers. That's fine for public information, but not for:
- Personal journals and reflections
- Health records and medical notes
- Financial planning documents
- Private research and ideas
- Handwritten notes (via reMarkable → Obsidian workflows)
Living Knowledge keeps everything local while still giving you the power of retrieval-augmented generation (RAG).
┌─────────────────────────────────────────────────────────────────┐
│ Your Device │
│ (Phone, Laptop, etc.) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Cloudflare Tunnel │
│ (Zero Trust Authentication + Encryption) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Your Local Machine │
│ (Mac / Linux / Windows) │
│ ┌───────────────────────────────────────────────────────────┐ │
│ │ Docker Compose │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ LibreChat │ │ MongoDB │ │ MeiliSearch │ │ │
│ │ │ API │ │ (history) │ │ (search) │ │ │
│ │ └──────┬──────┘ └─────────────┘ └─────────────┘ │ │
│ │ │ │ │
│ │ ▼ │ │
│ │ ┌─────────────────────────────────────────────┐ │ │
│ │ │ MCP Servers │ │ │
│ │ │ ┌─────────────────┐ ┌──────────────────┐ │ │ │
│ │ │ │ devrag │ │ filesystem │ │ │ │
│ │ │ │ (semantic search│ │ (read/write │ │ │ │
│ │ │ │ read-only) │ │ notes) │ │ │ │
│ │ │ └────────┬────────┘ └────────┬─────────┘ │ │ │
│ │ └───────────┼────────────────────┼───────────┘ │ │
│ └──────────────┼────────────────────┼───────────────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌───────────────────────────────────────────────────────────┐ │
│ │ Obsidian Vault │ │
│ │ (iCloud, local folder, etc.) │ │
│ └───────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
| Component | Purpose |
|---|---|
| LibreChat | Web interface and API for chatting with AI models |
| MongoDB | Stores user accounts and conversation history |
| MeiliSearch | Full-text search over past conversations |
| devrag | Semantic vector search over your markdown notes |
| filesystem | MCP server that allows AI to create/edit notes |
| Cloudflare Tunnel | Secure, encrypted access without port forwarding |
- Docker & Docker Compose — Install Docker
- Anthropic API Key — From console.anthropic.com (or use OpenAI/other providers)
- Cloudflare Account — Free tier works; needed for secure external access
- Obsidian Vault — Or any folder of markdown files
Optimized for Apple Silicon (M1/M2/M3) but works on any system that runs Docker:
- macOS (ARM64 or Intel)
- Linux (x86_64 or ARM64)
- Windows with WSL2
git clone https://github.com/sahlstra/living-knowledge.git
cd living-knowledge/librechat# Copy the example environment file
cp .env.example .env
# Edit .env and add your API key(s)
# Required: ANTHROPIC_API_KEY=sk-ant-...
# Optional: OPENAI_API_KEY, GOOGLE_KEY, etc.# Copy the Living Knowledge override example
cp docker-compose.override.yml.living-knowledge.example docker-compose.override.yml
# Edit docker-compose.override.yml and update the vault path:
# - /path/to/your/obsidian_vault:/app/obsidian_vaultCommon vault paths:
- macOS iCloud:
/Users/yourname/Library/Mobile Documents/iCloud~md~obsidian/Documents - macOS local:
/Users/yourname/Documents/ObsidianVault - Linux:
/home/yourname/Documents/ObsidianVault - Windows (WSL2):
/mnt/c/Users/yourname/Documents/ObsidianVault
# Build the custom image with MCP servers
docker compose -p living-knowledge up -d --build
# Watch the logs to confirm startup
docker compose -p living-knowledge logs -f apiOpen http://localhost:3080 and create your account.
To access Living Knowledge from your phone or outside your home network:
# macOS
brew install cloudflare/cloudflare/cloudflared
# Linux
# See: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/cloudflared tunnel login
cloudflared tunnel create living-knowledgeCreate ~/.cloudflared/config.yml:
tunnel: <your-tunnel-id>
credentials-file: /path/to/.cloudflared/<tunnel-id>.json
ingress:
- hostname: notes.yourdomain.com
service: http://localhost:3080
- service: http_status:404cloudflared tunnel route dns living-knowledge notes.yourdomain.comcloudflared tunnel run living-knowledgeIn the Cloudflare Zero Trust dashboard:
- Go to Access → Applications
- Add your hostname (
notes.yourdomain.com) - Configure authentication (email OTP is simple and effective)
Now your notes are only accessible to authenticated users.
Living Knowledge gives the AI two capabilities:
The AI can search your notes by meaning, not just keywords:
"Find my notes about the conversation with Dr. Martinez about sleep patterns"
Even if those exact words don't appear, devrag finds semantically similar content.
The AI can:
- Read any markdown file in your vault
- Create new notes
- Update existing notes
"Create a new note summarizing what we just discussed about project planning"
The AI will create a properly formatted markdown file in your vault.
Controls MCP server configuration:
fileStrategy: "local"
endpoints:
agents:
recursionLimit: 50 # Increase for complex RAG tasks
mcpServers:
filesystem:
type: stdio
command: "npx"
args: ["-y", "@modelcontextprotocol/server-filesystem", "/app/obsidian_vault"]
devrag:
type: stdio
command: "/app/devrag_server"
args: ["-config", "/app/devrag_config.json"]Controls semantic search behavior:
{
"document_patterns": ["/app/obsidian_vault/**/*.md"],
"db_path": "/app/vectors.db",
"chunk_size": 500,
"search_top_k": 5,
"model": {
"name": "multilingual-e5-small",
"dimensions": 384
}
}Running semantic search on ARM64 Alpine containers requires a special approach. The devrag binary uses SQLite with vector extensions, which have C library dependencies.
The problem: Alpine Linux uses musl libc, but most binaries are compiled against glibc.
The solution: Dockerfile.mcp uses a multi-stage build:
-
Stage 1 (Debian): Compile the Go binary with static linking:
-ldflags "-linkmode external -extldflags '-static'"This bakes all C dependencies into the binary itself.
-
Stage 2 (Alpine): Copy the standalone binary into the LibreChat image.
The result is a single, portable binary that runs anywhere.
# Check devrag binary
docker compose -p living-knowledge exec api /app/devrag_server --help
# Check filesystem server
docker compose -p living-knowledge exec api npx -y @modelcontextprotocol/server-filesystem --helpdocker compose -p living-knowledge up -d --build# All services
docker compose -p living-knowledge logs -f
# Just the API
docker compose -p living-knowledge logs -f apidocker compose -p living-knowledge down -v
docker compose -p living-knowledge up -d --build- Docker binding: Services are bound to
localhostonly by default - No port forwarding: Cloudflare Tunnel creates an outbound connection; no inbound ports needed
- Zero Trust: Add email/OAuth authentication via Cloudflare Access
- Local data: Your notes and embeddings never leave your machine
- API keys: Stored in
.envwhich is gitignored
| Component | Cost |
|---|---|
| Hosting | $0 (runs on your hardware) |
| Cloudflare Tunnel | $0 (free tier) |
| Domain | ~$10-15/year (optional; can use Cloudflare's free *.cfargotunnel.com) |
| AI API | Pay-per-use (Claude Sonnet: ~$3/M input tokens, ~$15/M output tokens) |
Typical monthly cost: $5-20 depending on usage.
Aaron Sahlstrom — GitHub
This project builds on excellent open-source work:
- LibreChat by Danny Avila
- devrag by Tomohiro Owada
- Model Context Protocol by Anthropic
- Cloudflare Tunnel
This configuration and documentation is provided as-is. LibreChat and devrag have their own licenses—please review them for your use case.
Issues and pull requests welcome. This is a personal project shared in hopes it's useful to others who want AI-powered access to their private notes.