add_to_collections
Organize Zotero references by adding items to specific collections for better research management and structured bibliographies.
Instructions
Add a Zotero item to one or more collections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item_key | Yes | ||
| collection_keys | Yes |
Implementation Reference
- src/zotero_mcp/server.py:169-173 (handler)MCP tool registration for add_to_collections, which calls the ZoteroClient implementation.
@mcp.tool(description="Add a Zotero item to one or more collections") def add_to_collections(item_key: str, collection_keys: list[str]) -> str: """Add an item to multiple collections at once.""" cols = _get_client().add_to_collections(item_key, collection_keys) return json.dumps({"item_key": item_key, "collections": cols}, ensure_ascii=False) - src/zotero_mcp/client.py:291-298 (handler)Implementation of the add_to_collections logic which updates the Zotero item's collection list via the pyzotero client.
def add_to_collections(self, item_key: str, collection_keys: list[str]) -> list[str]: """Add item to one or more collections. Returns updated collection list.""" item = self.zot.item(item_key) existing = set(item["data"].get("collections", [])) existing.update(collection_keys) item["data"]["collections"] = list(existing) self.zot.update_item(item) return item["data"]["collections"]