Skip to main content
Glama
calibre-mcp

calibre-mcp

by ZehuiTIAN

calibre-mcp

一个 MCP 服务器,让 AI 助手 (Claude Code、Claude Desktop、Cursor 等)能够读写你本地的 Calibre 电子书库。

在聊天中即可搜索书库、浏览最近添加的书籍、自动查重导入新电子书,以及管理"收件箱"文件夹。

  • 常规设置下零配置:calibredb 可执行文件和 Calibre 图形界面正在使用的书库会在 macOS、Windows 和 Linux 上自动发现。

  • 与语言环境无关:所有读取都通过 calibredb --for-machine(JSON)进行,因此结果永远不会取决于你的 Calibre 界面语言。

  • 默认安全:查重依赖 Calibre 本身——书库中已存在相同"书名+作者"的书籍会被跳过,绝不会重复导入。

工具

工具

描述

library_info

书库路径、书籍数量、Calibre 版本

search_books

完整的 calibre 查询语言搜索(author:asimov、title:"i robot"、tags:python 等)

list_books

浏览书库,默认按最近添加排序

add_books

导入电子书文件或整个目录,带查重功能

import_inbox

导入收件箱文件夹中的所有内容并归档

Related MCP server: Calibre MCP Server

系统要求

  • Calibre(任何附带 calibredb 的版本;已在 9.x 上测试)

  • Python ≥ 3.10

安装

pipx(推荐)

pipx install calibre-mcp

uv

uv tool install calibre-mcp

pip

pip install calibre-mcp

从源码安装

git clone https://github.com/ZehuiTIAN/calibre-mcp.git
cd calibre-mcp
pip install -e ".[dev]"     # dev extras add pytest + ruff

配置

常规设置下一切都是可选的;每个值都可以通过环境变量固定。

变量

含义

默认值

CALIBRE_LIBRARY_PATH

要使用的书库目录

你的 Calibre 图形界面使用的书库(来自 gui.json 的最常用书库,否则为默认书库)

CALIBREDB_PATH

calibredb 可执行文件的路径

PATH 中的 calibredb,然后是平台安装位置(macOS 应用包、C:\Program Files\Calibre2\)

CALIBRE_INBOX_DIR

import_inbox 的收件文件夹

已禁用(使用时会报错)

CALIBREDB_TIMEOUT

calibredb 调用超时前的秒数

300

注册到 Claude Code

claude mcp add calibre-mcp -- calibre-mcp

或添加到 ~/.claude.json → mcpServers(用户范围):

"calibre_mcp": {
  "type": "stdio",
  "command": "calibre-mcp",
  "args": [],
  "env": {
    "CALIBRE_LIBRARY_PATH": "/path/to/your/library",
    "CALIBRE_INBOX_DIR": "/path/to/your/inbox"
  }
}

注册到 Claude Desktop / Cursor

将相同的 JSON 块添加到 claude_desktop_config.json(Claude Desktop)或 Cursor 的 MCP 设置中的 MCP 服务器部分。

收件箱工作流

收件文件夹为手动下载的书籍提供了一个便捷的"查找 → 放入 → 归档"循环:

  1. 将 CALIBRE_INBOX_DIR 指向一个文件夹,例如 ~/Downloads/Calibre-Inbox。

  2. 将电子书下载到该文件夹。

  3. 让助手运行 import_inbox。

每个文件都会添加到书库;成功添加的文件和重复文件归档到 imported/YYYY-MM/,失败的文件归档到 failed/——收件箱本身保持整洁,任何文件都不会被覆盖(名称冲突会添加 -1、-2 等后缀)。

支持的扩展名:.epub .pdf .mobi .azw .azw3 .djvu .cbz .cbr .fb2 .txt .md .docx .rtf .lit .prc .pdb .chm .htmlz。

注意事项

  • 数据库锁:当 Calibre 图形界面打开着书库时,写入操作(add_books、import_inbox)可能因数据库锁错误而失败。只读工具仍可正常工作。导入前请关闭 Calibre(或切换到另一个书库)。

  • 大型书库:add_books/import_inbox 会在每次添加前后对全部书籍 ID 做快照,实际运行很快,但每次导入的复杂度为 O(书籍数量)。

  • 此工具只整理你的书库。它不包含搜索或下载功能;请仅用于你有权持有的内容。

开发

pip install -e ".[dev]"
ruff check .
pytest -m "not integration"      # unit tests, run anywhere
pytest                           # + integration tests (need local calibre)

集成测试会在 /tmp 下创建临时书库,绝不会触碰你的真实书库。

许可证

MIT — 参见 LICENSE。


中文速览

把本地 Calibre 书库接给 Claude/Cursor 等 AI 助手的 MCP 服务器:五个工具 (library_info / search_books / list_books / add_books / import_inbox), 自动发现 calibredb 和书库位置,全平台(Windows/macOS/Linux)开箱即用。

pipx install calibre-mcp
claude mcp add calibre-mcp -- calibre-mcp

导入时自动查重(书名+作者相同的书不会被重复导入);配合 CALIBRE_INBOX_DIR 收件箱目录,把下载的书丢进去、说一句"导入收件箱"即可 归档,处理完的文件自动归类到 imported/ 或 failed/。

注意:Calibre 桌面程序打开着同一书库时,写入操作可能因数据库锁失败, 导入前先关闭 Calibre。

Available Tools

11 tools
add_booksA

Import ebook files (or directories of ebooks) into the library.

Books whose title + author are already in the library are skipped by calibre and reported as "duplicate". The Calibre GUI must not hold the library open while adding.

Args: paths: Absolute paths to ebook files or folders containing ebooks.

Inputs: paths (required). Returns: object

build_indexA

Index book contents for full-text search (one-time, cached).

Converts each book's text with calibre's converter and stores it in a local SQLite FTS5 index kept outside the library. Only books that are not indexed yet are processed; an initial run over a whole library can take several minutes.

Args: book_ids: Optional list of book ids to index; default: all books that are not indexed yet. limit: Optional cap on how many books to index in this call.

Inputs: limit, book_ids. Returns: object

detect_scanned_booksA

Find library books whose PDF has no usable text layer (scanned pages).

Such books stay unsearchable until OCR'd with ocr_book. Requires the ocr extra (pip install 'calibre-mcp[ocr]'); no API key needed.

Args: limit: Maximum number of scanned books to report (1-200).

Inputs: limit. Returns: object

import_inboxA

Import every ebook file in the configured inbox folder into the library.

Requires the CALIBRE_INBOX_DIR environment variable. Successfully added files and duplicates are moved to <inbox>/imported/YYYY-MM/; files that fail to import are moved to <inbox>/failed/ for inspection.

Inputs: no named parameters. Returns: object

library_infoA

Show the active library: its path on disk, number of books, calibre version.

Inputs: no named parameters. Returns: object

list_booksA

Browse books in the library; defaults to most recently added first.

Args: limit: Maximum number of results (1-200, default 20). sort_by: calibre field to sort by, e.g. id, title, authors, timestamp. order: "desc" (default) or "asc". search: Optional calibre search expression to filter the listing.

Inputs: limit, order, search, sort_by. Returns: object

ocr_bookA

OCR a scanned PDF via the configured cloud provider and index the text.

Detection → page rendering → provider transcription → cache → full-text index → (by default) pandoc re-typeset EPUB attached to the book's existing record. Books with a usable text layer are left untouched.

Configuration: CALIBRE_OCR_PROVIDER (default "anthropic"), CALIBRE_OCR_API_KEY, CALIBRE_OCR_MODEL, CALIBRE_OCR_BASE_URL, CALIBRE_OCR_MAX_PAGES.

Args: book_id: Book whose PDF format should be OCR'd. typeset: Also build a re-typeset EPUB with pandoc (default True). import_format: Attach the EPUB to the book record (default True).

Inputs: book_id (required), typeset, import_format. Returns: object

ocr_scanned_booksA

OCR all scanned-PDF books in the library, in resumable batches.

Detects scanned books, skips any that already have OCR output cached, and runs the full ocr_book pipeline (OCR → index → optional re-typeset EPUB) on up to limit remaining books. Repeat the call to work through the whole library; per-batch caching makes interruptions safe.

Args: limit: Maximum books to OCR in this call (1-100, default 10). typeset: Also build re-typeset EPUBs with pandoc (default True). import_format: Attach the EPUBs to book records (default True).

Inputs: limit, typeset, import_format. Returns: object

read_bookA

Read a page of a book's plain text, converted on demand by calibre.

The first call converts the book (a copy in a cache directory — the library is never modified); later calls reuse the cache. Returns the chunk plus next_offset for paging and total_chars for context.

Args: book_id: The book's id (find it with search_books). offset: Character offset to start reading from (0 = beginning). limit: Maximum characters to return (1-40000, default 12000).

Inputs: book_id (required), limit, offset. Returns: object

search_booksA

Search the library with calibre's query language.

Args: query: A calibre search expression, e.g. author:asimov, title:"i robot", tags:python. An empty string matches everything. limit: Maximum number of results (1-200, default 20).

Inputs: query (required), limit. Returns: object

search_in_bookA

Full-text search inside book contents, with match snippets for quoting.

Searches the local text index; books must be indexed first with build_index (a one-time, cached step). Matching is substring-based, so Chinese and English queries both work without word segmentation.

Args: query: Text to find inside book contents. book_id: Optional book id to restrict the search to a single book. limit: Maximum number of matches to return (1-100, default 20).

Inputs: query (required), limit, book_id. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 11 tools

    Disambiguation4/5

    Most tools target distinct actions: metadata search, browsing, full-text search, reading, and OCR are clearly separated. Minor overlap exists between list_books (which accepts a search filter) and search_books, and between ocr_scanned_books and ocr_book, but descriptions clarify the batch-vs-single distinction.

    Naming Consistency4/5

    The majority of tools follow a clear verb_noun pattern like search_books, add_books, build_index, and read_book. A few deviations stand out: library_info uses noun_info, search_in_book uses a preposition, and ocr_book/ocr_scanned_books use an acronym as the verb, but the overall style remains predictable.

    Tool Count5/5

    Eleven tools is a well-scoped size for a Calibre-focused server covering library browsing, metadata search, book import, reading, full-text search, and OCR. Each tool addresses a distinct workflow without feeling bloated or redundant.

    Completeness4/5

    The toolset covers the core workflows thoroughly: discovering, searching, adding, reading, indexing, and OCR-ing books. Obvious gaps like metadata editing, book deletion, or retrieving original format files are absent, but they appear to be outside the server's intended reading/OCR-oriented scope.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides AI agents with research capabilities for local Calibre e-book libraries, including fulltext search across titles, ISBNs, and comments, plus structured excerpt retrieval from books.
      2
      GPL 3.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables searching, reading, and managing a Calibre ebook library through natural language, with features like metadata search, full-text search, content extraction, and library management.
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables read-only search, browsing, and metadata retrieval from a local Calibre e-book library using natural language queries.
      MIT