Skip to main content
Glama

cwa-book-mcp

通过 MCP 搜索 CWA 和 Z-Library,把经过校验的 EPUB/PDF 原文件链接交给 Agent,并默认自动加入 CWA。CWA 负责持久入库、转换和去重。

Node.js + TypeScript,单进程,stdio MCP,npm 分发。推荐 Node.js 24 LTS,最低 22.19;无需本项目 Docker 容器。

0.3.0 新增 download_book:默认下载并入库,支持仅下载和稍后入库。 当前发布进度见验证结果。支持本地进程的 MCP 客户端可使用:

npm 安装入口:npx -y cwa-book-mcp@latest,或导入下方配置。

{
  "mcpServers": {
    "cwa-books": {
      "command": "npx",
      "args": ["-y", "cwa-book-mcp@latest"],
      "env": {
        "CWA_BASE_URL": "http://localhost:8083",
        "CWA_USERNAME": "<CWA_USER>",
        "CWA_PASSWORD": "<CWA_PASSWORD>"
      }
    }
  }
}

写入默认关闭。确认 CWA 上传权限、转换与重复处理设置后,再启用 CWA_WRITE_ENABLED=true。书源是可选配置;仅配置 CWA 即可搜索、读取书库。

启用 Z-Library 只需在 env 中增加 ZLIBRARY_EMAIL 和 ZLIBRARY_PASSWORD,或使用已有会话 ZLIBRARY_USER_ID / ZLIBRARY_USER_KEY。程序自动更新、探测和切换入口,自动接受认证响应给出的公网 HTTPS 下载地址,无需维护域名或 CDN 列表。

手机与网页客户端通过远端 MCPHub 使用此进程。书源原文件交付和自动入库沿用现有出站网络与 CWA 地址,无需新增端口、CF 隧道路由或 PUBLIC_BASE_URL。Agent 需要具备将 HTTP 响应保存成文件并读取的工具;仅返回链接不代表已保存。不同客户端的 JSON 格式详见配置与接入。

使用:search_books 选定 Z 候选 → download_book 创建任务 → get_task 的 download.status 为 available → get_download_url → Agent 下载读取。默认复用 MCP 校验时的临时文件自动上传 CWA;仅下载传 save_to_cwa:false,缓存有效时可 collect。认证和常规文件校验均在 MCP 内部完成,入库进度单独报告。

六个工具:search_books、download_book、acquire_book、upload_book、get_task、get_download_url。acquire_book 保留书库获取/转换流程。CWA 独有文件或转换结果仍需客户端 CWA 认证或可达的显式签名网关;不会自动换成另一书源版本。upload_book 本地附件 PUT 也需可达的文件入口。文件不通过 MCP 消息传输。

开发:npm ci → npm run check → npm run build。从当前仓库启动使用 node dist/cli.js,验收打包使用 npm run test:package。

当前方案与进度 · 配置 · 接口契约 · 验证结果

Available Tools

6 tools
acquire_bookA
Idempotent

start 用 request_id、candidate_id、required_format 创建持久任务。retry 只核对已提交任务,不重新上传。resolve 用 task_id/candidate_id 明确选择 CWA 匹配,提交后的元数据差异可通过重新搜索再选择解决,语言仍须一致。cancel 不删除 CWA 记录。

Inputs: action, task_id, request_id, candidate_id, +1 more. Returns: object

download_bookA
Idempotent

从显式选择的 Z 候选下载 EPUB/PDF 原文件并在 MCP 内校验。start 需要 request_id、candidate_id、required_format,默认 save_to_cwa:true,将同一文件自动交给 CWA;仅下载用 false。get_task.download.status 为 available 后可用 get_download_url 获取无需账号认证的书源链接,由 Agent 的 HTTP 工具保存并读取。collection 独立报告入库结果。collect 用 task_id 将未过期缓存补入 CWA;retry/cancel 使用 task_id。取票不明或链接过期不自动重新消耗额度。不交付 CWA 转换后的文件。

Inputs: action, task_id, request_id, save_to_cwa, +2 more. Returns: object

get_download_urlA
Read-only

download_book 任务默认返回已在 MCP 内验证的书源原文件链接 delivery:source,无需客户端账号认证,可在 CWA 入库完成前获取;status:link_issued 仅表示链接提供,Agent 仍需 HTTP 保存并读取文件。重复取链接不重新取票,expires_at 为可识别的上游到期时间(未知为 null),available_until 同时受本地复用窗口与上游到期约束。其他任务默认返回需要 CWA Basic 认证的 OPDS 链接;delivery:gateway 显式取得限时签名 GET,需要可达的本程序文件入口。verification 仅记录服务端观察,无需客户端重复校验。

Inputs: task_id (required), delivery. Returns: object

get_taskB
Read-only

查询持久任务状态。ready 只表示 CWA 目标格式已验证;download_book 的 download.status:available 独立表示原文件已校验,可取链接,collection 报告入库进度。都不表示 Agent 已保存文件。needs_review 时选择 choices,已提交任务也可重新搜索 CWA 后 resolve。blocked 且有 waiting_for 时先处理关联任务;修复后用 retry 核对。

Inputs: task_id (required). Returns: object

search_booksB
Read-only

搜索书库与配置的书源。默认优先 CWA 中文、书源中文、CWA 其他、书源其他。partial 或 warnings 表示不能断言无结果;使用 next_cursor 继续。

Inputs: query (required), limit, author, cursor, +2 more. Returns: object

upload_bookA
Idempotent

prepare 用 request_id、title、filename、size_bytes、required_format 准备上传。文件真实元数据应与 title/authors/language 对应。按返回链接 PUT 完整文件;refresh_ticket 用 task_id 更新授权。禁止通过 MCP 传文件或任意服务端路径。

Inputs: title, action, sha256, authors, +6 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 6 tools

    Disambiguation3/5

    download_book and acquire_book overlap heavily — both take request_id, candidate_id, and required_format to create persistent tasks, and both expose retry/cancel semantics, so an agent could easily misselect between fetching the raw original versus the CWA-matched/converted copy. get_download_url and get_task are related status/retrieval tools but are more clearly separated by their resource. The distinctions exist but require close reading of dense descriptions.

    Naming Consistency5/5

    All six tools follow a consistent verb_noun snake_case pattern: search_books, acquire_book, download_book, upload_book, get_task, get_download_url. The convention is predictable and uniform throughout, with no style mixing.

    Tool Count5/5

    Six tools is well-scoped for a book-acquisition and library-management server. Sub-operations (retry, cancel, resolve, collect, prepare, refresh_ticket) are folded into action parameters rather than exploding into separate tools, keeping the surface lean and each tool earning its place.

    Completeness4/5

    The surface covers the core lifecycle: search sources, create acquisition task, get status, retrieve download URL, download original, and upload. Some operations an agent might expect as first-class tools (delete/remove from library, update metadata, list library) are absent or only implied, but the main workflows are covered.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables browsing, searching, and quote verification of a local ebook library via MCP, providing deterministic RAG with no embeddings or network.
      6
      26 PyPI
      2
      MIT
    • F
      license
      A
      quality
      C
      maintenance
      Enables bibliographic research on a private local Calibre library by providing read-only metadata search, book inspection, and optional RAG-based content retrieval through MCP.
      5
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables MCP clients to search the Knihobot.cz public book catalog, inspect live physical copies, compare editions, and retrieve recommendations.
      5
      ISC
    • F
      license
      A
      quality
      C
      maintenance
      Enables Claude clients to access a private local book library, allowing users to list books, search content, and retrieve metadata, chapter summaries, action items, personal notes, and infographic text through MCP tools.
      7
      -