跳到主要内容

Zotero 文献库

收藏0

用 pyzotero 程序化管理 Zotero 文献库:检索条目、新建与更新条目、整理分类与标签、导出引用格式、上传 PDF 附件,支持 Web API 与本地 API。

让 AI 安装

星光尘缘LV2最新版本 0.1.0更新于 2026-11-24下载 0 次

references/mcp.md

6.1 KB查看排版效果
1# MCP Server
2
3Pyzotero 1.15.2 ships an optional [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that exposes your **local Zotero library** and Semantic Scholar integration as tools for LLM clients (e.g., Claude Desktop).
4
5## Requirements
6
7- **Zotero 7+** for local reads, **Zotero 10+** for local writes, with local API access enabled:
8 - Zotero → Settings → Advanced → **Allow other applications on this computer to communicate with Zotero**
9- Python 3.10+ (required by `pyzotero[mcp]`)
10
11Zotero-library tools read the local desktop API without a key. Semantic Scholar tools call an external network API. The server starts read-only; local write tools require explicit enablement and a separate local authorization key.
12
13## Installation
14
15```bash
16# In a project
17uv add "pyzotero[mcp]==1.15.2"
18
19# As a standalone tool
20uv tool install "pyzotero[mcp]==1.15.2"
21```
22
23Run without installing:
24
25```bash
26uvx --from "pyzotero[mcp]==1.15.2" pyzotero-mcp
27```
28
29## Claude Desktop Configuration
30
31Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
32
33**If `pyzotero-mcp` is installed:**
34
35```json
36{
37 "mcpServers": {
38 "zotero": {
39 "command": "pyzotero-mcp"
40 }
41 }
42}
43```
44
45**Without installing (via uvx):**
46
47```json
48{
49 "mcpServers": {
50 "zotero": {
51 "command": "uvx",
52 "args": ["--from", "pyzotero[mcp]==1.15.2", "pyzotero-mcp"]
53 }
54 }
55}
56```
57
58## Available Tools
59
60### Zotero Library Tools
61
62| Tool | Description |
63|------|-------------|
64| `search` | Search the local library by query, item type, collection, tag, or full-text content |
65| `get_item` | Get a single item by key |
66| `get_children` | Get child items (attachments, notes) of an item |
67| `list_collections` | List all collections |
68| `list_tags` | List all tags, optionally filtered by collection |
69| `get_fulltext` | Get full-text content of a PDF or other attachment |
70
71### Semantic Scholar Tools
72
73| Tool | Description |
74|------|-------------|
75| `find_related` | Request recommended papers for a seed paper |
76| `get_citations` | Find papers that cite a given paper |
77| `get_references` | Find papers referenced by a given paper |
78| `search_semantic_scholar` | Search Semantic Scholar's paper index |
79
80Semantic Scholar tools can optionally check whether results already exist in your local Zotero library (`check_library` parameter, enabled by default).
81
82## MCP vs Web API vs CLI
83
84| Mode | Access | API key | Best for |
85|------|--------|---------|----------|
86| Web API (`Zotero(...)`) | Remote library | Private reads/writes | Automation, bulk CRUD, group libraries |
87| CLI (`pyzotero[cli]`) | Local Zotero | Local key for writes | Shell scripts, quick local search |
88| MCP (`pyzotero[mcp]`) | Local Zotero + external Semantic Scholar | Local key for enabled writes | LLM agents in sandboxed apps |
89
90For remote library management from Python, use the Web API client documented in the other reference files. Local library searches can work without external network access. Semantic Scholar lookups always need the network.
91
92## Tool Arguments and Results
93
94`search(query='', fulltext=False, itemtype='', collection='', tag='', limit=50, offset=0)` returns JSON text with `count` and `items`. For MCP, `tag='reviewed,unread'` means AND; `itemtype='journalArticle || book'` means OR. This differs from the CLI's repeated flags. Parse the tool's JSON text before using fields; failed calls can return an `error` object instead.
95
96Semantic Scholar tools return `papers` with counts and optional local-library annotations, not raw Zotero items. The installed implementation uses:
97
98| Tool | External API request | Response handling / limit |
99|------|----------------------|---------------------------|
100| `find_related` | GET `/graph/v1/paper/{id}`, then POST `/recommendations/v1/papers` with `positivePaperIds` | Normalizes `recommendedPapers`; up to 500 |
101| `get_citations` | GET `/graph/v1/paper/{id}/citations` | Extracts `data[].citingPaper`; one page, up to 1000 |
102| `get_references` | GET `/graph/v1/paper/{id}/references` | Extracts `data[].citedPaper`; one page, up to 1000 |
103| `search_semantic_scholar` | GET `/graph/v1/paper/search` | Extracts `data`; up to 100, relevance search |
104
105Host: `https://api.semanticscholar.org`. Pyzotero 1.15.2's integration does not send a Semantic Scholar API key or expose an API-key option, so do not imply a Zotero key authenticates these requests. Handle public-service rate limits. `check_library=False` avoids a local DOI-index scan. DOI absence and normalization can make local-library matching incomplete.
106
107The MCP tools do not expose an offset for citations/references/search and are not exhaustive literature search tools. Citation/reference `total` in the helper reflects the returned page, not a global count. `min_citations` filters fetched results locally. Leave the MCP `sort` argument empty: the wrapper sends it to relevance `/paper/search`, whose current official schema does not support sorting. Do not promise globally citation-ranked results.
108
109## Enabling Writes
110
111For an explicitly intended local write workflow, install both extras and obtain a persistent key:
112
113```bash
114uv tool install "pyzotero[cli,mcp]==1.15.2"
115pyzotero authorize --app-name "Research assistant"
116# Choose Always Allow in Zotero if persistent access is intended.
117pyzotero-mcp --enable-writes
118```
119
120The server reads the stored key/server-ID pair created by the CLI. Alternatively, `PYZOTERO_LOCAL_API_KEY` and `PYZOTERO_LOCAL_SERVER_ID` override the file. Keep those values private. With `--enable-writes`, additional tools are registered: `list_item_fields`, `create_item`, `update_item`, `add_tags`, `create_collection`, `add_to_collection`, `remove_from_collection`, `move_to_collection`, and `add_attachment`. Attachment paths must be absolute; files are copied into Zotero storage.
121
122`delete_item` is registered only with `--enable-deletes`, which also enables writes. It permanently erases items and can propagate via sync; it does not move them to trash.
123
124Sources: [Pyzotero MCP documentation](https://pyzotero.readthedocs.io/en/latest/#mcp-server), [Graph schema](https://api.semanticscholar.org/graph/v1/swagger.json), [recommendations schema](https://api.semanticscholar.org/recommendations/v1/swagger.json).

文件内容是平台检查时读出的文本,只供查看。平台不会运行包里的任何脚本或程序。