Skip to main content
Glama

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:

  1. Collect item keys: use add_items_by_doi or add_items (or search_library for existing items)

  2. 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.

  3. Call this tool with the .docx file path. It replaces every zcite tag with a Zotero field code and appends a bibliography.

  4. 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

NameRequiredDescriptionDefault
styleNoCitation style for the visible placeholder text. Zotero will reformat on refresh. Default: apaapa
formatNoDocument 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_pathYesAbsolute path to the .docx (Word) or .odt (LibreOffice) file containing <zcite keys="..."/> placeholder tags
library_idNoNumeric 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_typeNoLibrary for this call: 'user' (personal) or 'group'. Default: the library configured on the server.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.1.0
    • changedInput schema / properties / file_path / description
      Previous value: -"Absolute path to the .docx file containing <zcite keys=\"...\"/> placeholder tags"New value: +"Absolute path to the .docx (Word) or .odt (LibreOffice) file containing <zcite keys=\"...\"/> placeholder tags"
    • addedInput schema / properties / format
      Added value: +{
      +  "description": "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.",
      +  "enum": [
      +    "docx",
      +    "odt"
      +  ],
      +  "type": "string"
      +}
  2. Changed2 schema fields changedv2.0.4
    • changedInput schema / properties / library_id / description
      Previous value: -"Override the configured library ID for this call. Defaults to ZOTERO_LIBRARY_ID env (or ZOTERO_USER_ID). Required when library_type is 'group' and the server is configured for a user library."New value: +"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."
    • changedInput schema / properties / library_type / description
      Previous value: -"Override the configured Zotero library type for this call. Defaults to ZOTERO_LIBRARY_TYPE env (or 'user'). Use to target a different library per call without restarting the server."New value: +"Library for this call: 'user' (personal) or 'group'. Default: the library configured on the server."
  3. Changed2 schema fields changedv2.0.2
    • addedInput schema / properties / library_id
      Added value: +{
      +  "description": "Override the configured library ID for this call. Defaults to ZOTERO_LIBRARY_ID env (or ZOTERO_USER_ID). Required when library_type is 'group' and the server is configured for a user library.",
      +  "pattern": "^\\d+$",
      +  "type": "string"
      +}
    • addedInput schema / properties / library_type
      Added value: +{
      +  "description": "Override the configured Zotero library type for this call. Defaults to ZOTERO_LIBRARY_TYPE env (or 'user'). Use to target a different library per call without restarting the server.",
      +  "enum": [
      +    "user",
      +    "group"
      +  ],
      +  "type": "string"
      +}
  4. First observedv1.0.9

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations present, the description carries the full burden and does so richly: it discloses automatic metadata fetching, that a new file with _cited suffix is written, that unknown/ambiguous bracketed keys are hard errors with no file written, that unresolved inline @word is left as plain text with a warning, and that mixed documents are treated as zcite. It also warns that numbered styles require num or citations render as [?], which is behavior an agent could not otherwise predict.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Long, but the length is justified by genuine complexity, and it is well front-loaded: one-sentence purpose, then WORKFLOW, CITATION STYLES, ZCITE TAG FORMAT, OUTPUT, and WHERE THE FILE LIVES. Some passages, notably the bracketed-vs-inline citation discussion, are dense and could be trimmed without losing instruction.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a moderately complex transformation tool with no output schema, the description covers inputs, placeholder grammar, per-attribute semantics, error behavior, output artifact, and environment constraints. An agent has everything needed to call it correctly or to know it should not call it at all.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning beyond the schema: it explains that the style value only affects visible placeholder text because Zotero reformats on refresh, and ties numbered styles to the required num attribute. The library_id/library_type parameters are not elaborated in the description, leaving one small gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a precise verb+resource: replace citation placeholders in a .docx/.odt with native Zotero field codes. It further scopes the exact input forms (zcite tags, Pandoc markers) and the output, so an agent knows exactly what this tool does and how it differs from generic library/mutation siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a numbered end-to-end workflow, names prerequisites (collect keys via add_items_by_doi/add_items/search_library), and explicitly states when NOT to call it (sandbox/cloud workspace where the server cannot see the file) with a named fallback skill. The only gap is that the sibling create_cited_document is never mentioned, so the when-to-prefer-this-vs-that comparison is missing for that one alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.