Skip to main content
Glama

merge_duplicates

Merge duplicate Zotero items by transferring metadata, tags, and collections to a keeper item while removing duplicates to clean your library.

Instructions

Merge duplicate Zotero items: transfer metadata, tags, collections to keeper, trash rest

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keep_keyYes
remove_keysYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Registration and handler definition for the 'merge_duplicates' MCP tool.
    @mcp.tool(description="Merge duplicate Zotero items: transfer metadata, tags, collections to keeper, trash rest")
    def merge_duplicates(keep_key: str, remove_keys: list[str]) -> str:
        """Merge duplicates into one item. Fills empty fields from duplicates."""
        result = _get_client().merge_duplicates(keep_key, remove_keys)
        return json.dumps(result, ensure_ascii=False)
  • Core logic implementation for merging duplicate Zotero items.
    def merge_duplicates(self, keep_key: str, remove_keys: list[str]) -> dict:
        """Merge duplicates into keeper: transfer fields, tags, collections, trash rest."""
        keeper = self.zot.item(keep_key)
        removed_titles = []
    
        for rk in remove_keys:
            dup = self.zot.item(rk)
            dup_data = dup["data"]
            removed_titles.append(dup_data.get("title", rk))
    
            # Fill empty fields from duplicate
            for field, value in dup_data.items():
                if field in ("key", "version", "dateAdded", "dateModified"):
                    continue
                keeper_val = keeper["data"].get(field)
                if not keeper_val and value:
                    keeper["data"][field] = value
    
            # Merge tags
            existing_tags = {t["tag"] for t in keeper["data"].get("tags", [])}
            for t in dup_data.get("tags", []):
                if t["tag"] not in existing_tags:
                    keeper["data"].setdefault("tags", []).append(t)
                    existing_tags.add(t["tag"])
    
            # Merge collections
            existing_cols = set(keeper["data"].get("collections", []))
            for col in dup_data.get("collections", []):
                if col not in existing_cols:
                    keeper["data"].setdefault("collections", []).append(col)
                    existing_cols.add(col)
    
            # Trash the duplicate
            self.zot.trash_items([dup])
    
        self.zot.update_item(keeper)
        return {
            "kept": keep_key,
            "removed": remove_keys,
            "removed_titles": removed_titles,
            "keeper_title": keeper["data"].get("title", ""),
        }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the merge action and outcome ('transfer metadata, tags, collections to keeper, trash rest'), which implies a destructive operation on the removed items. However, it lacks details on permissions required, whether the operation is reversible, error handling (e.g., if keys are invalid), or side effects like updating references. For a tool that modifies data, this is insufficient.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core action ('Merge duplicate Zotero items') and succinctly explains the process. Every word earns its place, with no redundancy or fluff, making it easy to parse quickly.

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

Completeness3/5

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

Given the tool's complexity (destructive merge operation), lack of annotations, and 0% schema coverage, the description is incomplete. It covers the basic purpose but misses critical details like parameter semantics, behavioral risks, and usage context. However, the presence of an output schema mitigates the need to describe return values, keeping it from being entirely inadequate.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It mentions 'keeper' and implies 'remove_keys' correspond to items to be trashed, but doesn't explain what 'keep_key' and 'remove_keys' represent (e.g., Zotero item keys), their format, or constraints (e.g., must be valid keys, cannot overlap). The description adds minimal meaning beyond the schema's property names.

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

Purpose4/5

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

The description clearly states the action ('merge duplicate Zotero items') and specifies what happens during the merge ('transfer metadata, tags, collections to keeper, trash rest'). It distinguishes from siblings like 'find_duplicates' (which identifies but doesn't merge) and 'delete_item' (which deletes without merging). However, it doesn't explicitly contrast with all relevant siblings like 'update_item'.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing to identify duplicates first with 'find_duplicates'), nor does it specify scenarios where merging is appropriate versus deleting or updating items separately. The description assumes the user already knows when merging is needed.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BirdInTheTree/zotero-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server