Zotero Local Import Skill (Windows / macOS / Linux)
Before using this skill, make sure Zotero Desktop is open and configured:
- Open Zotero → Settings → Advanced
- Enable: Allow other applications on this computer to communicate with Zotero
- Note the connector port (commonly
23119) and provide it to the agent via--port
This skill only imports into existing collections. It does not create collections. If
--collectionis not provided, imports default to My Library.
Script location
scripts/zotero_tool.py
Features
- Import a single PDF
- Import all PDFs in a folder (optional recursive mode)
- Import into an existing collection
- List local Zotero collections
- Check recently imported attachments (read-only from
zotero.sqlite)
Agent pre-execution contract (foolproof mode)
The agent must support all of the following user input forms and complete import automatically:
- A folder path
- A single PDF path
- Multiple PDF paths
- A few PDFs inside a folder (user can provide file names such as
x.pdf, y.pdf, z.pdf)
The agent must also collect:
- Zotero local connector port
- Optional collection name (if omitted, default to My Library)
Required execution flow:
- Run
doctor --auto-install-deps - If successful, run
import
Natural-language parsing (paths, file names, port, collection) must be handled by the agent, not by the script. The script accepts structured arguments only.
Command usage
Run from repository root (or use absolute script path):
python skills/zotero-local-import-en/scripts/zotero_tool.py --help
0) Environment check (mandatory)
python skills/zotero-local-import-en/scripts/zotero_tool.py doctor \
--port <USER_ZOTERO_PORT> \
--auto-install-deps
This checks and auto-handles:
- Python runtime availability
requestsdependency (auto-installs if missing)http://127.0.0.1:<port>/connector/pingconnectivity- Platform URL opener availability (Windows:
os.startfile, macOS:open, Linux:xdg-open)
If auto-install fails, the agent should surface the error and suggest:
python -m pip install requests>=2.31.0
NL) Natural-language input policy (agent-side parsing only)
Users may say things like:
- “Import
x.pdf, y.pdf, z.pdffrom<folder>, portxxxx, collectionxxxx” - “Import this PDF:
<absolute path>, portxxxx”
The agent must convert NL input into structured CLI args, then call import:
- Folder mode:
--dir+ optional--pick - Single/multiple PDF mode: repeated
--pdf - Port:
--port - Collection: optional
--collection(defaults to My Library)
A) Import a single PDF
python skills/zotero-local-import-en/scripts/zotero_tool.py import \
--pdf "<ABSOLUTE_PDF_PATH>" \
--port <USER_ZOTERO_PORT>
A2) Import multiple PDFs (repeat --pdf)
python skills/zotero-local-import-en/scripts/zotero_tool.py import \
--pdf "<PDF_PATH_1>" \
--pdf "<PDF_PATH_2>" \
--pdf "<PDF_PATH_3>" \
--port <USER_ZOTERO_PORT>
B) Batch import a folder (non-recursive)
python skills/zotero-local-import-en/scripts/zotero_tool.py import \
--dir "<ABSOLUTE_FOLDER_PATH>" \
--port <USER_ZOTERO_PORT>
C) Batch import a folder (recursive)
python skills/zotero-local-import-en/scripts/zotero_tool.py import \
--dir "<ABSOLUTE_FOLDER_PATH>" \
--recursive \
--port <USER_ZOTERO_PORT>
D) Import into a specific existing collection
python skills/zotero-local-import-en/scripts/zotero_tool.py import \
--dir "<ABSOLUTE_FOLDER_PATH>" \
--recursive \
--collection "<EXISTING_COLLECTION_NAME>" \
--port <USER_ZOTERO_PORT>
D2) Import selected PDFs from a folder (CSV file names)
python skills/zotero-local-import-en/scripts/zotero_tool.py import \
--dir "<ABSOLUTE_FOLDER_PATH>" \
--pick "x.pdf,y.pdf,z.pdf" \
--collection "<EXISTING_COLLECTION_NAME>" \
--port <USER_ZOTERO_PORT>
Or repeat --pick:
python skills/zotero-local-import-en/scripts/zotero_tool.py import \
--dir "<ABSOLUTE_FOLDER_PATH>" \
--pick "x.pdf" \
--pick "y.pdf" \
--pick "z.pdf" \
--port <USER_ZOTERO_PORT>
E) List local collections
python skills/zotero-local-import-en/scripts/zotero_tool.py list-collections --port <USER_ZOTERO_PORT>
F) Check recently imported attachments
python skills/zotero-local-import-en/scripts/zotero_tool.py check --limit 10
Key parameters
--port: Zotero connector port (provided by user; defaults toZOTERO_PORTenv var, fallback23119)--timeout: HTTP timeout in seconds (default90)--collection: target existing collection name--db:zotero.sqlitepath (override forcheck)
Platform notes
- Windows: supported by default
- macOS: requires
open - Linux: requires
xdg-open
Failure handling
error=collection not found: create the collection manually in Zotero first- Connection failures: verify Zotero is running, local-app communication is enabled, and port is correct
- Import failures: retry with one PDF first, then run batch import