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.1.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.1-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zlibrary2kindle-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 313562fe1151589dde439bc35ac3f17cbccd1fa3182637f71c23e0b765c9fc3b
MD5 7ce9898e1fc4eda6bcd57f4c355eedc3
BLAKE2b-256 45006d2885867f06d7fb484c280f3ace18ff6d0bc2ab5a734f6fb7b0ac15d0d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zlibrary2kindle-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ad534828d2126b5ebd168c251cd7ff1ac7f9778b7b78a914ab79428d0a6278d
MD5 2cac6f0a242a8caa34e2c290a792f9f0
BLAKE2b-256 348014acc3e8d6d42bf39cc7e3741dc79eb45e21dabebbd580c8625f5942bea2

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