Personal Bookshelf
by olaservo
README.md
# Personal Bookshelf (MCP App)
A personal bookshelf as an MCP App. It reads books you own, as DRM-free EPUBs or tagged PDFs, and makes each one interactive: quizzes, widgets, tools that apply the book's rules, navigation skills and the book's companion code. Open a book and the reader shows the text with those blocks in place. Built on `@modelcontextprotocol/ext-apps`.
## Choosing what to learn yourself
A model can read any of these books for you. The bookshelf asks which parts you want to learn yourself. Each section in the reader has a "How deep?" choice: learn it myself (the model tutors and quizzes you), know enough to check (it answers and tells you what to verify), or hand it off (it answers from the section). Missed quiz questions come back on a spaced schedule, and "learn" and "check" sections end with a box where you explain the section back and the model says what you got right. Details are in `docs/reader.md`.
## Prerequisites
- Node 24 (LTS, supported until April 2028).
- Your own DRM-free EPUBs or tagged PDFs, in `BOOKS_DIR` (see Add a book).
- For `sign` only: [uv](https://docs.astral.sh/uv/) and a [c2pa-python](https://github.com/contentauth/c2pa-python) checkout at `../../c2pa/c2pa-python`.
- For the reference host only: an [ext-apps](https://github.com/modelcontextprotocol/ext-apps) checkout at `../../mcp/apps/ext-apps`.
## Run
```bash
npm install
npm run trust -- 9781098119065 # trust each bundle's extensions once (see Extensions and trust)
npm run trust -- 9798341639553
npm run trust -- 9781806025831
npm start # Streamable HTTP on http://localhost:3001/mcp, rebuilds UI on change
npm run start:stdio # stdio transport (run `npm run build` first)
```
To use it from Claude Code, with the server running:
```bash
claude mcp add --transport http bookshelf http://localhost:3001/mcp
```
The server listens on loopback only. `HOST`, `PORT` and the protocol versions it serves are in `docs/server.md`.
Test in the reference host from the ext-apps checkout:
```bash
cd ../../mcp/apps/ext-apps/examples/basic-host
SERVERS='["http://localhost:3001/mcp"]' npm start # then open http://localhost:8080
```
## Check
There is no test suite. These are the checks, in order:
```bash
npm run typecheck
npm run derive -- <book> verify # once per book: locators, no book text, derivation record, credential
npx @modelcontextprotocol/inspector@2.8.0 --cli --transport http --server-url http://127.0.0.1:3001/mcp --method skills/list --verify # with the server running
```
Then in the reference host: the shelf opens on the last book read, a chapter loads, a quiz answer stays answered after reopening, a trusted extension's form returns a verdict, and "Send to chat with citation" sends a quoted passage with its locator.
## Add a book
1. Buy the ebook DRM-free. On [Bookshop.org](https://bookshop.org/ebooks), search the title, open the Format filter and tick DRM-free. [eBooks.com](https://www.ebooks.com/) and some publishers (Packt sells PDF and EPUB) also sell DRM-free. Kindle editions and subscription platforms such as O'Reilly's do not work.
2. Download the EPUB or PDF. On Bookshop.org, open your ebook Library, click the three-dot menu under the cover and choose Download / Transfer.
3. Put the file in `books/` (or wherever `BOOKS_DIR` points) and restart the server.
A PDF must be tagged: the loader reads chapters, sections, paragraphs, lists, tables and figures from its structure tree. An untagged PDF is skipped with a message in the log.
That is enough to read the book. To give it metadata, summaries, companion code and a credential, add a `catalog` entry in `data/library.ts` and run the deriver (`docs/bundles.md`):
```bash
npm run derive -- books/<file> # the bundle: units, locators, source hash, rights
npm run derive -- books/<file> summarize --model claude-sonnet-5-5 # a summary per section, needs ANTHROPIC_API_KEY
npm run derive -- books/<file> code --repo <owner/name> # pin the companion repo
npm run derive -- books/<file> sign # C2PA credential, needs uv
```
These steps exist because nothing ships with the book that says what it contains or what may be made from it. What a publisher or author could ship instead is in `ARCHITECTURE.md`, "Asks for publishers".
## Books on the shelf
| Book | Publisher | Source | Bundle |
|---|---|---|---|
| *Designing Data-Intensive Applications* (2nd ed.), Martin Kleppmann and Chris Riccomini | O'Reilly | EPUB | summaries, quizzes, widgets, 2 rule tools, skill, signed |
| *AI Agents with MCP*, Kyle Stratis (2026) | O'Reilly | EPUB | summaries, quizzes, widgets, 3 rule tools, skill, code, signed |
| *AI Agents: The Definitive Guide*, Nicole Koenigstein (2026) | O'Reilly | EPUB | summaries, quizzes, skill, code, signed |
| *MCP Engineering Handbook*, Peder Holdgaard Pedersen (2026) | Packt | tagged PDF | chapter summaries, quizzes, widgets, 3 rule tools, skill, code |
The text is the publisher's and is read from your own copy. It never leaves this machine. The bundles in `books/<isbn>/` hold no book text.
## Status
What is official and what is a stand-in, for every book on the shelf. Each stand-in is replaced by the matching ask in `ARCHITECTURE.md` ("Asks for publishers").
| | Today | Official when |
|---|---|---|
| Source | Unsigned EPUB or PDF, identified by its SHA-256 | The publisher signs the file |
| Summaries | Chapters by Claude (from the skillbook, or written by Claude from the reader's copy for the MCP Engineering Handbook), O'Reilly sections by `claude-sonnet-5` | The publisher ships chapter abstracts |
| Rights policy | Assumed, our reading of the rights | The publisher publishes a derivation policy |
| Online links | O'Reilly books: chapter page only, since EPUB anchors are unconfirmed on learning.oreilly.com. The Packt book: its eBook page on packtpub.com | The publisher confirms anchors for its online edition |
| Bundle credential | O'Reilly bundles signed with the C2PA test certificate (reported untrusted). The Packt bundle is unsigned | A real signing identity |
| Citations extension | `io.github.olaservo/citations`, our own key | A working group names the extension |
## Extensions and trust
Extensions are code from a book's bundle that runs in the server process, so the server loads one only when the exact file is on your trust list. `trust.json` in this directory (gitignored, `TRUST_FILE` to move it) maps each trusted file to the sha256 of its bytes. Editing or replacing a file revokes it until you trust it again. Until then its tool is not registered and its form in the reader shows a note instead.
```
npm run trust -- 9781098119065 --list # show each extension file, its hash and whether it is trusted
npm run trust -- 9781098119065 # trust the bundle's current extension files
```
Read the files before trusting them. No bundle here is signed by an identity you can check. The O'Reilly bundles carry a credential made with the C2PA test certificate and the Packt bundle has none. All four are `origin: community`, with an unsigned `authored_by` in `book.json`.
## Optional: O'Reilly search
The bookshelf works without it. Two ways to add O'Reilly's catalog, which can be used together:
1. Install O'Reilly's Content MCP server in the host next to the bookshelf. In Claude Code: `claude mcp add --scope user --transport http oreilly https://api.oreilly.com/api/search/v1/mcp`, then `/mcp`, pick `oreilly` → Authenticate.
2. Let this server proxy it. Create a personal token at https://learning.oreilly.com/access-tokens/ and put `OREILLY_MCP_TOKEN=...` in `.env` here (gitignored). The server then registers `oreilly_search` and `oreilly_add` and the reader shows a search box. "Add to shelf" adds a placeholder with a link to the title on O'Reilly.
## Docs
- `docs/reader.md` depth marks, quiz review, explain-back, memory and the usage log
- `docs/bundles.md` the bundle format, the deriver, companion code, signing, overlays and extensions
- `docs/server.md` transports, tools, citations, skills and resources, and the source layout
- `DESIGN.md` concepts, `ARCHITECTURE.md` the source and bundle design, `TODO.md` open work
## License
The code is MIT (`LICENSE`). Each bundle in `books/<isbn>/` is CC-BY-4.0, as its `book.json` says. The books themselves belong to their publishers and are not in this repository.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues