pyzotero-cli

0
0
Source

Command-line interface for Zotero - search your local Zotero library, list collections, and manage items from the terminal.

Install

mkdir -p .claude/skills/pyzotero-cli && curl -L -o skill.zip "https://mcp.directory/api/skills/download/8493" && unzip -o skill.zip -d .claude/skills/pyzotero-cli && rm skill.zip

Installs to .claude/skills/pyzotero-cli

About this skill

Pyzotero CLI - Python Scripts

使用 Python 脚本调用 pyzotero 库,支持本地 Zotero API 和在线 Web API 两种模式。

快速开始

# 安装 pyzotero 库
pipx install pyzotero

# 设置环境变量 (可选)
export ZOTERO_LOCAL="true"  # 使用本地 API (默认)
# export ZOTERO_LOCAL="false"  # 使用在线 API

# 搜索库
python3 scripts/zotero_tool.py search -q "machine learning"

# 全文搜索 (包括 PDF)
python3 scripts/zotero_tool.py search -q "attention mechanisms" --fulltext

# 列出所有集合
python3 scripts/zotero_tool.py listcollections

📖 详细指南: QUICKSTART.md

环境变量配置

ZOTERO_LOCAL (必需)

控制使用本地 API 还是在线 API:

模式说明
"true" (默认)本地模式使用本地 Zotero 7+ 的本地 API
"false"在线模式使用 Zotero Web API

ZOTERO_USER_ID (在线模式必需)

您的 Zotero 用户 ID,在在线模式下需要设置。

ZOTERO_API_KEY (在线模式必需)

您的 Zotero API Key,在在线模式下需要设置。

配置示例

本地模式 (推荐):

export ZOTERO_LOCAL="true"
python3 scripts/zotero_tool.py search -q "python"

在线模式:

export ZOTERO_LOCAL="false"
export ZOTERO_USER_ID="your_user_id"
export ZOTERO_API_KEY="your_api_key"
python3 scripts/zotero_tool.py search -q "python"

安装

pipx (推荐)

pipx install pyzotero

pip (通用)

pip install --user pyzotero
export PATH="$HOME/.local/bin:$PATH"

📖 完整安装指南: INSTALL.md

前提条件

本地模式配置

需要在 Zotero 7+ 中启用本地 API:

  1. 打开 Zotero 7 (或更新版本)
  2. 进入 编辑 > 首选项 > 高级 (macOS: Zotero > 设置 > 高级)
  3. 勾选 "允许此计算机上的其他应用程序与 Zotero 通信"
  4. 重启 Zotero

在线模式配置

需要获取 API 密钥:

  1. 访问 https://www.zotero.org/settings/keys
  2. 点击 "Create new private key"
  3. 授予读取权限 (Read access to library and files)
  4. 复制密钥并设置环境变量:
    export ZOTERO_USER_ID="your_user_id"
    export ZOTERO_API_KEY="your_key"
    

核心命令

命令说明
python3 scripts/zotero_tool.py search -q "关键词"搜索库
python3 scripts/zotero_tool.py search --fulltext全文搜索 (包括 PDF)
python3 scripts/zotero_tool.py search --collection ID在特定集合中搜索
python3 scripts/zotero_tool.py listcollections列出所有集合
python3 scripts/zotero_tool.py itemtypes列出项目类型
python3 scripts/zotero_tool.py item KEY获取单个项目详情
python3 scripts/zotero_tool.py add -t "标题"添加单个项目
python3 scripts/zotero_tool.py add-from-json file.json批量添加项目
python3 scripts/zotero_tool.py collection-create -n "名称"创建新集合
python3 scripts/zotero_tool.py collection-rename KEY -n "新名"重命名集合
python3 scripts/zotero_tool.py collection-delete KEY -y删除集合
python3 scripts/zotero_tool.py collection-add-item ITEM -c COLL添加项目到集合
python3 scripts/zotero_tool.py collection-remove-item ITEM -c COLL从集合移除项目
python3 scripts/zotero_tool.py collection-list KEY列出集合中的项目

使用示例

基本搜索

# 搜索标题和元数据
python3 scripts/zotero_tool.py search -q "machine learning"

# 短语搜索
python3 scripts/zotero_tool.py search -q "\"deep learning\""

全文搜索

# 在 PDF 和附件中搜索
python3 scripts/zotero_tool.py search -q "neural networks" --fulltext

高级过滤

# 按项目类型过滤
python3 scripts/zotero_tool.py search -q "methodology" --itemtype book

# 在特定集合中搜索
python3 scripts/zotero_tool.py search --collection ABC123 -q "test"

# 限制结果数量
python3 scripts/zotero_tool.py search -q "python" -l 10

获取项目详情

# 获取单个项目
python3 scripts/zotero_tool.py item ABC123XYZ

添加单个项目

# 添加期刊文章
python3 scripts/zotero_tool.py add -t "文章标题" -a "FirstName LastName" -p "期刊名" -d "2024"

# 添加带 DOI 和标签的文章
python3 scripts/zotero_tool.py add -t "AI 在医学中的应用" -a "张三" "李四" -p "中华医学杂志" -d "2024" --doi "10.xxxx/xxxxx" --tags AI 医学 machine-learning

# 添加带摘要和 URL 的文章
python3 scripts/zotero_tool.py add -t "Python 数据分析" -a "王五" -p "计算机学报" -d "2024" --url "https://example.com" --abstract "本文介绍了..." --tags python 数据分析

批量添加项目

# 从 JSON 文件批量添加
python3 scripts/zotero_tool.py add-from-json papers.json

# JSON 文件格式示例:
[
  {
    "itemType": "journalArticle",
    "title": "文章标题",
    "creators": [{"firstName": "First", "lastName": "Last", "creatorType": "author"}],
    "publicationTitle": "期刊名",
    "date": "2024",
    "DOI": "10.xxxx/xxxxx",
    "tags": [{"tag": "tag1", "type": 1}],
    "abstractNote": "摘要"
  }
]

集合管理

# 创建新集合
python3 scripts/zotero_tool.py collection-create -n "新集合名称"

# 创建子集合
python3 scripts/zotero_tool.py collection-create -n "子集合" -p PARENT_KEY

# 重命名集合
python3 scripts/zotero_tool.py collection-rename COLLECTION_KEY -n "新名称"

# 删除集合(需要确认)
python3 scripts/zotero_tool.py collection-delete COLLECTION_KEY
python3 scripts/zotero_tool.py collection-delete COLLECTION_KEY -y  # 跳过确认

# 添加项目到集合
python3 scripts/zotero_tool.py collection-add-item ITEM_KEY -c COLLECTION_KEY

# 从集合移除项目
python3 scripts/zotero_tool.py collection-remove-item ITEM_KEY -c COLLECTION_KEY

# 列出集合中的项目
python3 scripts/zotero_tool.py collection-list COLLECTION_KEY
python3 scripts/zotero_tool.py collection-list COLLECTION_KEY -l 50  # 显示 50 个

输出格式

人类可读格式 (默认)

python3 scripts/zotero_tool.py search -q "python"

JSON 输出

# 输出 JSON 格式
python3 scripts/zotero_tool.py search -q "topic" --json

# 使用 jq 处理
python3 scripts/zotero_tool.py search -q "topic" --json | jq '.[].data.title'

# 保存到文件
python3 scripts/zotero_tool.py search -q "topic" --json > results.json

文档

文档说明
QUICKSTART.md5 分钟快速入门
INSTALL.md详细安装指南
EXAMPLES.md实用使用示例
README.md项目概览

故障排除

本地模式连接错误:

确保 Zotero 正在运行
启用本地 API: 设置 > 高级 > "允许此计算机上的其他应用程序与 Zotero 通信"
重启 Zotero

在线模式认证错误:

# 检查环境变量是否正确设置
echo $ZOTERO_USER_ID
echo $ZOTERO_API_KEY

# 确认 ZOTERO_LOCAL 设置为 false
export ZOTERO_LOCAL="false"

模块未找到错误:

# 确保已安装 pyzotero
pipx install pyzotero
# 或
pip install --user pyzotero

权限错误 (PEP 668 系统):

pipx install pyzotero

📖 详细故障排除: INSTALL.md

快速参考

# 设置模式
export ZOTERO_LOCAL="true"   # 本地模式 (默认)
export ZOTERO_LOCAL="false"  # 在线模式

# 在线模式需要额外设置
export ZOTERO_USER_ID="your_id"
export ZOTERO_API_KEY="your_key"

# 搜索
python3 scripts/zotero_tool.py search -q "topic"
python3 scripts/zotero_tool.py search -q "topic" --fulltext
python3 scripts/zotero_tool.py search -q "topic" --json

# 列表
python3 scripts/zotero_tool.py listcollections
python3 scripts/zotero_tool.py itemtypes

# 获取项目
python3 scripts/zotero_tool.py item ITEM_KEY

# 过滤
python3 scripts/zotero_tool.py search -q "topic" --itemtype journalArticle
python3 scripts/zotero_tool.py search --collection ABC123 -q "topic"

完整文档:

脚本说明

本技能提供 Python 脚本 scripts/zotero_tool.py,通过 pyzotero 库与 Zotero 交互:

  • 本地模式 (ZOTERO_LOCAL="true"): 直接连接到运行中的 Zotero 7+ 本地实例
  • 在线模式 (ZOTERO_LOCAL="false"): 通过 Zotero Web API 访问您的在线库

所有功能与原版 pyzotero-cli 保持一致,但使用 Python 脚本方式调用,更灵活且易于集成到其他 Python 项目中。

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,1421,171

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

969933

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

683829

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

691549

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

797540

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

697374

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.