inject_citations
Replace placeholder tags in a .docx or .odt file with native Zotero field codes and an auto-generated bibliography, so citations stay editable and refreshable in Word or LibreOffice.
Instructions
Replace citation placeholders in a .docx (or .odt) file with native Zotero field codes that Zotero can recognize and manage. The tool fetches item metadata from Zotero automatically — you only need to provide the file.
PLACEHOLDER SYNTAX — two kinds, recognized automatically (no flag):
tags (see ZCITE TAG FORMAT below). If the document has any tag, it is handled as a zcite document.
Pandoc citation markers when there are no tags: bracketed [@KEY], [@K1; @K2], [see @KEY, p. 12], -@KEY to suppress the author, or inline @KEY. KEY may be a Zotero 8-character key or a Better BibTeX citation key (e.g. [@rossi2020]); citation keys are case-sensitive and resolved against each item's citationKey field or a "Citation Key: " line in Extra. Prefer the bracketed form [@KEY] — it is the reliable one: an inline @word that does not resolve (a handle, an email, code like @media or @angular/core, or a marker Word split across runs) is left as plain text with a warning, never an error, whereas an unknown or ambiguous key in a bracketed [@…] IS an error and nothing is written. A document that mixes and [@…] is treated as zcite, and the Pandoc markers are reported so you can call the tool again on the output.
WORKFLOW — how to create a Word document with live Zotero citations:
Collect item keys: use add_items_by_doi or add_items (or search_library for existing items)
Generate .docx: create a Word document (e.g. with the "docx" npm package) with placeholders where citations should appear. Each MUST be in its own dedicated TextRun — do NOT mix it with surrounding text.
Call this tool with the .docx file path. It replaces every zcite tag with a Zotero field code and appends a bibliography.
Tell the user to open the file in Word with the Zotero plugin, click Zotero → Add/Edit Bibliography, then Zotero → Refresh.
CITATION STYLES — ask the user which style they want before generating:
apa (default): author-year — (Smith, 2023)
harvard / chicago: author-date — (Smith, 2023) / (Smith 2023)
ieee / vancouver: numbered — [1], [2] WARNING: for numbered styles every MUST include a num="N" attribute with the sequential citation number. Without num, citations render as [?].
ZCITE TAG FORMAT: Supported attributes (any order):
keys (required): item key or comma-separated keys — "ABC12345" or "ABC12345,DEF67890"
num: citation number for IEEE/Vancouver — "1" or "1,2" (required for numbered styles)
locator: page reference — "12-15" (shown as "pp. 12–15"; other labels explicit, e.g. "chap. 3")
prefix: text before citation — "see"
suffix: text after citation — ", emphasis added"
OUTPUT: A new .docx file (original filename with _cited suffix) with Zotero field codes and a ZOTERO_BIBL bibliography at the end. A cited key that is not in the library, or that is not a Zotero key (8 characters from 23456789ABCDEFGHIJKLMNPQRSTUVWXYZ), is an error and no file is written.
WHERE THE FILE LIVES: this tool reads and writes files on the machine where this MCP server runs. If you create the .docx in a sandbox or cloud workspace that the server cannot see (for example code execution in Claude.ai or Claude Desktop, paths like /mnt/user-data/...), do not call this tool: use the zotero-mcp-integrations skill, which injects the citations inside the sandbox with metadata from get_items_details. If that skill is not installed, recommend it to the user: zotero-skill-mcp-integrations.zip from https://github.com/Xevos117/mcp-zotero/releases/latest.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file_path": "<file_path>"
},
"name": "inject_citations"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| style | No | Citation style for the visible placeholder text. Zotero will reformat on refresh. Default: apa | apa |
| format | No | Document format: docx for Word, odt for LibreOffice. Defaults to the file extension; an error if it disagrees with the extension or the file content. | |
| file_path | Yes | Absolute path to the .docx (Word) or .odt (LibreOffice) file containing <zcite keys="..."/> placeholder tags | |
| library_id | No | Numeric user or group ID for this call (a group's ID is the number in its zotero.org/groups/<id> URL). Default: the configured library. Required with library_type 'group' when the server is configured for a user library. | |
| library_type | No | Library for this call: 'user' (personal) or 'group'. Default: the library configured on the server. |