Skip to content

orobsonn/mind-vault

Repository files navigation

Mind Vault — a personal knowledge graph for Claude, built on Cloudflare

Mind Vault in action

The latticework thinking tool for people who talk to Claude. Mind Vault is a single-user, self-hosted knowledge graph that runs entirely in your own Cloudflare account and plugs into Claude Code, Claude Desktop, or Claude Web as an MCP server. You talk to Claude about ideas, Claude decides what is worth keeping, atomizes the concept, sweeps the vault for cross-domain analogies, and saves the note with edges that name the shared mechanism — not just "related".

Not a notes app. A thinking tool.

  • Concepts, not pages. Every note is one idea, titled in one line, summarized in one sentence (Feynman test).
  • Edges with substance. 9 typed relations (analogous_to, same_mechanism_as, contradicts, refines, …) each requiring a 20-character minimum why — the mechanism behind the connection.
  • Cross-domain by design. Recall is domain-balanced — the vault surfaces the unexpected match from another field, because that's where insight lives.
  • Multilingual. Write in Portuguese, English, or whatever the conversation is in. The embedding model (bge-m3) retrieves across 100+ languages.
  • Sovereign. Everything lives in your Cloudflare account — D1 (SQLite), Vectorize (embeddings), Workers AI. No third party, no lock-in, no subscription.
  • OAuth 2.1 + dynamic client registration. Claude Desktop and Claude Web plug in with just the URL; no token juggling.

Who is this for?

  • Developers who live in Claude Code and want their learnings to compound across sessions instead of evaporating at the end of each conversation.
  • Anyone looking for a "Claude-native" alternative to Obsidian or Notion for idea capture — specifically the cross-domain, analogy-driven style from Charlie Munger's latticework of mental models or Luhmann's Zettelkasten.
  • Writers, researchers, thinkers who read across fields and want a second brain that forces them to look for the structural overlap instead of burying notes in folders.

Mind Vault is not a replacement for a daily-capture notes app. It is for the subset of your thinking worth preserving with rigor — the ideas you want to find again, in a different context, years later.

When Mind Vault makes sense (and when it doesn't)

Mind Vault is an opinionated tool. It is not "notes for Claude" — it is a discipline wrapped in an MCP server. Before installing it, check yourself against these lists.

✅ Use Mind Vault if…

  • You read or work across multiple domains and want the structural analogies between them to surface automatically. The whole point of the vault is to notice that a pattern you just hit in software engineering is the same shape as a pattern you read about in evolutionary biology last year.
  • You already live inside Claude Code, Claude Desktop, or a Claude-compatible client. Mind Vault is an MCP server — its value comes from being reachable without leaving the conversation.
  • You make judgment calls with reasoning worth preserving — design decisions, research conclusions, strategic bets. The vault protects the why so you can revisit it later.
  • You are on Pro, Max, or the API and can afford the ~2,400-token overhead per cold request. On Max 5x/20x this is negligible.
  • You believe in the Munger/Luhmann method: atomize one concept per note, link with substantive whys, prefer cross-domain structure over folders. If you don't buy the method, the tool will feel like friction.

❌ Skip Mind Vault if…

  • You're on Claude Free. The MCP overhead eats ~27% of your 5-hour window before you type anything. Not worth it.
  • You want a daily journal or task list. The vault is ruthless by design — it rejects ephemeral capture. Use Obsidian, Notion, or Apple Notes.
  • You only work within one narrow domain. The value proposition is cross-domain recall. A single-domain user gets most of the benefit from a plain markdown folder and grep.
  • You don't use Claude as your primary interface. The vault is readable from a web dashboard, but the writing discipline only works when an LLM is mediating the save flow. Without that, you'll drift back to dumping notes.
  • You want a second brain that captures everything. Mind Vault punishes low-signal saves — sloppy notes pollute future recalls. If you can't articulate a one-sentence tldr, the note isn't ready.
  • You need offline access or local-only storage. The vault runs on Cloudflare D1 + Vectorize. Your notes leave your machine.
  • You care about preserving the exact surface wording of what you wrote. The vault nudges toward atomization and rewriting — it is a thinking tool, not an archival tool.

The honest one-liner

Mind Vault is worth it when you treat it as a discipline for the ideas you'll actually want again, not as a place to dump things. If that distinction doesn't resonate, you probably don't need it yet.

💰 Cost: $0 — runs entirely on Cloudflare's free tier

Before you deploy anything, read this: you will not be charged. Mind Vault runs on Cloudflare's free tier, which is generous enough that a personal vault never comes close to the limits:

Service Free tier What a personal vault uses
Workers (the server) 100,000 requests/day ~50 reqs/day in active use
D1 (the database) 5 GB storage, 5M reads/day, 100k writes/day A few MB, hundreds of reads
Vectorize (the search) 5M stored vectors, 30M queries/month A few thousand at most
Workers AI (embeddings) 10,000 neurons/day A few hundred
KV (OAuth tokens + graph cache) 100k reads/day, 1k writes/day (per namespace) Single-digit reads per login + cached graph layout

No credit card required to create a Cloudflare account. You can sign up with just an email at cloudflare.com/sign-up, verify the email, and you're ready. Even if you exceeded the free tier (you won't), Cloudflare shows warnings before charging anything — never a surprise bill.

