Skip to main content
Glama
crabsmadethis

crabsmadethis/d2r-horadric-tools

d2r_save_inspect

Read and summarize a Diablo II Resurrected .d2s save file, extracting character class, level, stats, progression, and mercenary information. For validation, use the dedicated scan tool.

Instructions

Summarize a .d2s save: class, level, stats, progression, merc.

No scanner pass — use d2r_save_scan for validation.

Args: path: Absolute path to .d2s file, or bare character name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The MCP tool registration for 'd2r_save_inspect' as a FastMCP tool using the @mcp.tool() decorator. It delegates to _save_inspect (imported as inspect from d2r_mcp.save).
    @mcp.tool()
    async def d2r_save_inspect(path: str) -> dict:
        """Summarize a .d2s save: class, level, stats, progression, merc.
    
        No scanner pass — use d2r_save_scan for validation.
    
        Args:
            path: Absolute path to .d2s file, or bare character name.
        """
        return _save_inspect(path)
  • Import of the 'inspect' function from d2r_mcp.save, aliased as _save_inspect for use in the tool handler.
    from d2r_mcp.save import (
        scan as _save_scan,
        inspect as _save_inspect,
        list_items as _save_list_items,
        diff as _save_diff,
    )
  • The actual implementation of the inspect logic. Decodes class, level, progression, stats, name, and merc info from the .d2s binary header. Uses _resolve_save_path for path handling and returns an envelope via ok().
    def inspect(path: str) -> dict:
        """Return a human-readable character summary.
    
        Decodes class, level, progression, stats, waypoints, and merc info from
        the .d2s header and stats section. Does not run the full scanner; use
        scan() for validation.
        """
        resolved = _resolve_save_path(path)
        if not os.path.exists(resolved):
            return error("not_found", f"save file not found: {path}")
    
        from d2r_chargen.importer import _read_name, _decode_character_stats
        with open(resolved, "rb") as f:
            data = bytearray(f.read())
    
        cls_id = data[0x18]
        class_name = _CLASS_NAMES[cls_id] if 0 <= cls_id < len(_CLASS_NAMES) \
            else f"class_{cls_id}"
        level = data[0x1B]
        prog = data[0x15]
        progression = {0x00: "normal", 0x05: "nightmare", 0x0F: "hell"}.get(
            prog, f"0x{prog:02X}"
        )
        stats = _decode_character_stats(data)
    
        # Merc summary (kept minimal — full merc decode is the scanner's job)
        merc = {"present": False}
        merc_type = int.from_bytes(data[0xA8:0xAA], "little")
        if merc_type not in (0, 0xFFFF):
            merc["present"] = True
            merc["type_id"] = merc_type
            merc["xp"] = int.from_bytes(data[0xAA:0xAE], "little")
    
        return ok(
            character=_read_name(data),
            **{"class": class_name},
            class_id=cls_id,
            level=level,
            progression=progression,
            stats=stats,
            merc=merc,
        )
  • Helper function _resolve_save_path that resolves user-supplied paths (absolute, ~-expanded, or bare character names) to an absolute .d2s file path.
    def _resolve_save_path(path: str) -> str:
        """Resolve a user-supplied path to an absolute .d2s path.
    
        Accepts absolute paths, ~-prefixed paths, or bare character names
        (resolved against the Steam saves directory).
        """
        expanded = os.path.expanduser(path)
        if os.path.isabs(expanded) and os.path.exists(expanded):
            return expanded
        if not expanded.endswith(".d2s"):
            candidate = os.path.join(SAVES, f"{expanded}.d2s")
            if os.path.exists(candidate):
                return candidate
        candidate = os.path.join(SAVES, expanded)
        if os.path.exists(candidate):
            return candidate
        return expanded  # caller handles non-existence
  • CLASS_NAMES lookup list used by inspect to translate the binary class ID byte to a human-readable class name (Amazon, Sorceress, etc.).
    _CLASS_NAMES = ["Amazon", "Sorceress", "Necromancer", "Paladin",
                    "Barbarian", "Druid", "Assassin", "Warlock"]
Behavior4/5

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

Discloses that it does not perform validation ('No scanner pass'), which is a key behavioral trait. No annotations exist, so description carries full burden and adds relevant context about limitations.

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?

Two sentences and a brief argument list; every word is informative. Front-loaded with the core purpose, no 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?

For a simple tool with one parameter, no output schema, and no annotations, the description fully covers what it does, usage guidance, and parameter semantics. An agent can confidently select and invoke it.

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?

The description adds meaning to the single 'path' parameter beyond the schema: explains it expects an absolute path or a bare character name. This compensates for 0% schema description coverage.

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?

Clearly describes 'Summarize a .d2s save' with specific fields (class, level, stats, progression, merc). Distinguishes from sibling tools like d2r_save_scan and d2r_save_list_items.

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

Usage Guidelines5/5

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

Explicitly states when not to use ('No scanner pass') and provides alternative ('use d2r_save_scan for validation'). Also explains the argument format (absolute path or character name).

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