Skip to main content

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

PyPI Python 3.10+ License GitHub release GitHub stars

Let AI manage your Zotero library.

中文文档 | English


For Non-Programmers

This tool is designed to be used by AI, not memorized by you. After a simple install (~3 minutes), just talk to your AI assistant in plain language:

"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 items in my review collection that are missing them"

All you need to do:

  1. Follow the Installation steps below
  2. Tell your AI assistant (Claude Code, Cursor, etc.) what you need
  3. That's it

What It Does

Built on CLI-Anything by HKUDS, this tool gives AI agents full access to your local Zotero library through a JS Bridge — a lightweight Zotero plugin that exposes a privileged JavaScript endpoint.

Key capabilities:

  • Search & browse — keyword search, full-text PDF search, collection tree, tags
  • Import — from DOI, PMID, RIS/BibTeX files, or JSON
  • Export — BibTeX, CSL-JSON, RIS, CSV, formatted citations
  • PDF management — attach files, auto-find PDFs online, search annotations
  • Write operations — update metadata, manage tags, add notes, trigger sync
  • Advanced — execute arbitrary Zotero JS, semantic search with local embeddings, AI analysis
  • MCP server — 49 tools for Claude Desktop, Cursor, LM Studio, and other MCP clients

All write operations run locally through the JS Bridge — no API key or internet connection required.


Installation

Prerequisites: Python 3.10+, Zotero 7/8 (running).

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:

  1. The command generates a .xpi file and prints its path
  2. In Zotero: Tools → Plugins → gear icon → Install Plugin From File...
  3. Select the .xpi file, then restart Zotero

After the first install, future upgrades via app install-plugin are 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

Usage

Search & Browse

cli-anything-zotero item find "machine learning"
cli-anything-zotero item search-fulltext "CRISPR"
cli-anything-zotero collection tree

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
cli-anything-zotero item export ITEM_KEY --format bibtex
cli-anything-zotero item citation ITEM_KEY
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
cli-anything-zotero note add KEY --text "My note"
cli-anything-zotero sync

Advanced

cli-anything-zotero item search-annotations "risk"
cli-anything-zotero item annotations KEY
cli-anything-zotero item metrics KEY                   # NIH citation metrics
cli-anything-zotero collection stats COLLECTION_KEY
cli-anything-zotero js "return await Zotero.Items.getAll(1).then(i => i.length)"

Full command reference: docs/COMMANDS.md


MCP Server

49 tools for AI clients that support the Model Context Protocol. Full reference: docs/MCP.md

pip install 'cli-anything-zotero[mcp]'
zotero-cli mcp serve

Client configuration (Claude Desktop / Cursor / LM Studio):

{
  "mcpServers": {
    "zotero": {
      "command": "zotero-cli",
      "args": ["mcp", "serve"]
    }
  }
}

Optional Features

These require extra services. Everything else works without them.

Semantic Search

Any OpenAI-compatible /v1/embeddings endpoint (Ollama, LM Studio, OpenAI, etc.).

cli-anything-zotero item build-index                            # one-time
cli-anything-zotero item semantic-search "cardiovascular risk"
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

export OPENAI_API_KEY=sk-...
cli-anything-zotero item analyze ITEM_KEY --question "What are the main findings?"

Related Projects

There are several great tools in the Zotero ecosystem. Each has different strengths depending on your use case:

cli-anything-zotero zotero-mcp zotero-cli-cc pyzotero-cli
Approach Local JS Bridge Web API + MCP Web API + CLI Web API + CLI
Best for Local-first, full control MCP-native workflows Agent-driven research Scripting & automation
Write ops Local (no API key) Via Web API Via Web API Via Web API
MCP support 49 tools Yes 45 tools No
Terminal CLI Yes No Yes Yes
Zotero JS access Yes No No No
License Apache 2.0 MIT CC BY-NC 4.0 MIT

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli_anything_zotero-0.3.4.tar.gz (99.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cli_anything_zotero-0.3.4-py3-none-any.whl (109.8 kB view details)

Uploaded Python 3

File details

Details for the file cli_anything_zotero-0.3.4.tar.gz.

File metadata

  • Download URL: cli_anything_zotero-0.3.4.tar.gz
  • Upload date:
  • Size: 99.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for cli_anything_zotero-0.3.4.tar.gz
Algorithm Hash digest
SHA256 93b905cc8dffbf6f0b1c6d8b95a9b57efe352d0de36df85989b0262ae9df8773
MD5 1c6defdd8c76fffceb6799c82920f126
BLAKE2b-256 d4f00d0f4bb73b76a3366f2908141054bbac0da765a2a28eb5ccf46150d7161b

See more details on using hashes here.

File details

Details for the file cli_anything_zotero-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for cli_anything_zotero-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 41f3430cdc5a2b578b00919836fd0aa7382b265dba623df7a63b2e49f20b331d
MD5 dd88cb1f8803df77a5e0c0b6491c19e7
BLAKE2b-256 3a8de815b92a7f6f300e394a9395fa1e510642836300ce220de2041ecfd37a7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page