cli-anything-zotero

CLI & MCP server for Zotero 7/8 — 52 tools to let AI manage your research library locally. Search, import, export, PDF, notes, and more.

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 — 52 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.


Choose Your Mode

This tool supports two modes. Pick the one that fits your AI client:

CLI ModeMCP Mode
How AI calls itShell commands (cli-anything-zotero item find ...)Structured tool calls (no command-line needed)
Works withAny AI that can run shell commands (Claude Code, ChatGPT, Cursor, Windsurf, Cline, etc.)AI clients with MCP support (Claude Desktop, Cursor, Claude Code, LM Studio, etc.)
AI learning curveAI runs --help once to discover all 70+ commandsZero — 52 tools are auto-registered with typed parameters
Error rateOccasional typos by AI (self-corrects)Near-zero (parameters are type-constrained)
Installpip install cli-anything-zoteropip install 'cli-anything-zotero[mcp]' + client config

Not sure? If your AI client supports MCP, choose MCP — it's more reliable. Otherwise, CLI works everywhere.


Installation

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

Step 1: Install the package

CLI Mode (for any AI assistant):

pip install cli-anything-zotero

MCP Mode (for Claude Desktop, Cursor, Claude Code, etc.):

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

Both modes are included in the same package. The [mcp] extra just adds MCP protocol dependencies.

Step 2: Install the JS Bridge Plugin (one-time, both modes)

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.

Step 3: Set up your AI client

CLI Mode — No extra setup needed

Just tell your AI assistant the tool is available. It will run cli-anything-zotero --help to discover all commands automatically.

Verify it works:

cli-anything-zotero app ping
cli-anything-zotero js "return Zotero.version"
MCP Mode — Configure your AI client

Claude Code:

claude mcp add zotero --scope user -- cli-anything-zotero mcp serve

Claude Desktop / Cursor / LM Studio — add to your MCP config file:

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

After restarting your AI client, 52 Zotero tools will be available automatically.

Full MCP reference: docs/MCP.md

Troubleshooting

ProblemSolution
Cannot resolve Zotero profile directoryLaunch Zotero at least once first
Plugin not appearingRestart Zotero after installing the .xpi
endpoint_active: falsePlugin failed to load — reinstall via Zotero UI
Windows: pip not recognizedClose and reopen PowerShell after installing Python

Usage (CLI Mode)

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


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
VariableDefaultDescription
ZOTERO_EMBED_APIhttp://127.0.0.1:8080/v1/embeddingsEmbedding API endpoint
ZOTERO_EMBED_MODELnomic-embed-textModel 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?"

Upgrading to 0.4.0

Breaking change for MCP users: All MCP tool names have been renamed from mixed conventions to a consistent group_action pattern matching the CLI. If you have agent prompts or configs referencing old tool names, update them:

MCP tool rename table (click to expand)
Old name (0.3.x)New name (0.4.0)
list_librarieslibrary_list
list_collectionscollection_list
find_collectionscollection_find
get_collectioncollection_get
create_collectioncollection_create
delete_collectioncollection_delete
update_collectioncollection_rename
find_pdfs_in_collectioncollection_find_pdfs
remove_from_collectioncollection_remove_item
list_itemsitem_list
find_itemsitem_find
get_itemitem_get
export_itemitem_export
citation_itemitem_citation
bibliography_itemitem_bibliography
manage_tagsitem_tag
update_item_fieldsitem_update
delete_itemitem_delete
find_pdfitem_find_pdf
attach_pdfitem_attach
add_to_collectionitem_add_to_collection
get_annotationsitem_annotations
search_annotationsitem_search_annotations
search_fulltextitem_search_fulltext
semantic_searchitem_semantic_search
find_similaritem_similar
build_indexitem_build_index
find_duplicatesitem_duplicates
get_citation_metricsitem_metrics
analyze_itemitem_analyze
get_notenote_get
add_notenote_add
list_tagstag_list
list_searchessearch_list
list_stylesstyle_list
import_from_doiimport_doi
import_from_pmidimport_pmid
trigger_syncsync
execute_jsjs

New tools in 0.4.0: search_get, search_items, item_move_to_collection

CLI users: No breaking changes. The --help output now shows all commands at once.


Related Projects

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

cli-anything-zoterozotero-mcpzotero-cli-ccpyzotero-cli
ApproachLocal JS BridgeWeb API + MCPWeb API + CLIWeb API + CLI
Best forLocal-first, full controlMCP-native workflowsAgent-driven researchScripting & automation
Write opsLocal (no API key)Via Web APIVia Web APIVia Web API
MCP support52 toolsYes45 toolsNo
Terminal CLIYesNoYesYes
Zotero JS accessYesNoNoNo
LicenseApache 2.0MITCC BY-NC 4.0MIT

License

Apache 2.0

Related Servers

NotebookLM Web Importer

Import web pages and YouTube videos to NotebookLM with one click. Trusted by 200,000+ users.

Install Chrome Extension