電子書籍をクリーンなMarkdown形式のチャプターに変換し、AIクライアントによる決定論的なRAGと引用検証を可能にします。
別名 Terobyte/librarian-cli, librarian-cli
- スター
- 2
- ツール
- —
- ダウンロード数(30日間)
- 169
- 最新バージョン
- 0.1.1
- 最終コミット
- 2026年9月1日
- ライセンス
- MIT
Librarian MCPとは
LibrarianはMCPサーバーです。 電子書籍をクリーンなMarkdown形式のチャプターに変換し、AIクライアントによる決定論的なRAGと引用検証を可能にします。.
プロジェクトのREADMEから生成された概要
Librarian MCP server について
Librarianは、AIクライアントを利用する開発者が、決定論的なRAGを実現するために電子書籍をクリーンなMarkdown形式のチャプターへと変換することを可能にします。EPUB、FB2、DOCX、テキストレイヤー付きPDFなどの様々なフォーマットを、正確なトークン数を持つ構造化されたチャプターライブラリへと変換します。このプロセスは、ネットワークアクセス、埋め込み、APIキーを一切使用せず、完全にローカルで実行されるため、同じ入力に対して常にバイト単位で同一の出力が生成されることが保証されます。
ユーザーはこのMCP serverを、stdio MCP接続を介してClaude DesktopやClaude Codeに接続できます。ライブラリのパスを設定すると、サーバーはlist_books、find、verify_quoteを含む6つの読み取り専用ツールを提供します。これらのツールを使用することで、AIはカタログの閲覧、BM25を用いた全文検索、および定義されたトークン予算内での特定のチャプターの取得が可能になります。これは、AIモデルがハルシネーションを防ぐために、自身の引用を元のソーステキストと照合して検証できるように設計されています。
できること
- 1電子書籍ライブラリの検索ローカルコレクション内のすべてのタイトルおよび著者に対して全文検索を実行します。
- 2トークン制限内でのテキスト取得特定のトークン予算を超えない範囲で、書籍から連続したチャプターを取得します。
- 3書籍品質の監査取り込まれた電子書籍ファイルの構造やエンコーディングの品質を評価します。
プロジェクトの README から作成されています。すべてのユースケースは、その引用と照らし合わせて確認されています。
Librarian MCPのインストール方法
フォーマット検証日 2026年11月10日Cursor に追加Gooseに追加Claude CodeにLibrarian MCPをインストール
$ claude mcp add librarian-cli -- uvx librarian-cliCursorにLibrarian MCPをインストール
~/.cursor/mcp.json
{
"mcpServers": {
"librarian-cli": {
"command": "uvx",
"args": [
"librarian-cli"
]
}
}
}VS CodeにLibrarian MCPをインストール
.vscode/mcp.json
{
"servers": {
"librarian-cli": {
"type": "stdio",
"command": "uvx",
"args": [
"librarian-cli"
]
}
}
}VS Code CLIにLibrarian MCPをインストール
$ code --add-mcp '{"name":"librarian-cli","type":"stdio","command":"uvx","args":["librarian-cli"]}'Claude DesktopにLibrarian MCPをインストール
claude_desktop_config.json
{
"mcpServers": {
"librarian-cli": {
"command": "uvx",
"args": [
"librarian-cli"
]
}
}
}CodexにLibrarian MCPをインストール
$ codex mcp add librarian-cli -- uvx librarian-cliCodex config.tomlにLibrarian MCPをインストール
~/.codex/config.toml
[mcp_servers.librarian-cli] command = "uvx" args = ["librarian-cli"]
Gemini CLIにLibrarian MCPをインストール
$ gemini mcp add -s user librarian-cli uvx -- librarian-cliGemini settings.jsonにLibrarian MCPをインストール
~/.gemini/settings.json
{
"mcpServers": {
"librarian-cli": {
"command": "uvx",
"args": [
"librarian-cli"
]
}
}
}設定
LIB_HOMELibrary root directory (default ./library)
| 名前 | 説明 | 種類 |
|---|---|---|
| LIB_HOME | Library root directory (default ./library) |
自動チェック
実行日 2026年11月14日完全なレポート →自動チェックに合格しました。これはセキュリティ監査ではありません。コードを読み、サーバーに必要最小限のアクセス権を与えてください。 チェックの仕組み
- ソースリポジトリがリンクされており、アクセス可能terobyte/librarian-cli is public and reachablegithub.com/terobyte/librarian-cli ↗合格
- パッケージがこのリポジトリをソースとして指定librarian-cli names terobyte/librarian-cli as sourcepypi.org/project/librarian-cli/ ↗合格
- ビルドの来歴 (Sigstore 証明)Sigstore attestation for librarian-clipypi.org/project/librarian-cli/ ↗合格
- オープンソースライセンス (OSI)MITspdx.org/licenses/MIT.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit or release 2026-09-01github.com/terobyte/librarian-cli ↗合格
- OpenSSF Scorecard未チェック
- パッケージ名が有名なパッケージに酷似していないNo popular package one edit away from librarian-cli合格
- パッケージおよびその依存関係に重大な勧告なし70 resolved dependencies checked; no critical advisoryosv.dev ↗合格
- モデルへの隠れた指示がない0 tool descriptions and the README read; no override phrases, credential paths or hidden characters合格
- 破壊的なツールがラベル付けされている未チェック
- リモートエンドポイントが MCP ハンドシェイクに応答未チェック
README
GitHubで見る📚 librarian
Turn any ebook into clean, token-counted Markdown chapters — let Claude read your bookshelf over MCP and catch it misquoting your books. 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. |
lib verify "quote" [--book ID] [--json] [--limit N] |
Check a quote against one book or attribute it across 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 6 read-only tools — list_books,
list_chapters, find, get_chapters, book_info, verify_quote — so Claude can browse
the catalog, search it, pull chapters under a token budget, and check its own quotes against
the source 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" }
}
}
}
Verify quotes
An MCP server that catches Claude misquoting your books.
lib verify "quote" checks whether a quote actually appears in your library, verbatim —
punctuation, case, ё/е, and markdown formatting don't count. Two modes:
- Book mode (
--book <id>): full scan of one book — "does this book actually say this?" Works without the search index. - Shelf mode (no
--book): attribution across the whole library via FTS5 candidates — "which book is this from?" The quote needs at least 5 significant words (stop words don't count), or the check is skipped withverdict: null.
lib verify "Рукописи не горят" --book bulgakov-master-i-margarita
lib verify "рукописи не горят никогда"
| verdict | meaning |
|---|---|
exact |
matches after normalization (punctuation/case/ё/typography don't count) |
close |
similarity ≥ 0.95 — near-exact, differences shown as a word-diff |
distorted |
similarity ≥ 0.75 — the right place, but the quote is misremembered |
not_found |
similarity < 0.75 — nothing like it in the book/library |
null |
check wasn't run: empty quote, or a short quote without --book |
Exit codes (grep-style semantics, a deliberate departure from the project's usual
"1 = runtime error" — see docs/MILESTONES.md deviation 38):
| exit | case | stdout |
|---|---|---|
| 0 | exact / close — quote confirmed |
full report / JSON |
| 1 | distorted / not_found — not confirmed |
full report / JSON |
| 1 | runtime error (unknown book id, no search index, locked index) | empty |
| 2 | usage error: empty/short quote (verdict: null), --limit < 1 |
empty (message on stderr) |
Script discriminator: exit 1 with non-empty stdout means "checked, not confirmed"; exit
1 with empty stdout means an error (diagnostics went to stderr instead). Exit 0
includes close — a strict CI gate must check verdict == "exact" in the --json
output, not the exit code alone.
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.
lib verify: quotes spanning a chapter boundary are not supported (v1) — the best you'll get isdistortedon one half.lib verify:closeon a single-word replacement is realistic from ~150 characters of quote; shorter quotes with a replaced word honestly land indistorted— a third of a three-word quote really is a distortion.lib verifyshelf mode (no--book) needs the FTS5 search index; book mode (--book <id>) works without it in the CLI.lib serveas a whole still requires FTS5 — it syncs the index at startup regardless of which tool gets called.lib verifyin book mode scans the whole chapter text in pure Python; a long book can take a few seconds of CPU. The MCP tool runs it in a worker thread so it doesn't block the rest of the server.
Русская версия
See README.ru.md for the Russian documentation.
Librarian MCPのよくある質問
Librarian MCPをClaude Codeに追加するには
ターミナルでclaude mcp add librarian-cli -- uvx librarian-cliを実行します。すべてのプロジェクトで利用するには--scope userを追加します。
Librarian MCPをCursorに追加するには
~/.cursor/mcp.jsonを開き、上記のインストールセクションに示すCursor設定を使ってmcpServersの下にサーバーを追加します。
Librarianはインターネット接続やAPIキーを必要としますか?
いいえ、完全にオフラインで動作するため、ネットワークアクセス、LLM呼び出し、APIキーは一切不要です。
対応している電子書籍のフォーマットは何ですか?
FB2、EPUB、DOCX、HTML、TXT/MD、およびテキストレイヤー付きPDFに対応しています。
引用検証はどのように機能しますか?
ライブラリ内に引用文がそのまま存在するかを確認し、exact(完全一致)、close(近似)、distorted(歪曲)、not found(未検出)といった判定結果を提供します。
出力は一貫していますか?
はい、パイプラインは決定論的であるため、同じ入力に対しては常にバイト単位で同一の出力が生成されます。