readest-connector 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- readest_connector-0.1.0/LICENSE +21 -0
- readest_connector-0.1.0/PKG-INFO +189 -0
- readest_connector-0.1.0/README.md +171 -0
- readest_connector-0.1.0/pyproject.toml +33 -0
- readest_connector-0.1.0/readest_connector.egg-info/PKG-INFO +189 -0
- readest_connector-0.1.0/readest_connector.egg-info/SOURCES.txt +15 -0
- readest_connector-0.1.0/readest_connector.egg-info/dependency_links.txt +1 -0
- readest_connector-0.1.0/readest_connector.egg-info/entry_points.txt +3 -0
- readest_connector-0.1.0/readest_connector.egg-info/top_level.txt +1 -0
- readest_connector-0.1.0/readest_mcp/__init__.py +10 -0
- readest_connector-0.1.0/readest_mcp/__main__.py +3 -0
- readest_connector-0.1.0/readest_mcp/dav_bridge.py +607 -0
- readest_connector-0.1.0/readest_mcp/dav_selftest.py +124 -0
- readest_connector-0.1.0/readest_mcp/readest_api.py +624 -0
- readest_connector-0.1.0/readest_mcp/server.py +1096 -0
- readest_connector-0.1.0/readest_mcp/service.py +205 -0
- readest_connector-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Readest Connector contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: readest-connector
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP connector for Readest: browse, organize and download your Readest library
|
|
5
|
+
Author: loloshilele
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/loloshilele/readest-connector
|
|
8
|
+
Project-URL: Source, https://github.com/loloshilele/readest-connector
|
|
9
|
+
Project-URL: Issues, https://github.com/loloshilele/readest-connector/issues
|
|
10
|
+
Keywords: mcp,readest,ebook,epub,ebook-reader,webdav
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Text Processing
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# Readest 连接器
|
|
20
|
+
|
|
21
|
+
把 [Readest](https://readest.com) 的书库接进 WorkBuddy / Claude 这类支持 MCP 的助手:
|
|
22
|
+
查书、筛书、批量改元数据、下载 EPUB、导出笔记,全都能一句话完成。
|
|
23
|
+
|
|
24
|
+
纯标准库实现,不需要 `pip install` 任何东西。
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
readest_mcp/
|
|
28
|
+
server.py MCP 服务(stdio),注册 14 个工具
|
|
29
|
+
readest_api.py Readest Cloud 客户端:认证、/api/sync 元数据、/api/storage 文件
|
|
30
|
+
dav_bridge.py WebDAV 桥:把本机 iCloud Drive 里的 Readest 目录暴露给 Windows 端
|
|
31
|
+
dav_selftest.py 桥接的兼容性自测(16 项)
|
|
32
|
+
service.py 桥接的后台服务管理(开机自启 / 停止 / 状态)
|
|
33
|
+
connector/ WorkBuddy 连接器市场包(元信息 / mcp.json / 图标 / Skill)
|
|
34
|
+
install.py 源码安装器:写 MCP 配置、环境自检
|
|
35
|
+
pyproject.toml PyPI 打包配置(entry point: readest-mcp)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 环境要求
|
|
39
|
+
|
|
40
|
+
- Python 3.10+(Windows / macOS / Linux 都行)
|
|
41
|
+
- 一个 Readest 账号(免费账号就能用云同步)
|
|
42
|
+
- 装 WorkBuddy 或任何支持 MCP 的客户端
|
|
43
|
+
|
|
44
|
+
## 安装
|
|
45
|
+
|
|
46
|
+
**方式一:源码(推荐自己用)**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/loloshilele/readest-connector.git
|
|
50
|
+
cd readest-connector
|
|
51
|
+
python install.py # 写入 ~/.workbuddy/mcp.json
|
|
52
|
+
python install.py --check # 环境自检
|
|
53
|
+
python install.py --bridge # 顺带装 iCloud 桥的开机自启(仅 Windows + iCloud 客户端)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> 仓库是私有的:换机器时用 GitHub 页面上的 **Code → Download ZIP**,或者配好凭据后
|
|
57
|
+
> `git clone`。凭据可以是 SSH key,也可以是 PAT。
|
|
58
|
+
|
|
59
|
+
**方式零:压缩包(最省事,不碰 Git)**
|
|
60
|
+
|
|
61
|
+
把 `readest-connector-0.1.0.zip` 拷到目标机器,解压后 `python install.py` 即可。
|
|
62
|
+
包很小(约 50 KB),不含任何登录凭据。
|
|
63
|
+
|
|
64
|
+
**方式二:PyPI / uvx(装在别的机器上最省事)**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
uv tool install readest-connector # 或者不安装,直接从客户端里用 uvx readest-connector
|
|
68
|
+
readest-mcp --selftest # 验证能起来
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
然后手动把这一条加进 `~/.workbuddy/mcp.json`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"readest": { "command": "uvx", "args": ["readest-connector"] }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
MCP 配置写好后**不会自动生效**:重启客户端,或在「连接器」页面右上角的
|
|
82
|
+
自定义连接器入口找到 `readest`,点一次「信任」。
|
|
83
|
+
|
|
84
|
+
### 另一台 Windows 的完整流程
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
1. 拿代码 GitHub → Code → Download ZIP,解压到任意目录
|
|
88
|
+
2. 装依赖 不需要,系统自带 Python 3.10+ 即可
|
|
89
|
+
3. 写配置 python install.py
|
|
90
|
+
4. 信任连接器 客户端 → 连接器页 → 自定义连接器 → readest → 信任
|
|
91
|
+
5. 各自登录 readest_login_start → 浏览器点确认 → readest_login_finish
|
|
92
|
+
6. 验证 readest_list_books(能看到自己的书就通了)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**每台设备要各自登录一次**,令牌保存在本机 `~/.workbuddy/readest-connector/session.json`,
|
|
96
|
+
不随代码分发。第 5 步的浏览器确认只能你本人点,助手代不了。
|
|
97
|
+
|
|
98
|
+
`--bridge`(iCloud WebDAV 桥)是**可选的 Windows 专属配件**:只在「装了 iCloud for Windows、
|
|
99
|
+
想让 PC 端 Readest 通过本机 iCloud 目录与 iPhone 同步」时才需要,其它设备跳过第 3 步的该参数即可。
|
|
100
|
+
|
|
101
|
+
## 登录
|
|
102
|
+
|
|
103
|
+
Readest 用的是设备码授权,不需要在连接器里存密码:
|
|
104
|
+
|
|
105
|
+
1. 助手调用 `readest_login_start`,返回形如 `https://web.readest.com/link?code=XXXX-XXXX` 的链接
|
|
106
|
+
2. 你在浏览器里确认授权(10 分钟内有效)
|
|
107
|
+
3. 助手调用 `readest_login_finish` 完成轮询,令牌落到 `~/.workbuddy/readest-connector/session.json`
|
|
108
|
+
|
|
109
|
+
令牌约 16 小时过期,之后自动用 refresh token 续期,不用再授权。
|
|
110
|
+
|
|
111
|
+
## 工具一览(14 个)
|
|
112
|
+
|
|
113
|
+
| 分类 | 工具 | 作用 |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| 账号 | `readest_auth_status` | 当前登录状态、配额、会员权益 |
|
|
116
|
+
| | `readest_login_start` / `login_finish` / `login_password` | 设备码登录 / 邮箱密码登录 |
|
|
117
|
+
| | `readest_logout` | 清除本地令牌 |
|
|
118
|
+
| 书库 | `readest_list_books` | 列表,支持关键词 / 格式 / 标签 / 阅读状态 / 分组筛选 |
|
|
119
|
+
| | `readest_get_book` | 单本详情(进度、笔记、元数据) |
|
|
120
|
+
| | `readest_library_report` | 书库体检:重复书、脏书名、缺封面、无标签,可导出 CSV |
|
|
121
|
+
| | `readest_storage_stats` | 云端存储用量,按书排行 |
|
|
122
|
+
| 下载 | `readest_download_book` | 单本下载,自动命名「作者 - 书名.epub」 |
|
|
123
|
+
| | `readest_download_library` | 按标签 / 状态批量导出 |
|
|
124
|
+
| 整理 | `readest_update_book` | 改标题、作者、标签、分组、阅读状态 |
|
|
125
|
+
| | `readest_bulk_update` | 批量打标签 / 分组,默认 `dry_run`,命中超过 20 本要二次确认 |
|
|
126
|
+
| | `readest_export_notes` | 划线与笔记导出 Markdown |
|
|
127
|
+
|
|
128
|
+
### 两个实现上的注意点
|
|
129
|
+
|
|
130
|
+
- `/api/sync` 对「推送记录里缺失的字段」会**显式置空**。所以每次修改都要先拉完整记录,
|
|
131
|
+
只覆盖目标字段,再打上对应的 LWW 时间戳——否则改书名会顺手清掉别的设备上的阅读进度。
|
|
132
|
+
- `/storage/list` 默认每页 50 条,必须按 `totalPages` 翻页,否则大部分书的正文会被误判为「未上传」。
|
|
133
|
+
`/storage/stats` 按书统计返回的是 snake_case(`book_hash` / `total_size`),不是 camelCase。
|
|
134
|
+
|
|
135
|
+
## iCloud 同步(Windows 变通方案)
|
|
136
|
+
|
|
137
|
+
Readest 的 iCloud 后端**只编译进 iOS / macOS**:源码 `buildICloudProvider.ts` 里
|
|
138
|
+
`isICloudSupportedPlatform()` 硬编码 `['ios','macos']`,Windows 客户端即使把
|
|
139
|
+
`settings.json` 的 `icloud.enabled` 改成 true 也会被 `canBackendRun` 拦掉。
|
|
140
|
+
|
|
141
|
+
但 iCloud 后端本质是「往一个普通文件夹写文件」,线格式与 WebDAV 完全一致
|
|
142
|
+
(`writerVersion: readest-webdav-1`):
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
<root>/Readest/library.json
|
|
146
|
+
<root>/Readest/books/<hash>/{<书名>.epub, cover.png, config.json}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
iCloud for Windows 会把 iPhone 写的内容落到
|
|
150
|
+
`~/iCloudDrive/iCloud~com~bilingify~readest/Readest/...`,于是把这棵目录用 WebDAV
|
|
151
|
+
暴露出来,让 Windows 版 Readest 的 WebDAV 后端指过去,PC 与 iPhone 就共用同一份书库。
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
python readest_mcp/dav_bridge.py # 127.0.0.1:8765,读写
|
|
155
|
+
python readest_mcp/dav_bridge.py --read-only # 只读,最安全
|
|
156
|
+
python readest_mcp/dav_bridge.py --status # 只打印书库概况
|
|
157
|
+
python readest_mcp/dav_selftest.py # 16 项兼容性自测
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Readest 里填:URL `http://127.0.0.1:8765`,用户名 / 密码 `readest` / `readest`,根路径 `/`。
|
|
161
|
+
|
|
162
|
+
### 常驻运行
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
python readest_mcp/service.py install # 写开机自启项并立即启动
|
|
166
|
+
python readest_mcp/service.py status # 端口、HTTP 健康、日志尾部
|
|
167
|
+
python readest_mcp/service.py stop # 停止(并阻止自动重启)
|
|
168
|
+
python readest_mcp/service.py start # 手动启动
|
|
169
|
+
python readest_mcp/service.py uninstall # 移除开机自启项
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Windows 上的做法是启动文件夹里的一个 `.vbs`:用 `pythonw` 隐藏窗口拉起桥接,
|
|
173
|
+
进程退出后 10 秒自动重启,直到出现 `stop.flag`。日志在
|
|
174
|
+
`%LOCALAPPDATA%\ReadestDavBridge\bridge.log`,超过 2 MB 自动轮转。
|
|
175
|
+
|
|
176
|
+
macOS / Linux 上直接用 `nohup python dav_bridge.py --log-file ... &` 或写 systemd unit 即可。
|
|
177
|
+
|
|
178
|
+
## 已知限制
|
|
179
|
+
|
|
180
|
+
- **不支持 DRM**。Kindle / Kobo / Apple Books 买的加密书打不开,本连接器也只处理无 DRM 文件。
|
|
181
|
+
- **Readest 不会批量下载书文件**。`syncBooks` 只决定「上传」方向;远端有、本地无的书只生成
|
|
182
|
+
「仅元数据」的云端书架行(封面 + 进度 + 笔记,`downloadedAt = null`),书字节要等你
|
|
183
|
+
点 Download 或打开那本书时才拉(源码注释引用 issue #5009)。
|
|
184
|
+
- 桥接只监听 `127.0.0.1`,Basic Auth 仅防误连,不是安全边界;要跨机器用请自行加 TLS 与防火墙规则。
|
|
185
|
+
- 云端同步是 LWW(last-write-wins),两台设备同时改同一本书的进度会有一边被覆盖。
|
|
186
|
+
|
|
187
|
+
## 许可
|
|
188
|
+
|
|
189
|
+
MIT。Readest 本身是 AGPL-3.0,本项目只调用它的 HTTP 接口、读写它的同步目录,不包含其代码。
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Readest 连接器
|
|
2
|
+
|
|
3
|
+
把 [Readest](https://readest.com) 的书库接进 WorkBuddy / Claude 这类支持 MCP 的助手:
|
|
4
|
+
查书、筛书、批量改元数据、下载 EPUB、导出笔记,全都能一句话完成。
|
|
5
|
+
|
|
6
|
+
纯标准库实现,不需要 `pip install` 任何东西。
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
readest_mcp/
|
|
10
|
+
server.py MCP 服务(stdio),注册 14 个工具
|
|
11
|
+
readest_api.py Readest Cloud 客户端:认证、/api/sync 元数据、/api/storage 文件
|
|
12
|
+
dav_bridge.py WebDAV 桥:把本机 iCloud Drive 里的 Readest 目录暴露给 Windows 端
|
|
13
|
+
dav_selftest.py 桥接的兼容性自测(16 项)
|
|
14
|
+
service.py 桥接的后台服务管理(开机自启 / 停止 / 状态)
|
|
15
|
+
connector/ WorkBuddy 连接器市场包(元信息 / mcp.json / 图标 / Skill)
|
|
16
|
+
install.py 源码安装器:写 MCP 配置、环境自检
|
|
17
|
+
pyproject.toml PyPI 打包配置(entry point: readest-mcp)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 环境要求
|
|
21
|
+
|
|
22
|
+
- Python 3.10+(Windows / macOS / Linux 都行)
|
|
23
|
+
- 一个 Readest 账号(免费账号就能用云同步)
|
|
24
|
+
- 装 WorkBuddy 或任何支持 MCP 的客户端
|
|
25
|
+
|
|
26
|
+
## 安装
|
|
27
|
+
|
|
28
|
+
**方式一:源码(推荐自己用)**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/loloshilele/readest-connector.git
|
|
32
|
+
cd readest-connector
|
|
33
|
+
python install.py # 写入 ~/.workbuddy/mcp.json
|
|
34
|
+
python install.py --check # 环境自检
|
|
35
|
+
python install.py --bridge # 顺带装 iCloud 桥的开机自启(仅 Windows + iCloud 客户端)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> 仓库是私有的:换机器时用 GitHub 页面上的 **Code → Download ZIP**,或者配好凭据后
|
|
39
|
+
> `git clone`。凭据可以是 SSH key,也可以是 PAT。
|
|
40
|
+
|
|
41
|
+
**方式零:压缩包(最省事,不碰 Git)**
|
|
42
|
+
|
|
43
|
+
把 `readest-connector-0.1.0.zip` 拷到目标机器,解压后 `python install.py` 即可。
|
|
44
|
+
包很小(约 50 KB),不含任何登录凭据。
|
|
45
|
+
|
|
46
|
+
**方式二:PyPI / uvx(装在别的机器上最省事)**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
uv tool install readest-connector # 或者不安装,直接从客户端里用 uvx readest-connector
|
|
50
|
+
readest-mcp --selftest # 验证能起来
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
然后手动把这一条加进 `~/.workbuddy/mcp.json`:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"mcpServers": {
|
|
58
|
+
"readest": { "command": "uvx", "args": ["readest-connector"] }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
MCP 配置写好后**不会自动生效**:重启客户端,或在「连接器」页面右上角的
|
|
64
|
+
自定义连接器入口找到 `readest`,点一次「信任」。
|
|
65
|
+
|
|
66
|
+
### 另一台 Windows 的完整流程
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
1. 拿代码 GitHub → Code → Download ZIP,解压到任意目录
|
|
70
|
+
2. 装依赖 不需要,系统自带 Python 3.10+ 即可
|
|
71
|
+
3. 写配置 python install.py
|
|
72
|
+
4. 信任连接器 客户端 → 连接器页 → 自定义连接器 → readest → 信任
|
|
73
|
+
5. 各自登录 readest_login_start → 浏览器点确认 → readest_login_finish
|
|
74
|
+
6. 验证 readest_list_books(能看到自己的书就通了)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**每台设备要各自登录一次**,令牌保存在本机 `~/.workbuddy/readest-connector/session.json`,
|
|
78
|
+
不随代码分发。第 5 步的浏览器确认只能你本人点,助手代不了。
|
|
79
|
+
|
|
80
|
+
`--bridge`(iCloud WebDAV 桥)是**可选的 Windows 专属配件**:只在「装了 iCloud for Windows、
|
|
81
|
+
想让 PC 端 Readest 通过本机 iCloud 目录与 iPhone 同步」时才需要,其它设备跳过第 3 步的该参数即可。
|
|
82
|
+
|
|
83
|
+
## 登录
|
|
84
|
+
|
|
85
|
+
Readest 用的是设备码授权,不需要在连接器里存密码:
|
|
86
|
+
|
|
87
|
+
1. 助手调用 `readest_login_start`,返回形如 `https://web.readest.com/link?code=XXXX-XXXX` 的链接
|
|
88
|
+
2. 你在浏览器里确认授权(10 分钟内有效)
|
|
89
|
+
3. 助手调用 `readest_login_finish` 完成轮询,令牌落到 `~/.workbuddy/readest-connector/session.json`
|
|
90
|
+
|
|
91
|
+
令牌约 16 小时过期,之后自动用 refresh token 续期,不用再授权。
|
|
92
|
+
|
|
93
|
+
## 工具一览(14 个)
|
|
94
|
+
|
|
95
|
+
| 分类 | 工具 | 作用 |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| 账号 | `readest_auth_status` | 当前登录状态、配额、会员权益 |
|
|
98
|
+
| | `readest_login_start` / `login_finish` / `login_password` | 设备码登录 / 邮箱密码登录 |
|
|
99
|
+
| | `readest_logout` | 清除本地令牌 |
|
|
100
|
+
| 书库 | `readest_list_books` | 列表,支持关键词 / 格式 / 标签 / 阅读状态 / 分组筛选 |
|
|
101
|
+
| | `readest_get_book` | 单本详情(进度、笔记、元数据) |
|
|
102
|
+
| | `readest_library_report` | 书库体检:重复书、脏书名、缺封面、无标签,可导出 CSV |
|
|
103
|
+
| | `readest_storage_stats` | 云端存储用量,按书排行 |
|
|
104
|
+
| 下载 | `readest_download_book` | 单本下载,自动命名「作者 - 书名.epub」 |
|
|
105
|
+
| | `readest_download_library` | 按标签 / 状态批量导出 |
|
|
106
|
+
| 整理 | `readest_update_book` | 改标题、作者、标签、分组、阅读状态 |
|
|
107
|
+
| | `readest_bulk_update` | 批量打标签 / 分组,默认 `dry_run`,命中超过 20 本要二次确认 |
|
|
108
|
+
| | `readest_export_notes` | 划线与笔记导出 Markdown |
|
|
109
|
+
|
|
110
|
+
### 两个实现上的注意点
|
|
111
|
+
|
|
112
|
+
- `/api/sync` 对「推送记录里缺失的字段」会**显式置空**。所以每次修改都要先拉完整记录,
|
|
113
|
+
只覆盖目标字段,再打上对应的 LWW 时间戳——否则改书名会顺手清掉别的设备上的阅读进度。
|
|
114
|
+
- `/storage/list` 默认每页 50 条,必须按 `totalPages` 翻页,否则大部分书的正文会被误判为「未上传」。
|
|
115
|
+
`/storage/stats` 按书统计返回的是 snake_case(`book_hash` / `total_size`),不是 camelCase。
|
|
116
|
+
|
|
117
|
+
## iCloud 同步(Windows 变通方案)
|
|
118
|
+
|
|
119
|
+
Readest 的 iCloud 后端**只编译进 iOS / macOS**:源码 `buildICloudProvider.ts` 里
|
|
120
|
+
`isICloudSupportedPlatform()` 硬编码 `['ios','macos']`,Windows 客户端即使把
|
|
121
|
+
`settings.json` 的 `icloud.enabled` 改成 true 也会被 `canBackendRun` 拦掉。
|
|
122
|
+
|
|
123
|
+
但 iCloud 后端本质是「往一个普通文件夹写文件」,线格式与 WebDAV 完全一致
|
|
124
|
+
(`writerVersion: readest-webdav-1`):
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
<root>/Readest/library.json
|
|
128
|
+
<root>/Readest/books/<hash>/{<书名>.epub, cover.png, config.json}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
iCloud for Windows 会把 iPhone 写的内容落到
|
|
132
|
+
`~/iCloudDrive/iCloud~com~bilingify~readest/Readest/...`,于是把这棵目录用 WebDAV
|
|
133
|
+
暴露出来,让 Windows 版 Readest 的 WebDAV 后端指过去,PC 与 iPhone 就共用同一份书库。
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
python readest_mcp/dav_bridge.py # 127.0.0.1:8765,读写
|
|
137
|
+
python readest_mcp/dav_bridge.py --read-only # 只读,最安全
|
|
138
|
+
python readest_mcp/dav_bridge.py --status # 只打印书库概况
|
|
139
|
+
python readest_mcp/dav_selftest.py # 16 项兼容性自测
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Readest 里填:URL `http://127.0.0.1:8765`,用户名 / 密码 `readest` / `readest`,根路径 `/`。
|
|
143
|
+
|
|
144
|
+
### 常驻运行
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
python readest_mcp/service.py install # 写开机自启项并立即启动
|
|
148
|
+
python readest_mcp/service.py status # 端口、HTTP 健康、日志尾部
|
|
149
|
+
python readest_mcp/service.py stop # 停止(并阻止自动重启)
|
|
150
|
+
python readest_mcp/service.py start # 手动启动
|
|
151
|
+
python readest_mcp/service.py uninstall # 移除开机自启项
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Windows 上的做法是启动文件夹里的一个 `.vbs`:用 `pythonw` 隐藏窗口拉起桥接,
|
|
155
|
+
进程退出后 10 秒自动重启,直到出现 `stop.flag`。日志在
|
|
156
|
+
`%LOCALAPPDATA%\ReadestDavBridge\bridge.log`,超过 2 MB 自动轮转。
|
|
157
|
+
|
|
158
|
+
macOS / Linux 上直接用 `nohup python dav_bridge.py --log-file ... &` 或写 systemd unit 即可。
|
|
159
|
+
|
|
160
|
+
## 已知限制
|
|
161
|
+
|
|
162
|
+
- **不支持 DRM**。Kindle / Kobo / Apple Books 买的加密书打不开,本连接器也只处理无 DRM 文件。
|
|
163
|
+
- **Readest 不会批量下载书文件**。`syncBooks` 只决定「上传」方向;远端有、本地无的书只生成
|
|
164
|
+
「仅元数据」的云端书架行(封面 + 进度 + 笔记,`downloadedAt = null`),书字节要等你
|
|
165
|
+
点 Download 或打开那本书时才拉(源码注释引用 issue #5009)。
|
|
166
|
+
- 桥接只监听 `127.0.0.1`,Basic Auth 仅防误连,不是安全边界;要跨机器用请自行加 TLS 与防火墙规则。
|
|
167
|
+
- 云端同步是 LWW(last-write-wins),两台设备同时改同一本书的进度会有一边被覆盖。
|
|
168
|
+
|
|
169
|
+
## 许可
|
|
170
|
+
|
|
171
|
+
MIT。Readest 本身是 AGPL-3.0,本项目只调用它的 HTTP 接口、读写它的同步目录,不包含其代码。
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "readest-connector"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP connector for Readest: browse, organize and download your Readest library"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "loloshilele" }]
|
|
14
|
+
keywords = ["mcp", "readest", "ebook", "epub", "ebook-reader", "webdav"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Topic :: Text Processing",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/loloshilele/readest-connector"
|
|
23
|
+
Source = "https://github.com/loloshilele/readest-connector"
|
|
24
|
+
Issues = "https://github.com/loloshilele/readest-connector/issues"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
readest-mcp = "readest_mcp.server:main"
|
|
28
|
+
# 与包名同名的入口:uvx 默认执行与包同名的命令,市场包 mcp.json 里写的是
|
|
29
|
+
# {"command": "uvx", "args": ["readest-connector"]},没有这个入口会启动失败。
|
|
30
|
+
readest-connector = "readest_mcp.server:main"
|
|
31
|
+
|
|
32
|
+
[tool.setuptools]
|
|
33
|
+
packages = ["readest_mcp"]
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: readest-connector
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP connector for Readest: browse, organize and download your Readest library
|
|
5
|
+
Author: loloshilele
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/loloshilele/readest-connector
|
|
8
|
+
Project-URL: Source, https://github.com/loloshilele/readest-connector
|
|
9
|
+
Project-URL: Issues, https://github.com/loloshilele/readest-connector/issues
|
|
10
|
+
Keywords: mcp,readest,ebook,epub,ebook-reader,webdav
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Text Processing
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# Readest 连接器
|
|
20
|
+
|
|
21
|
+
把 [Readest](https://readest.com) 的书库接进 WorkBuddy / Claude 这类支持 MCP 的助手:
|
|
22
|
+
查书、筛书、批量改元数据、下载 EPUB、导出笔记,全都能一句话完成。
|
|
23
|
+
|
|
24
|
+
纯标准库实现,不需要 `pip install` 任何东西。
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
readest_mcp/
|
|
28
|
+
server.py MCP 服务(stdio),注册 14 个工具
|
|
29
|
+
readest_api.py Readest Cloud 客户端:认证、/api/sync 元数据、/api/storage 文件
|
|
30
|
+
dav_bridge.py WebDAV 桥:把本机 iCloud Drive 里的 Readest 目录暴露给 Windows 端
|
|
31
|
+
dav_selftest.py 桥接的兼容性自测(16 项)
|
|
32
|
+
service.py 桥接的后台服务管理(开机自启 / 停止 / 状态)
|
|
33
|
+
connector/ WorkBuddy 连接器市场包(元信息 / mcp.json / 图标 / Skill)
|
|
34
|
+
install.py 源码安装器:写 MCP 配置、环境自检
|
|
35
|
+
pyproject.toml PyPI 打包配置(entry point: readest-mcp)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 环境要求
|
|
39
|
+
|
|
40
|
+
- Python 3.10+(Windows / macOS / Linux 都行)
|
|
41
|
+
- 一个 Readest 账号(免费账号就能用云同步)
|
|
42
|
+
- 装 WorkBuddy 或任何支持 MCP 的客户端
|
|
43
|
+
|
|
44
|
+
## 安装
|
|
45
|
+
|
|
46
|
+
**方式一:源码(推荐自己用)**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/loloshilele/readest-connector.git
|
|
50
|
+
cd readest-connector
|
|
51
|
+
python install.py # 写入 ~/.workbuddy/mcp.json
|
|
52
|
+
python install.py --check # 环境自检
|
|
53
|
+
python install.py --bridge # 顺带装 iCloud 桥的开机自启(仅 Windows + iCloud 客户端)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> 仓库是私有的:换机器时用 GitHub 页面上的 **Code → Download ZIP**,或者配好凭据后
|
|
57
|
+
> `git clone`。凭据可以是 SSH key,也可以是 PAT。
|
|
58
|
+
|
|
59
|
+
**方式零:压缩包(最省事,不碰 Git)**
|
|
60
|
+
|
|
61
|
+
把 `readest-connector-0.1.0.zip` 拷到目标机器,解压后 `python install.py` 即可。
|
|
62
|
+
包很小(约 50 KB),不含任何登录凭据。
|
|
63
|
+
|
|
64
|
+
**方式二:PyPI / uvx(装在别的机器上最省事)**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
uv tool install readest-connector # 或者不安装,直接从客户端里用 uvx readest-connector
|
|
68
|
+
readest-mcp --selftest # 验证能起来
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
然后手动把这一条加进 `~/.workbuddy/mcp.json`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"readest": { "command": "uvx", "args": ["readest-connector"] }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
MCP 配置写好后**不会自动生效**:重启客户端,或在「连接器」页面右上角的
|
|
82
|
+
自定义连接器入口找到 `readest`,点一次「信任」。
|
|
83
|
+
|
|
84
|
+
### 另一台 Windows 的完整流程
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
1. 拿代码 GitHub → Code → Download ZIP,解压到任意目录
|
|
88
|
+
2. 装依赖 不需要,系统自带 Python 3.10+ 即可
|
|
89
|
+
3. 写配置 python install.py
|
|
90
|
+
4. 信任连接器 客户端 → 连接器页 → 自定义连接器 → readest → 信任
|
|
91
|
+
5. 各自登录 readest_login_start → 浏览器点确认 → readest_login_finish
|
|
92
|
+
6. 验证 readest_list_books(能看到自己的书就通了)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**每台设备要各自登录一次**,令牌保存在本机 `~/.workbuddy/readest-connector/session.json`,
|
|
96
|
+
不随代码分发。第 5 步的浏览器确认只能你本人点,助手代不了。
|
|
97
|
+
|
|
98
|
+
`--bridge`(iCloud WebDAV 桥)是**可选的 Windows 专属配件**:只在「装了 iCloud for Windows、
|
|
99
|
+
想让 PC 端 Readest 通过本机 iCloud 目录与 iPhone 同步」时才需要,其它设备跳过第 3 步的该参数即可。
|
|
100
|
+
|
|
101
|
+
## 登录
|
|
102
|
+
|
|
103
|
+
Readest 用的是设备码授权,不需要在连接器里存密码:
|
|
104
|
+
|
|
105
|
+
1. 助手调用 `readest_login_start`,返回形如 `https://web.readest.com/link?code=XXXX-XXXX` 的链接
|
|
106
|
+
2. 你在浏览器里确认授权(10 分钟内有效)
|
|
107
|
+
3. 助手调用 `readest_login_finish` 完成轮询,令牌落到 `~/.workbuddy/readest-connector/session.json`
|
|
108
|
+
|
|
109
|
+
令牌约 16 小时过期,之后自动用 refresh token 续期,不用再授权。
|
|
110
|
+
|
|
111
|
+
## 工具一览(14 个)
|
|
112
|
+
|
|
113
|
+
| 分类 | 工具 | 作用 |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| 账号 | `readest_auth_status` | 当前登录状态、配额、会员权益 |
|
|
116
|
+
| | `readest_login_start` / `login_finish` / `login_password` | 设备码登录 / 邮箱密码登录 |
|
|
117
|
+
| | `readest_logout` | 清除本地令牌 |
|
|
118
|
+
| 书库 | `readest_list_books` | 列表,支持关键词 / 格式 / 标签 / 阅读状态 / 分组筛选 |
|
|
119
|
+
| | `readest_get_book` | 单本详情(进度、笔记、元数据) |
|
|
120
|
+
| | `readest_library_report` | 书库体检:重复书、脏书名、缺封面、无标签,可导出 CSV |
|
|
121
|
+
| | `readest_storage_stats` | 云端存储用量,按书排行 |
|
|
122
|
+
| 下载 | `readest_download_book` | 单本下载,自动命名「作者 - 书名.epub」 |
|
|
123
|
+
| | `readest_download_library` | 按标签 / 状态批量导出 |
|
|
124
|
+
| 整理 | `readest_update_book` | 改标题、作者、标签、分组、阅读状态 |
|
|
125
|
+
| | `readest_bulk_update` | 批量打标签 / 分组,默认 `dry_run`,命中超过 20 本要二次确认 |
|
|
126
|
+
| | `readest_export_notes` | 划线与笔记导出 Markdown |
|
|
127
|
+
|
|
128
|
+
### 两个实现上的注意点
|
|
129
|
+
|
|
130
|
+
- `/api/sync` 对「推送记录里缺失的字段」会**显式置空**。所以每次修改都要先拉完整记录,
|
|
131
|
+
只覆盖目标字段,再打上对应的 LWW 时间戳——否则改书名会顺手清掉别的设备上的阅读进度。
|
|
132
|
+
- `/storage/list` 默认每页 50 条,必须按 `totalPages` 翻页,否则大部分书的正文会被误判为「未上传」。
|
|
133
|
+
`/storage/stats` 按书统计返回的是 snake_case(`book_hash` / `total_size`),不是 camelCase。
|
|
134
|
+
|
|
135
|
+
## iCloud 同步(Windows 变通方案)
|
|
136
|
+
|
|
137
|
+
Readest 的 iCloud 后端**只编译进 iOS / macOS**:源码 `buildICloudProvider.ts` 里
|
|
138
|
+
`isICloudSupportedPlatform()` 硬编码 `['ios','macos']`,Windows 客户端即使把
|
|
139
|
+
`settings.json` 的 `icloud.enabled` 改成 true 也会被 `canBackendRun` 拦掉。
|
|
140
|
+
|
|
141
|
+
但 iCloud 后端本质是「往一个普通文件夹写文件」,线格式与 WebDAV 完全一致
|
|
142
|
+
(`writerVersion: readest-webdav-1`):
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
<root>/Readest/library.json
|
|
146
|
+
<root>/Readest/books/<hash>/{<书名>.epub, cover.png, config.json}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
iCloud for Windows 会把 iPhone 写的内容落到
|
|
150
|
+
`~/iCloudDrive/iCloud~com~bilingify~readest/Readest/...`,于是把这棵目录用 WebDAV
|
|
151
|
+
暴露出来,让 Windows 版 Readest 的 WebDAV 后端指过去,PC 与 iPhone 就共用同一份书库。
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
python readest_mcp/dav_bridge.py # 127.0.0.1:8765,读写
|
|
155
|
+
python readest_mcp/dav_bridge.py --read-only # 只读,最安全
|
|
156
|
+
python readest_mcp/dav_bridge.py --status # 只打印书库概况
|
|
157
|
+
python readest_mcp/dav_selftest.py # 16 项兼容性自测
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Readest 里填:URL `http://127.0.0.1:8765`,用户名 / 密码 `readest` / `readest`,根路径 `/`。
|
|
161
|
+
|
|
162
|
+
### 常驻运行
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
python readest_mcp/service.py install # 写开机自启项并立即启动
|
|
166
|
+
python readest_mcp/service.py status # 端口、HTTP 健康、日志尾部
|
|
167
|
+
python readest_mcp/service.py stop # 停止(并阻止自动重启)
|
|
168
|
+
python readest_mcp/service.py start # 手动启动
|
|
169
|
+
python readest_mcp/service.py uninstall # 移除开机自启项
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Windows 上的做法是启动文件夹里的一个 `.vbs`:用 `pythonw` 隐藏窗口拉起桥接,
|
|
173
|
+
进程退出后 10 秒自动重启,直到出现 `stop.flag`。日志在
|
|
174
|
+
`%LOCALAPPDATA%\ReadestDavBridge\bridge.log`,超过 2 MB 自动轮转。
|
|
175
|
+
|
|
176
|
+
macOS / Linux 上直接用 `nohup python dav_bridge.py --log-file ... &` 或写 systemd unit 即可。
|
|
177
|
+
|
|
178
|
+
## 已知限制
|
|
179
|
+
|
|
180
|
+
- **不支持 DRM**。Kindle / Kobo / Apple Books 买的加密书打不开,本连接器也只处理无 DRM 文件。
|
|
181
|
+
- **Readest 不会批量下载书文件**。`syncBooks` 只决定「上传」方向;远端有、本地无的书只生成
|
|
182
|
+
「仅元数据」的云端书架行(封面 + 进度 + 笔记,`downloadedAt = null`),书字节要等你
|
|
183
|
+
点 Download 或打开那本书时才拉(源码注释引用 issue #5009)。
|
|
184
|
+
- 桥接只监听 `127.0.0.1`,Basic Auth 仅防误连,不是安全边界;要跨机器用请自行加 TLS 与防火墙规则。
|
|
185
|
+
- 云端同步是 LWW(last-write-wins),两台设备同时改同一本书的进度会有一边被覆盖。
|
|
186
|
+
|
|
187
|
+
## 许可
|
|
188
|
+
|
|
189
|
+
MIT。Readest 本身是 AGPL-3.0,本项目只调用它的 HTTP 接口、读写它的同步目录,不包含其代码。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
readest_connector.egg-info/PKG-INFO
|
|
5
|
+
readest_connector.egg-info/SOURCES.txt
|
|
6
|
+
readest_connector.egg-info/dependency_links.txt
|
|
7
|
+
readest_connector.egg-info/entry_points.txt
|
|
8
|
+
readest_connector.egg-info/top_level.txt
|
|
9
|
+
readest_mcp/__init__.py
|
|
10
|
+
readest_mcp/__main__.py
|
|
11
|
+
readest_mcp/dav_bridge.py
|
|
12
|
+
readest_mcp/dav_selftest.py
|
|
13
|
+
readest_mcp/readest_api.py
|
|
14
|
+
readest_mcp/server.py
|
|
15
|
+
readest_mcp/service.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
readest_mcp
|