CLI for Zotero 7/8 — let AI manage your library. 40+ commands for search, import, PDF, BibTeX export, and more.
Project description
cli-anything-zotero
Let AI manage your Zotero library.
中文文档 | English | WeChat Group 👇
For Non-Programmers: You Don't Need to Read This Whole Page
This tool is designed to be used by AI, not memorized by you. After a simple install (takes ~3 minutes), you just talk to your AI assistant in plain language:
"Help me find papers about diabetes and kidney disease in my Zotero library"
"Import this DOI into my CKM collection: 10.1038/s41586-024-07871-6"
"Export all papers in my thesis collection as BibTeX"
"Find PDFs for all items in my review collection that are missing them"
"Summarize the key findings of this paper: ITEM_KEY"
The AI reads the command reference automatically -- you never need to. Just install it and start asking.
All you need to do:
- Follow the Installation steps below (Python + one Zotero plugin)
- Tell your AI assistant (Claude Code, Cursor, etc.) what you need
- That's it
对非程序员朋友的说明
这个工具不需要你记住任何命令,安装完之后直接用中文告诉 AI 你想做什么就行:
"帮我在 Zotero 里搜一下关于糖尿病和肾病的文献"
"把这个 DOI 导入到我的 CKM 合集里:10.1038/s41586-024-07871-6"
"把毕业论文合集里的文献全部导出成 BibTeX"
"帮我找一下综述合集里缺 PDF 的文献,自动下载"
"总结一下这篇文章的主要发现"
你只需要:
- 按照下面的安装步骤装好(Python + 一个 Zotero 插件,3 分钟)
- 打开你的 AI 工具(Claude Code、Cursor 等),用自然语言说你想做什么
- 没了
Built on CLI-Anything by HKUDS. Designed for AI agents (Claude Code, Cursor, Codex, etc.) and power users.
Why This Tool?
Zotero's built-in HTTP server was designed for browser extensions, not for AI agents or CLI workflows. It has no API for attaching PDFs, updating metadata, triggering sync, or running full-text search.
This CLI fills those gaps through a JS Bridge -- a lightweight Zotero plugin that exposes a privileged JavaScript endpoint. Zero UI popup, millisecond response.
Installation
Prerequisites: Python 3.10+, Zotero 7/8 (running). No other system tools needed.
1. Install the CLI
pip install cli-anything-zotero
Or install from source:
git clone https://github.com/PiaoyangGuohai1/cli-anything-zotero.git
cd cli-anything-zotero && pip install -e .
2. Install the JS Bridge Plugin (one-time)
cli-anything-zotero app install-plugin
First install requires manual steps in Zotero:
- The command generates a
.xpifile and prints its path - In Zotero: Tools -> Plugins -> gear icon -> Install Plugin From File...
- Select the
.xpifile, then restart Zotero
After the first install, future upgrades via
app install-pluginare automatic.
3. Verify
cli-anything-zotero app plugin-status --json
# Should show: "plugin_installed": true, "endpoint_active": true
cli-anything-zotero app ping
cli-anything-zotero js "return Zotero.version"
Troubleshooting
| Problem | Solution |
|---|---|
Cannot resolve Zotero profile directory |
Launch Zotero at least once first |
| Plugin not appearing | Restart Zotero after installing the .xpi |
endpoint_active: false |
Plugin failed to load -- reinstall via Zotero UI |
Windows: pip not recognized |
Close and reopen PowerShell after installing Python |
Core Features
Everything below works out of the box after installation. No extra services needed.
Search & Browse
cli-anything-zotero item find "machine learning" # keyword search
cli-anything-zotero item search-fulltext "CRISPR" # search inside PDFs
cli-anything-zotero collection tree # browse collection hierarchy
Import
cli-anything-zotero import doi "10.1038/s41586-024-07871-6" --tag "review"
cli-anything-zotero import pmid "37821702" --collection FMTCPUWN
cli-anything-zotero import file ./refs.ris
Read & Export
cli-anything-zotero item get ITEM_KEY # full metadata
cli-anything-zotero item export ITEM_KEY --format bibtex
cli-anything-zotero item citation ITEM_KEY # formatted citation
cli-anything-zotero item context ITEM_KEY # LLM-ready context
Write & Manage
cli-anything-zotero item update KEY --field title="New Title"
cli-anything-zotero item tag KEY --add "important"
cli-anything-zotero item attach KEY ./paper.pdf
cli-anything-zotero item find-pdf KEY # auto-find PDF online
cli-anything-zotero note add KEY --text "My note"
cli-anything-zotero sync
Advanced
cli-anything-zotero item search-annotations "risk" # search all highlights
cli-anything-zotero item annotations KEY # view PDF annotations
cli-anything-zotero item metrics KEY # NIH citation metrics
cli-anything-zotero collection stats COLLECTION_KEY # collection statistics
cli-anything-zotero js "return await Zotero.Items.getAll(1).then(i => i.length)"
Optional Features
These require extra services. Everything else works without them.
Semantic Search -- requires an embedding API
Any OpenAI-compatible /v1/embeddings endpoint (Ollama, LM Studio, OpenAI, etc.).
# 1. Build the vector index (one-time)
cli-anything-zotero item build-index
# 2. Search
cli-anything-zotero item semantic-search "cardiovascular risk prediction"
cli-anything-zotero item similar ITEM_KEY
| Variable | Default | Description |
|---|---|---|
ZOTERO_EMBED_API |
http://127.0.0.1:8080/v1/embeddings |
Embedding API endpoint |
ZOTERO_EMBED_MODEL |
nomic-embed-text |
Model name |
ZOTERO_EMBED_KEY |
(empty) | API key (if needed) |
AI Analysis -- requires OpenAI API key
export OPENAI_API_KEY=sk-...
cli-anything-zotero item analyze ITEM_KEY --question "What are the main findings?"
Full Command Reference
40+ commands across 12 groups. See docs/COMMANDS.md for the complete reference.
License
Apache 2.0 -- same as CLI-Anything.
中文文档
让 AI 帮你管理 Zotero 文献库。
基于 CLI-Anything 框架。专为 AI Agent 和高级用户设计。
为什么需要这个工具?
Zotero 内置 HTTP 服务只为浏览器扩展设计,无法添加 PDF、更新元数据、触发同步或全文搜索。本工具通过 JS 桥填补这些空缺 -- 零弹窗、毫秒级响应。
安装
前提: Python 3.10+,Zotero 7/8(运行中)。无需其他系统工具。
第一步:安装 CLI
pip install cli-anything-zotero
第二步:安装 JS 桥插件(一次性操作)
cli-anything-zotero app install-plugin
首次安装需要在 Zotero 中手动导入:
- 上面的命令会生成一个
.xpi文件并显示路径 - 在 Zotero 中:工具 -> 插件 -> 齿轮图标 -> Install Plugin From File...
- 选择
.xpi文件,重启 Zotero
装好后以后升级都是自动的。
第三步:验证
cli-anything-zotero app plugin-status --json
cli-anything-zotero app ping
核心功能
安装完成后开箱即用,无需额外服务。
# 搜索
cli-anything-zotero item find "机器学习"
cli-anything-zotero item search-fulltext "CRISPR"
cli-anything-zotero collection tree
# 导入
cli-anything-zotero import doi "10.1038/s41586-024-07871-6" --tag "综述"
cli-anything-zotero import pmid "37821702"
# 读取与导出
cli-anything-zotero item get ITEM_KEY
cli-anything-zotero item export ITEM_KEY --format bibtex
cli-anything-zotero item context ITEM_KEY # LLM 友好格式
# 写入与管理
cli-anything-zotero item update KEY --field title="新标题"
cli-anything-zotero item attach KEY ./论文.pdf
cli-anything-zotero note add KEY --text "我的笔记"
cli-anything-zotero sync
可选功能
| 功能 | 需要 | 命令 |
|---|---|---|
| 语义搜索 | 嵌入 API(Ollama/LM Studio 等) | item semantic-search, item similar, item build-index |
| AI 分析 | OPENAI_API_KEY |
item analyze |
完整命令参考
40+ 命令,12 个分组。详见 docs/COMMANDS.md。
许可证
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cli_anything_zotero-0.2.1.tar.gz.
File metadata
- Download URL: cli_anything_zotero-0.2.1.tar.gz
- Upload date:
- Size: 97.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cabbd9b955c0f2302cf60520b4c589471a71a4b7de52cc1ecbbd3bf0e58e209
|
|
| MD5 |
174770e13e5cedbdd2af64710bc2f97c
|
|
| BLAKE2b-256 |
a1c3f6db833508a87691a3b5c58c2fd6554e8229121788d1f0e0c3819afc4305
|
File details
Details for the file cli_anything_zotero-0.2.1-py3-none-any.whl.
File metadata
- Download URL: cli_anything_zotero-0.2.1-py3-none-any.whl
- Upload date:
- Size: 105.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0516d2c896a6211791bdbd82f060045680fc6223cfac177be8ccf4bd12ae32c
|
|
| MD5 |
bdd51d96bd68becd496ab549d31b442a
|
|
| BLAKE2b-256 |
b5f04c38240b50a3e564399025ae9ecdf0f8d1763549640eb9485540e1945a04
|