OpenPaper
by IoriAkatsuki
README.md
<h1 align="center">OpenPaper</h1>
<p align="center"><b>让 AI Agent 在后台用你学校的订阅下载论文全文:无头、自动登录、自动过 Cloudflare。</b></p>
<p align="center">
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT"></a>
<a href="pyproject.toml"><img src="https://img.shields.io/badge/python-%3E%3D3.10-blue.svg" alt="Python >=3.10"></a>
<img src="https://img.shields.io/badge/MCP-compatible-blue.svg" alt="MCP">
<img src="https://img.shields.io/badge/headless-100%25-black.svg" alt="headless">
</p>
<p align="center"><a href="#中文">中文</a> | <a href="#english">English</a> | <a href="FAQ.md">FAQ</a></p>
## 中文
对 Claude Code、Codex、Antigravity、Cursor 等 Agent 说一句「帮我下这篇论文 DOI: 10.1016/...」,OpenPaper 会先找开放获取版本;找不到时,用学校的订阅在后台下载 PDF 并抽出正文,返回给 Agent。整个过程不弹窗,也不需要你点验证码。
### 为什么选 OpenPaper
| | OpenPaper | 一般的论文下载工具 |
|---|---|---|
| 登录 | 账号存在系统钥匙环,会话过期时**无头自动续期** | 弹出浏览器让你手动登录 |
| Cloudflare / Turnstile | 学校出口 IP + 真浏览器指纹,**自动点击 Turnstile** | 卡在「请验证您是真人」 |
| Elsevier / ScienceDirect | 走学校订阅直接下 PDF,**不需要 API key** | 要申请 Elsevier API key,或者放弃 |
| 易安联(EnLink)学校 | 内置全隧道(学校出口 IP) | WebVPN 反代,经常被 CF 拦 |
| 运行方式 | MCP 在后台跑,适合 Agent 批量调用 | 需要人一直守着 |
南京邮电大学实测(2026-11):
| 出版商 | 结果 |
|---|---|
| IEEE Xplore | ✅ PDF |
| Wiley | ✅ PDF(隧道或 CARSI) |
| Elsevier / ScienceDirect | ✅ PDF(冷启动 15–60 秒) |
| Nature / Springer | ✅ PDF |
| ACS | ⚠️ 时好时坏,开放获取的可以 |
| Taylor & Francis | ➖ 未实测(南邮未订阅,代码已内置适配) |
| RSC | ❌ id.rsc.org 无法访问 |
其他学校走 WebVPN、EZproxy、EasyConnect、aTrust,内置 100+ 高校配置;没实测过的,欢迎提 issue 反馈结果。
### 一句话安装
对你的 Agent 说:
```text
帮我安装这个 MCP:https://github.com/IoriAkatsuki/openpaper
```
### 手动安装
```bash
uv tool install git+https://github.com/IoriAkatsuki/openpaper.git
# 或
pipx install git+https://github.com/IoriAkatsuki/openpaper.git
openpaper config-cmd --school 你的学校
openpaper save-credentials # 账号密码存入系统钥匙环(Win / macOS / Linux),之后自动续期
```
接入 MCP:
```bash
# Claude Code
claude mcp add openpaper -s user -- openpaper-mcp
```
```toml
# Codex: ~/.codex/config.toml
[mcp_servers.openpaper]
command = "openpaper-mcp"
```
```json
// Antigravity / Cursor 等: mcp_config.json
{ "mcpServers": { "openpaper": { "command": "openpaper-mcp", "args": [] } } }
```
易安联学校建议再开隧道(见下文[易安联隧道](#易安联隧道enlink-全隧道)),Elsevier 和 Wiley 都靠它。
### MCP 工具
| 工具 | 作用 |
|---|---|
| `fetch_paper` | 按 DOI 或 URL 获取全文(Markdown/文本),同时保存 PDF |
| `search_papers` | 按关键词搜索论文,可限年份 |
| `get_paper_metadata` | 获取标题、作者、摘要、引用数 |
| `configure_school` | 设置学校(首次使用时 Agent 会问你) |
示例:
> 帮我找 2023 年以后钙钛矿太阳能电池的高引论文,把前 5 篇的 PDF 都下下来
### 命令行
```bash
openpaper search "perovskite solar cells"
openpaper fetch 10.1016/j.joule.2018.10.010
openpaper batch dois.txt --output ./papers
openpaper tunnel up | down | status
openpaper schools
```
### 获取顺序
1. 开放获取:Unpaywall、arXiv
2. 易安联隧道(健康时):无头浏览器经学校 IP 直连出版商
3. 回退:WebVPN → CARSI 机构登录 → FlareSolverr
4. 都不行时返回元数据,并说明原因(未订阅、需要登录等)
### 环境要求
- **Python >= 3.10**(项目依赖已包含 `keyring>=25.0.0`)
- **操作系统**:支持 **Linux**(实测),以及 **Windows** / **macOS**(系统钥匙环与隧道监管代码已跨平台适配,但尚未在 Windows / macOS 上实测)。`openpaper save-credentials` 在 Linux 优先使用 `secret-tool`(libsecret)并可回退到 Python `keyring`,在 Windows 使用凭据管理器、在 macOS 使用钥匙串
- **CloakBrowser**(随依赖安装,首次运行时自动下载浏览器)
- **易安联隧道**需要 Node.js 和 [openenlink(njupt 分支)](https://github.com/IoriAkatsuki/openenlink/tree/njupt)(隧道监管代码已跨平台适配,Windows / macOS 未实测;`systemd` 开机自启仅限 Linux)
- **FlareSolverr** 可选
更多常见问题见 [FAQ.md](FAQ.md)。
## 进阶
### 自动续期登录与 CARSI
- **自动续期**:运行一次 `openpaper save-credentials`,账号密码存入系统钥匙环(Linux 优先 `secret-tool`/libsecret 并可回退到 `keyring`,Windows 凭据管理器与 macOS 钥匙串使用 `keyring`),不写入明文文件。WebVPN 会话或统一认证票据过期时,会用无头浏览器自动重新登录(Linux 已实测,Windows / macOS 未实测)。自动登录每次只尝试一次,失败(例如出现验证码)时返回 `needs_login`,并附上处理建议。
- **MCP 全程无头**:MCP 后台不会弹出浏览器窗口,需要人工介入时会在结果里返回状态和处理建议。
- **CARSI**:运行 `openpaper config-cmd --carsi-idp-entity-id https://idp.njupt.edu.cn/idp/shibboleth`(南邮示例,也可直接编辑 `~/.openpaper/config.json` 的 `carsi_idp_entity_id`)之后,WebVPN 反代过不了 Cloudflare 的出版商会改走「机构登录 + 无头浏览器」(Wiley 已实测,ACS / T&F 已内置但未实测,RSC 暂不支持)。IdP 的使用条款页会被自动勾选同意,属性发布会按出版商记住。
- **FlareSolverr**:直连出版商(OA 页面、PDF)遇到 Cloudflare 挑战时,由 FlareSolverr 求解,再把 cookie 交给 requests 下载(实测 ACS 可以)。要求:服务与 openpaper 出口相同(host 网络),且 Chromium 禁用 QUIC(策略 `QuicAllowed: false`)。
- 浏览器统一使用 `--disable-quic`:HTTP/3 会绕过透明代理(如 OpenClash),导致出口 IP 跳变,Cloudflare 会因此反复挑战。
### 易安联隧道(EnLink 全隧道)
WebVPN 反代出去时,Cloudflare 看到的是网关的 TLS 指纹(HTTP/1.1),很多出版商会因此一直弹挑战。隧道模式用 [openenlink](https://github.com/Snowflyt/openenlink) 建立和客户端(SwordAgent)一样的全隧道,在本机开一个 SOCKS5 代理(`127.0.0.1:1088`)。这样出网是学校 IP,TLS 指纹是本机浏览器自己的,CF 不再拦截。
- 隧道 token 由 openpaper 自动获取:先用钥匙环里的账号无头登录 WebVPN,再调用 `/enlink/api/client/user/terminal/rules/<userId>`。token 只通过子进程的 stdin 传给 openenlink,不会出现在 argv、日志或文件里。
- openenlink 以 git 子模块 `vendor/openenlink` 随仓库分发([IoriAkatsuki/openenlink](https://github.com/IoriAkatsuki/openenlink/tree/njupt) 的 `njupt` 分支,含 `connect` 子命令与 DNS 失败缓存,已向上游提 PR)。一条命令安装:
```bash
openpaper tunnel install
```
它会初始化子模块(用 pip 安装、没有子模块时克隆到 `~/.openpaper/openenlink`),在找不到 Node.js 26.9+ 时下载官方 Node 到 `~/.openpaper/node`,再 `npm install` 编译 TCP/IP 栈(首次需几分钟,需要 git、curl、tar)。
- 配置(`~/.openpaper/config.json`):
```json
{
"tunnel_enabled": true,
"tunnel_proxy_url": "socks5h://127.0.0.1:1088"
}
```
`tunnel_command` 留空即自动使用安装好的 openenlink;要用别处的 openenlink 时再填,例如 `"node /path/to/openenlink/src/cli.ts"`。
- 管理命令:`openpaper tunnel up | down | status`(`run` 在前台运行监管进程,供 systemd 调用)。监管进程掉线后会按退避重启;监管代码已适配 Windows / macOS(未实测)。
- 开机自启(仅 Linux):把 `contrib/openpaper-tunnel.service` 复制到 `~/.config/systemd/user/`,然后执行 `systemctl --user enable --now openpaper-tunnel`。
- 隧道健康时,出版商流量直接走代理,不做 WebVPN URL 转换;隧道不健康时,本次抓取自动回退 WebVPN → CARSI → FlareSolverr。
- ScienceDirect(Elsevier)走隧道时用 CloakBrowser 无头浏览器:文章页和 `pdf.sciencedirectassets.com` 各有一道 Cloudflare Turnstile,会自动点击复选框;按 PII 找本文的 `pdfft` 链接,跳到 PDF 域后在页内 fetch。直接 fetch pdfft 或用 requests 请求都会被判为机器人(403)。
- 南邮实测:IEEE、Wiley、Elsevier 走隧道都能下载 PDF(Elsevier 冷启动 15–60 秒,不需要 API key);T&F 因南邮未订阅未实测(仅返回摘要,代码已内置适配);RSC 的 id.rsc.org 无法访问。
FlareSolverr 的 podman quadlet 和 Chromium 禁用 QUIC 的策略见 `contrib/flaresolverr.container` 和 `contrib/flaresolverr-policies/`。
## 免责声明
本项目是学术论文获取工具,帮助高校师生合法访问机构已订阅的学术资源。不包含任何 VPN 协议实现,不提供 VPN 连接功能。使用者应遵守相关法律法规和学校网络使用规范。
## 致谢
派生自 [Rimagination/vpnsci](https://github.com/Rimagination/vpnsci)(现名 [instsci](https://github.com/Rimagination/instsci),MIT)。隧道依赖 [Snowflyt/openenlink](https://github.com/Snowflyt/openenlink)(AGPL-3.0,仅作外部进程调用,不含其代码),浏览器使用 [CloakBrowser](https://github.com/CloakHQ/cloakbrowser),可选 [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr)。另外感谢:
- [webvpn-converter](https://github.com/lcandy2/webvpn-converter) — 学校配置数据
- [Tuna-Erha-Bot](https://github.com/Konano/Tuna-Erha-Bot) — WebVPN 加密算法
- [ZJUWebVPN](https://github.com/eWloYW8/ZJUWebVPN) — 动态密钥方案
- [CASPaperTunneling](https://github.com/qiyang-ustc/CASPaperTunneling) — CAS 认证流程
## English
**OpenPaper** is an MCP server and CLI that lets AI agents (Claude Code, Codex, Antigravity, Cursor…) fetch full-text papers through *your* university subscription, fully headless.
- **Open-access first** (Unpaywall, arXiv), then institutional access via EnLink full tunnel, WebVPN, EZproxy, EasyConnect, aTrust, or CARSI (set up with `openpaper config-cmd --carsi-idp-entity-id <IdP>`; browser mode tested on Wiley, built in but untested for ACS and Taylor & Francis) — with built-in configs for 100+ Chinese universities.
- **Headless auto-login**: credentials are stored in the system keyring (Windows Credential Manager, macOS Keychain, or Linux `secret-tool`/libsecret with Python `keyring` fallback), so expired sessions renew themselves without any pop-up (tested on Linux; Windows/macOS support is implemented in code but untested live).
- **Cloudflare-proof**: an EnLink full tunnel (school egress IP) plus CloakBrowser's real-browser fingerprint (auto-downloaded on first run), with automatic Turnstile clicks. Elsevier/ScienceDirect PDFs download **without an API key**.
- **Tested at NJUPT**: IEEE, Wiley, Elsevier, Nature, and Springer return PDFs (ACS is intermittent / OA works; RSC is blocked at `id.rsc.org`; Taylor & Francis is untested due to no NJUPT subscription, though adapter code is built in).
Requirements: Python >= 3.10 (`keyring>=25.0.0` is included in dependencies; Node.js + [openenlink `njupt` branch](https://github.com/IoriAkatsuki/openenlink/tree/njupt) for the EnLink tunnel — the tunnel supervisor is cross-platform in code, `systemd` auto-start is Linux-only, and Windows/macOS live runs are untested).
```bash
uv tool install git+https://github.com/IoriAkatsuki/openpaper.git
# or: pipx install git+https://github.com/IoriAkatsuki/openpaper.git
openpaper config-cmd --school <your-school>
openpaper save-credentials # System keyring (Win / macOS / Linux)
claude mcp add openpaper -s user -- openpaper-mcp
```
See [FAQ.md](FAQ.md) (in Chinese) for common questions.
Derived from [Rimagination/vpnsci](https://github.com/Rimagination/vpnsci) (now instsci, MIT). For legitimate access to resources your institution already subscribes to.
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues