Skip to main content
Glama
crabsmadethis

crabsmadethis/d2r-horadric-tools

d2r_lookup_unique

Search for Diablo II Resurrected unique items by name or numeric UID. Returns item details and stats. Supports partial name matching for easy lookup.

Instructions

Look up a D2R unique item by name or numeric UID.

Searches unique_items.py data. Returns item info + stats. Supports substring matching (e.g. "harlequin" finds Harlequin Crest).

Args: query: Item name (or substring) or numeric UID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The tool 'd2r_lookup_unique' is registered with @mcp.tool() decorator on async function d2r_lookup_unique, which delegates to lookup_unique(query) from d2r_mcp.lookups.
    @mcp.tool()
    async def d2r_lookup_unique(query: str | int) -> str:
        """Look up a D2R unique item by name or numeric UID.
    
        Searches unique_items.py data. Returns item info + stats.
        Supports substring matching (e.g. "harlequin" finds Harlequin Crest).
    
        Args:
            query: Item name (or substring) or numeric UID
        """
        return lookup_unique(query)
  • Core handler logic: lookup_unique() accepts a name (substring match) or numeric UID, looks up UNIQUE_ITEMS dict, fetches stats from UNIQUE_ITEM_STATS, and returns formatted JSON with uid, name, code, qlvl, base_name, and stats.
    def lookup_unique(query):
        """Look up a unique item by name (substring match) or numeric ID.
    
        Returns JSON with: uid, name, code, qlvl, base_name, stats.
        """
        if not _HAS_DATA:
            return _NO_DATA_MSG
        # Try numeric ID
        try:
            uid = int(query)
            if uid in UNIQUE_ITEMS:
                item = UNIQUE_ITEMS[uid]
                stats = UNIQUE_ITEM_STATS.get(uid, {}).get("stats", [])
                base = ITEM_BASES.get(item["code"], {})
                return _fmt({
                    "uid": uid, "name": item["name"], "code": item["code"],
                    "qlvl": item["qlvl"], "base_name": base.get("name", "?"),
                    "stats": stats,
                })
            return f"No unique item with ID {uid}"
        except ValueError:
            pass
    
        # Try exact name match (case-insensitive)
        q = query.lower()
        if q in _UNIQUE_NAME_TO_ID:
            return lookup_unique(str(_UNIQUE_NAME_TO_ID[q]))
    
        # Substring search
        matches = _substring_matches(query, _UNIQUE_NAME_TO_ID)
        if matches:
            results = []
            for name, uid in matches:
                item = UNIQUE_ITEMS[uid]
                results.append({
                    "uid": uid, "name": item["name"],
                    "code": item["code"], "qlvl": item["qlvl"],
                })
            if len(results) == 1:
                return lookup_unique(str(results[0]["uid"]))
            return _fmt({"matches": results, "count": len(results)})
    
        return f"No unique item found matching '{query}'"
  • Helper _substring_matches used by lookup_unique to find case-insensitive substring matches capped at 10 results.
    def _substring_matches(query, name_to_id, limit=10):
        """Find entries where query is a case-insensitive substring of the name."""
        q = query.lower()
        return [(name, id_) for name, id_ in name_to_id.items() if q in name][:limit]
  • Reverse index _UNIQUE_NAME_TO_ID built at import time mapping lower-cased item names to UIDs for fast lookups.
    _UNIQUE_NAME_TO_ID = {v["name"].lower(): k for k, v in UNIQUE_ITEMS.items()}
  • Helper _fmt used by lookup_unique to format result dicts as pretty-printed JSON.
    def _fmt(obj):
        """Format a result dict as readable JSON."""
        return json.dumps(obj, indent=2, default=str)
Behavior4/5

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

No annotations, but description transparently explains it is a read-only lookup returning item info+stats, with substring matching. No mention of destructive actions, but clear safe usage.

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?

Extremely concise: 3 sentences plus Args section. Front-loaded with purpose. Every sentence adds value without redundancy.

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?

Simple tool with one parameter, well-described. Output schema exists, so return values are covered. No missing context for an effective lookup.

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?

Despite 0% schema coverage, description enriches the parameter 'query' by explaining it can be name or numeric UID, supports substring matching, and gives an example ('harlequin' finds Harlequin Crest).

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?

Description clearly states it looks up D2R unique items by name or UID, specifies data source (unique_items.py), and mentions substring matching. Distinguished from siblings like d2r_lookup_runeword and d2r_lookup_set_item.

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?

Provides clear context on how to use (name or UID, substring matching). Implicitly separates from siblings by focusing on uniques, but no explicit when-not-to-use or alternative tool mentions.

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/crabsmadethis/d2r-horadric-tools'

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