Skip to main content

Local MCP to search ZLibrary, download books, and send to Kindle

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zlibrary2kindle-0.1.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zlibrary2kindle-0.1.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file zlibrary2kindle-0.1.0.tar.gz.

File metadata

  • Download URL: zlibrary2kindle-0.1.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for zlibrary2kindle-0.1.0.tar.gz
Algorithm Hash digest
SHA256 03a8a540646ddc9511b736b4f44b7194f1f481693156fcaabeb41aa5799247e5
MD5 5c2ff7021d3b4eb21c389a0b8d3eaa0f
BLAKE2b-256 ec635188badd2253206b8b0e6673365a20eba5f277074697d263f0eb43443fe9

See more details on using hashes here.

File details

Details for the file zlibrary2kindle-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zlibrary2kindle-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for zlibrary2kindle-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1ed0fd0395fc5040e66c590c881d6bb58cb308d5b79886ab5f57763938fe313
MD5 df25af0302faa750ef271bccd35e6d68
BLAKE2b-256 7855a6aa978b61942ead9164ce685bfb8c85bddae85b37e3d1dbdef8e21b99d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page