Deterministic book-to-markdown pipeline for LLM consumption
Project description
librarian
Turn any ebook into clean, token-counted Markdown chapters — and let Claude read your bookshelf over MCP. Deterministic RAG: no embeddings, no network, no API keys.
Any input format — FB2, EPUB, DOCX, HTML, TXT/MD, text-layer PDF — becomes a directory of clean chapters with token counts. No network, no LLM, no randomness: the same input always produces byte-identical output.
Install
uv tool install librarian-cli
# or: pipx install librarian-cli
Offline contract: install and runtime need no network (the tokenizer's vocabulary is vendored in the package).
Quick start
lib ingest examples/*.epub
lib list
lib find curiouser
lib get <book-id> --budget 3000
Commands
| Command | Purpose |
|---|---|
lib ingest <files…> [--force] [--no-keep-source] [--config cfg.toml] [--verbose] |
Process books into the library; prints a file · id · status · score table. |
lib list [<book-id>] |
No argument — all books; with an id — that book's chapters (n, title, tokens, summary). |
lib get <book-id> <spec> |
Print chapters by range (1-3,7) to stdout. |
lib get <book-id> --budget N [--from K] |
Greedily print consecutive chapters from K while the token sum stays ≤ N. |
lib find <query> [--limit 10] [--book <id>] [--reindex] [--json] |
Full-text search across chapters and titles/authors library-wide (bm25, snippets, RU/EN stemming). |
lib info <book-id> |
JSON: book metadata + quality metrics. |
lib doctor [<book-id>] |
No id — books in review and broken directories; with id — that book's report. |
lib reingest --all [--config cfg.toml] [--verbose] |
Rebuild the library from source/ with the current code/config. |
lib rm <book-id> |
Delete a book and rebuild the index. |
lib serve [--library <path>] |
Stdio MCP server over the library. |
Library root: --library <path> (or the LIB_HOME env var, default ./library). Data goes
to stdout, diagnostics to stderr. Exit codes: 0 success, 1 runtime error, 2 usage error.
Give Claude your bookshelf
librarian-cli ships a built-in stdio MCP server with 5 read-only tools — list_books,
list_chapters, find, get_chapters, book_info — so Claude can browse the catalog,
search it, and pull chapters under a token budget on its own: deterministic RAG with no
embeddings, no network, and no API keys.
Claude Code:
claude mcp add librarian --env LIB_HOME=$HOME/books -- uvx librarian-cli
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"librarian": {
"command": "uvx",
"args": ["librarian-cli"],
"env": { "LIB_HOME": "/path/to/books" }
}
}
}
Quality
Every book gets a score from five metrics (coverage, structure, garbage, encoding,
dehyphenation): ok (score ≥ 0.90, no hard triggers) — saved silently; review
(0.60 ≤ score < 0.90, or triggers present) — saved with a warning, details via
lib doctor <id>; failed (score < 0.60) — not saved. Scans and password-protected PDFs
honestly fail (OCR and DRM removal are out of scope).
Determinism
The pipeline has no network access, no LLM calls, and no randomness — the same input file
always produces byte-identical output. That makes ingestion reproducible and cacheable, and
it's what makes lib serve's RAG deterministic: no embeddings to drift, no model calls to
vary between runs.
Limitations
- PDF: works well on typographically normal books; complex layouts may land in
review. - DRM is not circumvented; source legality is the user's responsibility.
- Networked filesystems (NFS/SMB) are not supported (the advisory lock isn't reliable there).
- MOBI/DJVU and text-less scans are not supported (v3 candidates: OCR, calibre).
- CLI messages are currently in Russian; English output is planned.
Русская версия
See README.ru.md for the Russian documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file librarian_cli-0.1.0.tar.gz.
File metadata
- Download URL: librarian_cli-0.1.0.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61be35b59d5ff6f803ecf665d95b8f765a6db91a5789770423aa815b446b168c
|
|
| MD5 |
33854119ae04d9e55991c23e917c128f
|
|
| BLAKE2b-256 |
703485829e92eb5813b388983e53850362efeb7e0cbb816bb21815929d871b3f
|
Provenance
The following attestation bundles were made for librarian_cli-0.1.0.tar.gz:
Publisher:
release.yml on Terobyte/librarian-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
librarian_cli-0.1.0.tar.gz -
Subject digest:
61be35b59d5ff6f803ecf665d95b8f765a6db91a5789770423aa815b446b168c - Sigstore transparency entry: 2118002881
- Sigstore integration time:
-
Permalink:
Terobyte/librarian-cli@39aca449d56ca7ed7b7af6e010bfcb86a76c57d8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Terobyte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@39aca449d56ca7ed7b7af6e010bfcb86a76c57d8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file librarian_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: librarian_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5cfc98b24a935a8bcd29b89375ff593f5d81da5d7743274aaf93aa4baf32824
|
|
| MD5 |
4efaaa9038e66af6fdee168b34137192
|
|
| BLAKE2b-256 |
5341011c0e959d07918657c99a8cb8bc04698e57547149d0d472f0c0bda1bdd5
|
Provenance
The following attestation bundles were made for librarian_cli-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Terobyte/librarian-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
librarian_cli-0.1.0-py3-none-any.whl -
Subject digest:
a5cfc98b24a935a8bcd29b89375ff593f5d81da5d7743274aaf93aa4baf32824 - Sigstore transparency entry: 2118002989
- Sigstore integration time:
-
Permalink:
Terobyte/librarian-cli@39aca449d56ca7ed7b7af6e010bfcb86a76c57d8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Terobyte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@39aca449d56ca7ed7b7af6e010bfcb86a76c57d8 -
Trigger Event:
push
-
Statement type: