Skip to main content

ZLibrary2KindleSkill

Search Z-Library books and send them to your Kindle via email. Supports both CLI and Claude Code MCP mode.

Features:

  • Search Z-Library by title, author, ISBN
  • Download books (EPUB preferred, PDF fallback)
  • Send directly to Kindle email
  • Session cookies persisted — login once, reuse automatically
  • Two-factor auth supported via app password

Language: English | 中文

Prerequisites

  • ZLibrary account — email and password
  • Kindle email whitelisted — Add sender in Amazon account settings
  • Gmail App Password — Required for Gmail SMTP with 2FA

Setup

1. Install

pip install -e .

2. Configure credentials

Method A — ~/.zshrc (recommended)

Add to ~/.zshrc:

export ZLIBRARY_EMAIL="your@email.com"
export ZLIBRARY_PASSWORD="your-password"
export KINDLE_EMAIL="your-name@kindle.com"
export SENDER_EMAIL="your@email.com"
export SENDER_PASSWORD="xxxx xxxx xxxx xxxx"  # Gmail App Password

Then source ~/.zshrc.

Method B — mcp.json env

Edit mcp.json and fill in the env block.

Security: Method A keeps credentials out of your project directory. Method B stores them in plaintext.

Step-by-Step Guide

Quick Start

# 1. Login (once)
python -m src.cli login

# 2. Search
python -m src.cli search "Mo Yan"

# 3. Download (copy book_id from search results)
python -m src.cli download <book_id>

# 4. Send to Kindle
python -m src.cli send /tmp/zlibrary2kindle/downloads/book.epub "Book Title"

CLI Reference

Command Description
python -m src.cli login Authenticate to ZLibrary. Session is saved automatically.
python -m src.cli search "query" --limit 10 Search books. Returns [book_id] title | author.
python -m src.cli download <book_id> Download book to /tmp/zlibrary2kindle/downloads/.
python -m src.cli send <file> "Title" Email file to Kindle.

Note: If zlib2k-cli command is not found after install, use python -m src.cli instead.

Claude Code Skill

Load as a Claude Code local MCP server for AI-assisted book search and sending:

// mcp.json
{
  "mcpServers": {
    "zlibrary2kindle": {
      "command": "python",
      "args": ["-m", "src.server"]
    }
  }
}

Then you can ask Claude in natural language:

帮我下载莫言的书发送到Kindle
Search for books by Yu Hua and send them to my Kindle

Claude Code will automatically use the zlibrary_login, zlibrary_search, zlibrary_download, and kindle_send_email tools to complete the task.

Architecture

src/
├── mcp_tools/          # MCP tool definitions
│   ├── zlibrary_login.py
│   ├── zlibrary_search.py
│   ├── zlibrary_download.py
│   └── kindle_send_email.py
├── services/           # Business logic
│   ├── playwright_service.py    # Browser lifecycle
│   ├── zlibrary_service.py      # ZLibrary flows
│   └── email_service.py        # SMTP sending
├── server.py           # MCP server entry
└── cli.py             # CLI entry point

Troubleshooting

"Session expired" or download fails : Run python -m src.cli login again to refresh session cookies.

Login page changed / Cloudflare challenge : Try python -m src.cli login --no-headless to see the browser and solve CAPTCHA manually.

Email too large for Kindle : Google/Gmail limits attachments to ~25MB. PDFs often exceed this. Try searching for EPUB format instead.

PDF Chinese fonts missing on Kindle : EPUB format renders Chinese better on Kindle. Download EPUB when available.

Metadata

Release files for zlibrary2kindle 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zlibrary2kindle 0.1.1
File Size Uploaded
zlibrary2kindle-0.1.1.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zlibrary2kindle 0.1.1
File Interpreter ABI Platform
zlibrary2kindle-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 37.0 kB

Release files / zlibrary2kindle-0.1.1.tar.gz

Download URL zlibrary2kindle-0.1.1.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
313562fe1151589dde439bc35ac3f17cbccd1fa3182637f71c23e0b765c9fc3b
BLAKE2b-256 checksum
How to use checksums
45006d2885867f06d7fb484c280f3ace18ff6d0bc2ab5a734f6fb7b0ac15d0d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / zlibrary2kindle-0.1.1-py3-none-any.whl

Download URL zlibrary2kindle-0.1.1-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ad534828d2126b5ebd168c251cd7ff1ac7f9778b7b78a914ab79428d0a6278d
BLAKE2b-256 checksum
How to use checksums
348014acc3e8d6d42bf39cc7e3741dc79eb45e21dabebbd580c8625f5942bea2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page