Commonplace
My bookshelf as a commonplace book Claude can search, by idea or by exact phrase, offline.
- what
- local ai tool, 2026
- my part
- design and spec; built with Claude as the engineer
- built with
- python · mcp · chromadb · bm25 hybrid rag · docker
notes on the making
A commonplace book is the notebook readers used to keep: passages copied out of what they'd read, so they could find them again. I wanted one I didn't have to copy into. I own about 120 ebooks, and I wanted Claude to use them properly: ask a question and get the actual passage back, with the book and chapter it came from, rather than a vague summary from memory.
The requirement that shaped everything was how I actually remember books. Sometimes I remember an idea but not the wording. Sometimes I remember one exact phrase and nothing else. The search had to handle both, and it had to run entirely on my own PC, with no cloud service and no internet after setup.
I designed it and wrote the spec; Claude wrote the code.
01three layers
Calibre holds the books. I set it up in Docker; I didn't write it.
A sync step turns each EPUB into clean Markdown, keeping chapter and section headings as real headings. That middle layer was a deliberate choice: the search never has to understand EPUB, and when a result looks wrong, the text it searched can be read or diffed directly.
An index and an MCP server sit on top. The server gives Claude three tools: search the library, read a whole chapter, and list the books. Search finds the passage; reading the chapter gives Claude the context around it.
02meaning and exact words, together
Either search method on its own fails one of my two cases.
Semantic search turns each passage into an embedding, a vector that captures its meaning, using a small local model (bge-small-en-v1.5) stored in ChromaDB. It's good at "the idea about working backwards from the customer" even when the book never uses those words. It's bad at names and exact phrases.
Keyword search uses BM25, the classic ranking behind most search boxes. It's good at a rare name or a precise phrase and useless for paraphrase.
So the server runs both and merges the two rankings with Reciprocal Rank Fusion. Each passage scores by its position in each list, not by its raw scores, which come from completely different scales:
for ranking in (semantic_rank, keyword_rank):
for r, cid in enumerate(ranking):
fused[cid] = fused.get(cid, 0.0) + 1.0 / (60 + r + 1)
A passage that ranks well in both lists wins. It has one constant (60 is the standard value) and needs no tuning between two incompatible score types, which is why I preferred it to blending scores. Putting words in double quotes adds a hard filter on top: every result must contain that exact phrase.
03the chunk size I asked for was wrong
Passages are cut along each book's own chapter and section headings, so a result can always say where it came from. My spec asked for chunks of around 600 tokens.
That was a mistake. The embedding model only reads the first 512 tokens of anything it's given, and it doesn't complain about the rest. It silently ignores them. A 600-token chunk would have been searchable by keyword all the way through, but by meaning only for its first 512 tokens: a failure you'd never notice in testing, only as searches that oddly miss.
So chunks are 480 tokens with 100 tokens of overlap, a little under the model's limit, and the limit is written next to the setting so nobody "improves" it later. The indexer also records the model and chunk settings, and refuses to update an index built with different ones, because mixing two chunk sizes in one index would quietly corrupt the rankings.
04cheap updates
The first full index took about two and a quarter hours on my CPU and produced roughly 44,700 passages. Re-running that every time I add a book wasn't an option.
Each book file is fingerprinted with a SHA-256 hash. An update compares fingerprints, removes passages for changed or deleted books, and embeds only new or changed ones. Adding a book now takes a minute or two, and running it with nothing new is close to instant.
The whole sync is wrapped in a Claude skill with hard rules: never touch the Calibre library itself, never force a full rebuild, and report what changed. It's safe to run unattended.
The book count on my work page comes from the same sync. Vercel builds this site on its own servers and can't see my PC, so the sync writes the count into a JSON file in the site's repo, and the page imports it at build time.
05small things that bit
An MCP server talks to Claude Desktop over standard input and output, so a single stray print() anywhere in the server corrupts the protocol. All logging goes to stderr, and libraries' progress bars are switched off.
The MCP SDK also renamed its main class between major versions, FastMCP to MCPServer, with the same API. The server tries both imports, so a dependency upgrade doesn't break it.
06testing it
Before indexing the real library, we indexed three books into a separate test copy and ran the indexer twice. The second run correctly did nothing. Then we called all three tools through a real MCP client: meaning-based search, exact-phrase search, filtering by book, the chapter list and full chapter reads, all offline.
07what mattered
Claude can now answer from my books with the passage, the book and the chapter, whether I describe an idea loosely or quote a phrase exactly. The choices that mattered most were the unglamorous ones: a Markdown layer in the middle, rank fusion instead of score blending, a chunk size that respects the model's real limit, and updates that only touch what changed.
It runs on my own machine against my own files, so there's no public demo or source to link.