⚠️ The real cost: Claude tokens

The infrastructure is free, but connecting the MCP to Claude is not free from the token budget's perspective. You need to understand this before deciding if Mind Vault is worth it for your usage pattern.

What it costs

Cost Tokens When you pay
MCP always-on overhead ~2,400 Every request while the MCP is connected (cacheable, 5-min TTL)
using-mind-vault skill ~1,300 Only when the skill is invoked (don't invoke if MCP is connected — it duplicates the tool descriptions)
recall response 100–300 Per call (returns tldrs only, never bodies — cheap by design)
get_note response 500–2,000 Per call (full body)

The ~2,400 tokens come from the tool descriptions and usage instructions that the MCP injects into the system prompt (src/mcp/instructions.ts + the 6 tool schemas). They load on every request while the MCP is connected, whether or not you actually use the vault that turn. The prompt cache (5-min TTL) makes this near-free during active back-and-forth, but you re-pay it on every cold start.

Impact by Claude plan

Anthropic doesn't publish exact token quotas for consumer plans, but here's the practical read based on community-observed numbers:

Plan Usage window Observed budget MCP overhead as % of window
Free 5h rolling very tight (~9k tok effective) ~27% — don't use Mind Vault on Free
Pro ($20/mo) 5h rolling + weekly cap ~44k tok per 5h window ~5.5% per cold request
Max 5x ($100/mo) 5h rolling + weekly cap ~220k tok per 5h window ~1.1%
Max 20x ($200/mo) 5h rolling + weekly cap ~880k tok per 5h window ~0.3%
API (Claude Code / SDK) no window, pay per token unlimited billed directly (~$0.036/cold turn on Opus, ~$0.0036 cached)

Key things to know about the plan windows:

  • All paid plans use a 5-hour rolling window, not a daily reset. Messages fall off 5 hours after you sent them. Check /usage in Claude Code or claude.ai/settings/usage to see live counters.
  • Weekly caps were added in August 2025 to Pro and Max for heavy users, on top of the 5h window. Mind Vault's fixed overhead contributes to this weekly counter too.
  • Peak hours burn faster: on weekdays 5–11am PT / 1–7pm GMT, Anthropic tightens the 5h session limits during high demand. An MCP-connected session with 10 cold turns in peak hours can eat a noticeable chunk of a Pro window.
  • API billing is the opposite model: no window, but every token is metered. Here the MCP overhead becomes a real line item. Cache discipline matters most.

Practical recommendations

  1. Free plan: don't bother. The MCP overhead eats too much of your tiny window.
  2. Pro plan: connect the MCP selectively. For conversations that are going to touch the vault, keep it on. For an hour of UI work or debugging, disconnect it — you'll get noticeably more headroom in the 5h window.
  3. Max 5x / 20x: leave it connected. The overhead is <1% of your window and the discipline encoded in the tool descriptions pays for itself the first time it prevents a bad note.
  4. API / Claude Code: leave it connected in vault-centric sessions, disconnect in others. You're paying per token either way; cache warmth is your best lever.
  5. Never invoke the using-mind-vault skill while the MCP is connected — it duplicates ~1,300 tokens of guidance the MCP already loaded. The skill exists for fallback environments (Gemini, Codex, etc.) without MCP support.
  6. Batch vault interactions inside a single session. Five recalls in a row stay cached and are nearly free. Five recalls spread across the day pay cold-start each time.
  7. Prefer recall over get_note. Read full bodies only when the tldr is insufficient. A 2k-token note read 5 times in a session is 10k tokens gone.

For the full methodology and per-tool breakdown, see docs/token-cost.md.

Quickstart — let your agentic IDE do the work

Mind Vault is set up by your agentic IDE (Claude Code, Cursor, Windsurf, etc), not by a web wizard. The repo ships with a deterministic runbook at CLAUDE.md that the agent follows end-to-end. The only thing you type is an email and a passphrase. Everything else — provisioning D1, Vectorize, KV, hashing the passphrase, generating the session secret, pushing secrets, deploying, applying the schema — is done for you.

What you need:

  • A computer with Node.js 20+ installed (nodejs.org)
  • A free Cloudflare account (sign up — no credit card)
  • An agentic IDE connected to Claude

The flow:

git clone https://github.com/orobsonn/mind-vault.git
cd mind-vault
npm install
npx wrangler login   # opens browser → click "Allow" → done

Now open the folder in your IDE and say:

Set up Mind Vault.

The agent reads CLAUDE.md, asks you for an email and a passphrase (12+ chars), and runs the full runbook. When it finishes it hands you back the Worker URL plus the one-liner to connect Claude Code to the MCP:

claude mcp add --transport http mind-vault https://<your-worker>.workers.dev/mcp

Install the using-mind-vault skill (the agent gives you the link) and paste the personalization block it shows you.

First conversation

Open Claude and share an idea:

"I just realized tech debt behaves like compound interest — the longer you ignore it, the worse the rate gets."

Claude calls MindVault:recall to sweep the vault for analogies, then offers to save the note with MindVault:save_note, atomizing it into one concept per note and creating edges with substantive why justifications. You'll see the MCP tool calls in the conversation UI.

What you'll see

Notes view

Notes view — each concept atomized, tldr as the Feynman test, domains as narrow as possible.

Graph view

Graph view — force-directed physics with Obsidian-style reveal. Solid purple lines are explicit edges; dashed teal lines are semantic-similarity edges surfaced by the embedding model; nodes are colored by domain.

Architecture

flowchart LR
    User([You])
    Claude[Claude Code<br/>Desktop / Web]
    Worker[Cloudflare Worker<br/>single endpoint]
    OAuth[OAuth 2.1<br/>KV grants]
    MCP[MCP Server<br/>6 tools]
    D1[(D1<br/>notes + edges<br/>FTS5)]
    Vec[(Vectorize<br/>1024-dim<br/>cosine)]
    AI[Workers AI<br/>bge-m3 multilingual]
    Web[Web Dashboard<br/>graph view]

    User -->|chat| Claude
    User -->|browse| Web
    Claude -->|OAuth| Worker
    Web -->|session| Worker
    Worker --> OAuth
    Worker --> MCP
    MCP -->|SQL + FTS5| D1
    MCP -->|embed query| AI
    MCP -->|vector search| Vec
    AI -.->|on save| Vec

    classDef edge fill:#f4f4f5,stroke:#71717a,color:#18181b
    classDef store fill:#ecfdf5,stroke:#10b981,color:#064e3b
    classDef compute fill:#eff6ff,stroke:#3b82f6,color:#1e3a8a
    class User,Claude,Web edge
    class D1,Vec,OAuth store
    class Worker,MCP,AI compute
Loading

A single Cloudflare Worker serves three responsibilities on the same URL:

Path Function
/ Landing page — when configured, shows vault status with connection badge + copy-pasteable MCP URL + skill download + personalization prompt. When not configured, shows a static "finish setup from your agentic IDE" page pointing at CLAUDE.md.
/authorize, /token, /register OAuth 2.1 via @cloudflare/workers-oauth-provider with dynamic client registration
/mcp MCP endpoint protected by OAuth, served by McpAgent (agents/mcp) wrapping McpServer from @modelcontextprotocol/sdk
/skill/using-mind-vault.zip The skill ZIP served as a static asset
/status JSON vault status (notes, edges, OAuth clients, active tokens, connection state)

Bindings (all in wrangler.toml):

  • DB — D1 (SQLite) for notes, edges, tags, FTS5
  • VECTORIZE — 1024-dim cosine index, one vector per note
  • AI — Workers AI, model @cf/baai/bge-m3 for multilingual embeddings
  • OAUTH_KV — KV namespace for OAuth grants/tokens/client registrations
  • GRAPH_CACHE — KV namespace caching the precomputed graph layout for the web dashboard
  • ASSETS — static assets (skill ZIP)

Schema (5 tables):

  • notes(id, title, body, tldr, domains JSON, kind, created_at, updated_at)
  • notes_fts (virtual FTS5 on title + tldr + body, auto-synced via triggers)
  • tags(note_id, tag) (escape hatch; real structure lives in edges)
  • edges(id, from_id, to_id, relation_type, why, created_at) with CHECK enum of 9 relation types and UNIQUE(from_id, to_id, relation_type)
  • meta(key, value) for singleton metadata

MCP tools (what Claude calls)

Tool Purpose
save_note Atomic note + edges in a single call. Validates edge why ≥ 20 chars, domain slugs against regex, edge target existence.
recall Hybrid search: Workers AI embedding query + FTS5, merged and domain-balanced (max 3 per domain, up to 5 distinct domains). Returns only {id, title, domain, kind, tldr} — never the body.
expand 1-hop neighbors of a note in the graph.
get_note Full body + tags + edges of one note by id.
link Create an edge between two existing notes (for when Claude spots a connection between prior saves mid-conversation).

Tool descriptions are written in English with mandatory-flow instructions ("call recall first before save_note") and pedagogical error messages ("if the conversation is in Portuguese and you were going to use biologia-evolutiva, use evolutionary-biology instead") that teach Claude how to recover from mistakes in one shot.

Method & intellectual lineage

flowchart TD
    Idea([You articulate an idea])
    Atomize{One concept?<br/>title has 'and'/'e'?}
    Split[Split into<br/>separate notes]
    Tldr{Can you write<br/>a one-sentence tldr?}
    NotReady[Keep thinking —<br/>note isn't ready]
    Recall[recall across domains<br/>even if 'obviously new']
    Read[Read ALL returned<br/>domains, not just top hit]
    Hit{Cross-domain<br/>analogy found?}
    Edge[Draft edge with<br/>substantive why<br/>20+ chars, name the mechanism]
    Save[save_note<br/>atomic + edges in one call]
    Vault[(Vault grows<br/>as a latticework)]

    Idea --> Atomize
    Atomize -->|yes, split| Split --> Tldr
    Atomize -->|no, atomic| Tldr
    Tldr -->|no| NotReady
    Tldr -->|yes| Recall
    Recall --> Read
    Read --> Hit
    Hit -->|yes| Edge --> Save
    Hit -->|no| Save
    Save --> Vault
    Vault -.->|future recall<br/>surfaces this note| Recall

    classDef action fill:#eff6ff,stroke:#3b82f6,color:#1e3a8a
    classDef check fill:#fef3c7,stroke:#f59e0b,color:#78350f
    classDef terminal fill:#ecfdf5,stroke:#10b981,color:#064e3b
    classDef stop fill:#fee2e2,stroke:#ef4444,color:#7f1d1d
    class Recall,Read,Edge,Save,Split action
    class Atomize,Tldr,Hit check
    class Idea,Vault terminal
    class NotReady stop
Loading

This is not a clean-room design. Each decision has roots in a tradition:

  • Charlie Munger — latticework of mental models, the value of cross-domain thinking. North star.
  • Scott E. Page, The Model Thinker — diversity prediction theorem (diversity of models beats depth of one). Foundation for domain-balanced recall.
  • Douglas Hofstadter & Emmanuel Sander, Surfaces and Analogies — analogy as the core of cognition. Foundation for the weight of analogous_to and same_mechanism_as edges.
  • Dedre Gentner, Structure-Mapping Theory — the distinction between surface and structural similarity. Keeps edges honest.
  • Niklas Luhmann / Sönke Ahrens, How to Take Smart Notes (Zettelkasten) — atomic notes, links with substance, emergent structure. Foundation for "one concept one note", "never link without a why", and "not every conversation becomes a note".
  • Richard Feynman — if you cannot explain it simply, you do not understand it. Foundation for the mandatory tldr field.
  • Karl Popper — fallibilism. Foundation for contradicts and refines as first-class edge types.

The public framing is latticework thinking / many-model knowledge graph, not "Munger mental models" — the academic basis (Page, Hofstadter, Gentner, Luhmann) is more rigorous than Munger's speeches alone.

Advanced: auto-deploy on git push (optional)

Skip this section if you're not sure you need it. The Quickstart above (with wrangler login + wrangler deploy) is enough for personal use — you only redeploy when you change code, and you can just run wrangler deploy again from your terminal.

This repo ships with a GitHub Actions workflow (.github/workflows/deploy.yml) that auto-deploys to your Worker on every push to master or main. Useful if you plan to modify Mind Vault and want your changes to ship automatically when you push to GitHub.

To enable it on your fork:

  1. Create a Cloudflare API token: go to dash.cloudflare.com/profile/api-tokensCreate Token → use the "Edit Cloudflare Workers" template, then add these extra permissions: D1 Edit, Vectorize Edit, Workers KV Storage Edit, Workers AI Edit. Click Continue → Create Token → copy the token shown (you won't see it again).
  2. Copy your Cloudflare Account ID: in any page of the Cloudflare dashboard, it's in the right sidebar.
  3. In your GitHub fork, go to Settings → Secrets and variables → Actions → New repository secret and add:
    • CLOUDFLARE_API_TOKEN = the token from step 1
    • CLOUDFLARE_ACCOUNT_ID = the account ID from step 2
  4. Push any commit to master. The workflow runs npm run typecheck + npm test + npm run build:skill before deploying, so a failing test blocks the deploy.

You can follow the runs at https://github.com/YOUR_USER/mind-vault/actions.

Development

npm install
npm run dev          # wrangler dev on local Miniflare
npm test             # vitest-pool-workers (workers pool + node pool for auth)
npm run typecheck    # tsc --noEmit
npm run build:skill  # package skills/using-mind-vault/ into assets/using-mind-vault.zip
npm run deploy       # build skill + wrangler deploy

Tests run in two pools: the main workers pool (for D1 + MCP tool tests with mocked Vectorize / Workers AI), and a separate node pool for the password hashing test (crypto.subtle is available in both, but the node pool keeps the auth module isolated from the workers runtime constraints).

Security

Single-user by design. Do not share the Worker URL. Access is gated by OAuth 2.1 using an email + passphrase hash stored as Worker secrets. The passphrase itself is hashed with PBKDF2-SHA256 at 100k iterations (Workers-capped — see src/auth/password.ts). The tokens issued by the OAuth provider are stored in the OAUTH_KV namespace.

If you want a multi-user version, fork and adapt — it is not a drop-in change. You will need per-user rows in D1, per-user Vectorize filtering, and a registration flow.

There is currently no login rate limit. Pull requests welcome.

Free tier

D1 + Vectorize + Workers AI free tiers are sufficient for personal use. Confirm current limits on Cloudflare's pricing pages before relying on them for large vaults.


Made by Robson Lins · Instagram · X / Twitter · YouTube

About

Personal knowledge graph MCP server on Cloudflare D1 + Vectorize. Deploy your own sovereign second brain in one click — Claude captures atomic concepts, finds cross-domain analogies, and links them with substantive justifications. Latticework thinking as a service, running entirely in your Cloudflare account.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors