Calibre is the world's most popular e-book management application. This CLI harness wraps the real Calibre tools (calibredb, ebook-convert, ebook-meta) to give AI agents and scripts a clean, structured interface for library management, metadata editing, and format conversion.
All heavy lifting is done by the actual Calibre binaries:
| Task | Tool | Command Pattern |
|---|---|---|
| Library operations | calibredb |
calibredb --with-library <lib> <cmd> |
| Format conversion | ebook-convert |
ebook-convert input.epub output.mobi |
| File metadata | ebook-meta |
ebook-meta book.epub --field value |
The CLI harness is a stateful wrapper — it tracks the library path in a session file and passes it to every calibredb invocation. It never reimplements library logic.
~/Calibre Library/
├── metadata.db # SQLite database (all metadata)
├── Author Name (ID)/
│ ├── Book Title (ID)/
│ │ ├── cover.jpg # Cover image
│ │ ├── metadata.opf # OPF metadata file
│ │ ├── Title - Author.epub
│ │ └── Title - Author.mobi
The CLI maintains a JSON session file at ~/.cli-anything-calibre/session.json:
{
"library_path": "/path/to/Calibre Library",
"last_command": "list",
"filters": {}
}connect <path>— Set active library pathinfo— Show library stats (book count, formats, size)check— Verify library integrity
list— List books with filtering and sortingsearch <query>— Search using Calibre query languageadd <files>— Add book files to libraryremove <ids>— Remove books (move to trash)show <id>— Show full metadata for a bookexport <ids>— Export books to directory
set <id> <field> <value>— Set a metadata fieldget <id> [field]— Get metadata (all or specific field)embed <ids>— Embed metadata into book files
list <id>— List available formats for a bookadd <id> <file>— Add a format to a bookremove <id> <fmt>— Remove a format from a bookconvert <id> <input_fmt> <output_fmt>— Convert book format
list— List all custom columnsadd <label> <name> <type>— Create custom columnremove <label>— Delete custom columnset <id> <label> <value>— Set custom field value
generate <output>— Generate a catalog of the library
Used with books search and books list --search:
author:asimov # Author contains "asimov"
title:"Foundation" # Title phrase
tags:fiction # Tag match
rating:>3 # Rating greater than 3
series:"Foundation" # Series match
pubdate:[2020-01-01,2021-12-31] # Date range
identifiers:isbn:1234567890 # Specific identifier
has:cover # Has cover image
not:tags:fiction # Negation
author:asimov and tags:scifi # Boolean AND
| Field | Type | Description |
|---|---|---|
title |
text | Book title |
authors |
text | Author names (&-separated) |
tags |
text | Comma-separated tags |
series |
text | Series name |
series_index |
float | Position in series |
rating |
float | Rating 1-5 |
publisher |
text | Publisher name |
pubdate |
datetime | Publication date |
comments |
text | Description/comments |
cover |
path | Path to cover image |
languages |
text | Language codes |
identifiers |
text | ISBN, ASIN, etc. (type:value) |
Input: EPUB, MOBI, AZW, AZW3, PDF, HTML, DOCX, ODT, FB2, TXT, RTF, LIT, and more
Output (conversion): EPUB, MOBI, AZW3, PDF, HTML, DOCX, TXT, and more
# Calibre must be installed (hard dependency)
sudo apt-get install calibre # Debian/Ubuntu
brew install --cask calibre # macOS
# Or download from: https://calibre-ebook.com/download
# Verify tools are in PATH:
which calibredb
which ebook-convert
which ebook-meta- Unit tests: synthetic CLI argument parsing, query building, JSON output
- E2E tests with
calibredb: real library operations, real output verification - E2E tests with
ebook-convert: real format conversion, output file validation - Subprocess tests via
_resolve_cli("cli-anything-calibre")
cli-anything-calibre library connect ~/my-books
cli-anything-calibre books add *.epub
cli-anything-calibre books search "not:tags:read" --jsoncli-anything-calibre formats convert 42 EPUB MOBIcli-anything-calibre meta set 42 series "Foundation"
cli-anything-calibre meta set 42 series_index 1
cli-anything-calibre meta set 42 tags "scifi,classic"