zlib-mcp

zlib-mcp

An MCP server that lets AI agents search and download books from z-library using the user's own account credentials.

Category
访问服务器

README

zlib-mcp

npm license node Bilibili 微信公众号 中文文档

A stdio MCP server that gives any AI agent tool — Claude Code, Codex CLI, Cursor, Claude Desktop — the ability to search z-library and download books.

Bring your own account. There is no shared backend, no API key, no proxy: the server runs on your machine, talks straight to z-library, and uses your credentials and your quota.

Tools

Tool What it does Needs credentials
zlib_search Search by title / author / ISBN, with format, language and year filters yes
zlib_get_download_url Get a direct download link for one book (no file written) yes
zlib_download Download a book into a directory you configured yes
zlib_limits Check today's remaining download allowance yes
zlib_login One-time helper: exchange email + password for remix credentials no

zlib_download only appears once you set ZLIB_DOWNLOAD_DIR — an MCP server that can write files anywhere by default is not an acceptable default, so you have to name the directory yourself.

Requirements

  • Node.js ≥ 20
  • A z-library account

Setup in 5 minutes

1. Get your credentials

If you already know your remix_userid / remix_userkey, skip ahead. Otherwise add the server with just your email and password (see the config snippets below), then ask your agent to run zlib_login once and put the returned remix_id / remix_key into the config permanently.

You can also run it straight from a terminal:

ZLIB_EMAIL=you@example.com ZLIB_PASSWORD='…' npx zlib-mcp

2. Add the server to your client

Every client takes the same three things: the command npx, the argument zlib-mcp, and an env block.

<details open> <summary><b>Claude Code</b></summary>

claude mcp add zlib \
  --env ZLIB_REMIX_ID=123456 \
  --env ZLIB_REMIX_KEY=your_remix_userkey \
  --env ZLIB_DOWNLOAD_DIR="$HOME/Downloads/books" \
  -- npx -y zlib-mcp

Or edit ~/.claude.json / .mcp.json directly using the JSON below.

</details>

<details> <summary><b>Claude Desktop</b> — <code>claude_desktop_config.json</code></summary>

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "zlib": {
      "command": "npx",
      "args": ["-y", "zlib-mcp"],
      "env": {
        "ZLIB_REMIX_ID": "123456",
        "ZLIB_REMIX_KEY": "your_remix_userkey",
        "ZLIB_DOWNLOAD_DIR": "/Users/you/Downloads/books"
      }
    }
  }
}

</details>

<details> <summary><b>Cursor</b> — <code>.cursor/mcp.json</code> or <code>~/.cursor/mcp.json</code></summary>

{
  "mcpServers": {
    "zlib": {
      "command": "npx",
      "args": ["-y", "zlib-mcp"],
      "env": {
        "ZLIB_REMIX_ID": "123456",
        "ZLIB_REMIX_KEY": "your_remix_userkey",
        "ZLIB_DOWNLOAD_DIR": "/Users/you/Downloads/books"
      }
    }
  }
}

</details>

<details> <summary><b>Codex CLI</b> — <code>~/.codex/config.toml</code></summary>

[mcp_servers.zlib]
command = "npx"
args = ["-y", "zlib-mcp"]

[mcp_servers.zlib.env]
ZLIB_REMIX_ID = "123456"
ZLIB_REMIX_KEY = "your_remix_userkey"
ZLIB_DOWNLOAD_DIR = "/Users/you/Downloads/books"

</details>

3. Try it

Find me Kleppmann's Designing Data-Intensive Applications in epub, then download the first result.

Configuration

Variable Required Default Notes
ZLIB_REMIX_ID one of two — Your remix_userid
ZLIB_REMIX_KEY one of two — Your remix_userkey
ZLIB_EMAIL one of two — Fallback: exchanged for remix credentials on first use
ZLIB_PASSWORD one of two — Fallback, used with ZLIB_EMAIL
ZLIB_HOST no pkuedu.xyz Upstream mirror; change it if you get blocked
ZLIB_DOWNLOAD_DIR no (unset → zlib_download disabled) Where downloads are written
ZLIB_MAX_DOWNLOAD_BYTES no 524288000 (500 MB) Files above this need allow_large: true
ZLIB_TIMEOUT_MS no 20000 Per-request connect timeout
ZLIB_CREDENTIAL_CACHE no 1 Set 0 to never write ~/.zlib-mcp/credentials.json
ZLIB_LOG_LEVEL no info debug / info / warn / error / silent; all logs go to stderr

Credential precedence

  1. ZLIB_REMIX_ID + ZLIB_REMIX_KEY
  2. Cached credentials from a previous ZLIB_EMAIL login (~/.zlib-mcp/credentials.json, mode 600)
  3. ZLIB_EMAIL + ZLIB_PASSWORD → logged in on first tool call, not at startup

The cache exists so a client restart does not trigger a fresh login every time — repeated logins are what makes z-library's anti-abuse system notice you. It stores only the remix id and key; your password is never written to disk, logged, or returned by any tool. On Windows the 600 mode is a no-op (the OS ignores POSIX permissions) — set ZLIB_CREDENTIAL_CACHE=0 if that matters to you.

If nothing is configured the server still starts and lists its tools; calling one returns instructions on what to set. It does not crash — a crashed MCP server just shows up as "unavailable" in most clients, with nothing to debug.

Troubleshooting

"Upstream host … appears to be blocking this request" — the mirror is behind an anti-bot wall. Set ZLIB_HOST to another one and restart the client. Known mirrors change often; 1lib.sk is currently blocked, pkuedu.xyz currently works. Anything that serves the same /eapi/* endpoints will do.

"z-library rejected the current credentials" — your remix key expired. Run zlib_login again and update the config. If you use the email/password fallback, delete ~/.zlib-mcp/credentials.json to force a fresh login.

"download quota reached" — free accounts get a small number of downloads per day. zlib_limits shows the counter; it resets on z-library's side at midnight UTC.

Nothing appears in the client — check the client's MCP log; this server writes all diagnostics to stderr. ZLIB_LOG_LEVEL=debug makes it chattier.

zlib_download is missing — you did not set ZLIB_DOWNLOAD_DIR. That is by design.

Development

pnpm install
pnpm check      # format check → lint → typecheck → tests
pnpm build

To try an unreleased version straight from git, point your client's command/args at npx / ["-y", "github:shiyi-0x7f/zlib-mcp"] — the prepare script builds it on install.

Tests never hit the real upstream — fetch is stubbed everywhere.

Legal

This tool only provides API access to your own z-library account. It hosts nothing, distributes nothing, and ships no copyrighted content. Making sure your use of it is lawful where you are is on you. Your account, your quota, your risk — an account banned for abuse is yours to lose.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选