Skip to main content
Glama
README.md
<p align="center">
  <img src="docs/img/logo.png" alt="D2-MCP" width="128">
</p>

<h1 align="center">D2-MCP</h1>

<p align="center">
  <b>Diablo II modding tools as an open-source <a href="https://modelcontextprotocol.io">MCP</a> server.</b><br>
  Give an assistant things to look up instead of guess, for Legacy Diablo II (1.00 to 1.14d) and Resurrected.<br>
  Free public server: <code>https://mcp.diablo2.org</code>, no key needed.
</p>

<p align="center">
  <a href="#tools"><img alt="45 tools" src="https://img.shields.io/badge/tools-45-8f3131?style=for-the-badge"></a>
  <a href="https://github.com/diablo2org/D2-MCP/commits/main"><img alt="Last commit" src="https://img.shields.io/github/last-commit/diablo2org/D2-MCP?style=for-the-badge&color=e0731f"></a>
  <a href="pyproject.toml"><img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-3776ab?style=for-the-badge"></a>
  <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-2ea44f?style=for-the-badge"></a>
  <br>
  <img alt="Legacy 1.00 to 1.14d, Resurrected" src="https://img.shields.io/badge/Legacy%201.00%E2%80%931.14d%20%C2%B7%20Resurrected-6e7681?style=for-the-badge">
</p>

<p align="center">
  <a href="#use-it-now"><img alt="Get started with D2-MCP" src="https://img.shields.io/badge/%E2%96%B6%20Get%20started-D2--MCP-8f3131?style=for-the-badge&labelColor=5c0202" height="44"></a>
</p>

<p align="center">
  <a href="#use-it-now">Use it now</a> ·
  <a href="#tools">Tools</a> ·
  <a href="#install">Install</a> ·
  <a href="#run">Run</a> ·
  <a href="#data">Data</a> ·
  <a href="#use-the-tools-in-your-own-server">Use in your own server</a> ·
  <a href="#add-a-source">Add a source</a> ·
  <a href="#other-diablo-ii-mcp-servers">Other D2 MCP servers</a> ·
  <a href="#where-it-came-from">Where it came from</a>
</p>

---

It answers questions such as what a column in a data file does, what a row holds in each patch, where a function is defined in the game's reconstructed source, and what a patch's binary really does. Every result says which game version it's about.

The repository holds code only. It ships no game files, data tables or site content: each group of tools fetches or reads its own data, as set out below.

## Use it now

There's a public server with the data already loaded, free and with no key or sign-in:

```
https://mcp.diablo2.org
```

- **Claude (web, desktop, mobile):** Settings → Connectors → Add custom connector, and paste the URL.
- **Claude Code:** `claude mcp add --transport http d2 https://mcp.diablo2.org`
- **Any other MCP client:** add it as a remote server using streamable HTTP.

It offers every tool below except the mod check, archive, sprite and save tools, which work on files on your own disk; [install it](#install) locally for those. Your assistant runs the tools, so there's nothing to pay and nothing to set up. The server is read-only.

## Tools

**Knowledge base** (diablo2.org: the Phrozen Keep's articles and file guides, the site's own pages, the download catalogue)

- `search_knowledge_base`: search articles, by category if you like.
- `read_article`: read one, by section or in parts.
- `lookup_column`: what a column of a data file does, in every version's file guide and the D2R Data Guide.
- `read_d2r_guide`: the D2R Data Guide's page for one data file.
- `search_downloads`, `get_download`: the download catalogue (mods, tools, plugins, patches).

**Data tables** (the game's `.txt` tables, by patch)

- `search_game_data`: find rows containing some text.
- `read_game_data`: one row, column by column, in one patch or compared across all of them.
- `diff_tables`: what changed in a table between two patches, matched by row key.
- `game_data_coverage`: which versions and tables are loaded.

**Source code** (game and server reconstructions, 1.14d research specs and Rust reimplementation, and D2R modding repositories)

- `find_symbol`: where a function, struct, enum value or macro is defined.
- `search_code`: lines containing every word of a query in code, specs and notes.
- `read_code`: lines of a file, with a permalink and the source's game version where given.
- `compare_versions`: a diff between version branches, for a source that has them.
- `read_d2r_json`: a D2R JSON file (UI layout, item art map, strings) by key.
- `d2moo_pull_requests`: D2MOO's open pull requests and their diffs.

**Decompiled binaries** (Ghidra output)

- `decomp_search`: a string, constant or function name in one patch's binaries.
- `decomp_function`: one function's decompiled C, by name or address.

**Calculator**

- `calculate`: a sandboxed calculator for odds, expected values, breakpoints and small simulations.

**Mod check** (a mod's tables on your own disk; see [docs/modcheck.md](docs/modcheck.md))

- `mod_changes`: what a mod's tables change from a vanilla version, table by table or row by row.
- `lint_tables`: what's broken in a set of tables: bad references, malformed cells, column and row problems.

**Archives** (MPQ archives and string tables on your own disk; see [docs/archives.md](docs/archives.md))

- `mpq_list`, `mpq_read`, `mpq_extract`: list an MPQ, read one file in it, or extract files by name or pattern.
- `mpq_create`: build an MPQ from a folder.
- `read_strings`: look up or search the game's strings in `.tbl` files or an MPQ.
- `tbl_to_json`, `json_to_tbl`: convert a string table to editable JSON and back.
- `check_strings`: check a mod's Resurrected string files against the game's: placeholders that would crash, ids that collide in their low 16 bits, missing languages, broken colour codes; gives the next free id.
- `bin_table_info`: what a compiled `.bin` data table holds.
- `read_bin_table`: a compiled `.bin` table's records field by field, with the 1.14d layouts from d2-114d-codex.

**Sprites** (DC6, DCC and COF files on your own disk; see [docs/sprites.md](docs/sprites.md))

- `sprite_info`: what a sprite or COF holds: directions, frames, sizes, offsets, layers, warnings.
- `sprite_to_png`: decode a DC6 or DCC to PNG, one frame or a sheet, optionally through a colour-shift table.
- `png_to_dc6`, `png_to_dcc`: encode PNG frames as a DC6 or DCC against a palette.

**Drops** (exact odds from a table set's treasure classes, 1.10 rules onward, and the chance to hit; see [docs/dropcalc.md](docs/dropcalc.md))

- `drop_chances`: what a monster, super unique, boss or treasure class drops and how often, by difficulty, players, party and magic find.
- `monster_stats`: a monster's life, defence, experience and attacks by difficulty and players.
- `item_affixes`: which magic or rare affixes an item can roll at an item level, and how likely each is.
- `hit_chance`: the chance an attack hits, from attack rating, defence and both levels (or a monster's), and the smallest attack rating that reaches a chance.

**Breakpoints** (from your own `animdata.d2` and tables; see [docs/breakpoints.md](docs/breakpoints.md))

- `frame_breakpoints`: a character's, form's or mercenary's FCR, FHR or FBR table.
- `attack_speed`: frames per attack for a character, weapon and skill, and the IAS breakpoints.

**Internals** (one function across game versions, from your own Ghidra output; see [docs/internals.md](docs/internals.md))

- `function_across_versions`: a function's counterpart in other versions, with a confidence and the evidence. It declines rather than guesses, so many functions get no match.
- `function_fingerprint`: what the index recorded for one function.
- `function_index_status`: which versions are indexed.

**Saves** (a character save on your own disk, read with an imported table set's widths; see [docs/saves.md](docs/saves.md))

- `inspect_save`: what a `.d2s` holds: header and checksum, character, progress, mercenary, stats, class skills, and every item for Legacy version 96 saves (Resurrected version 105: all but the item records). Read-only.

Groups beyond the calculator live in their own modules (`d2mcp/tools_<group>.py`) and read files at paths you give them, so a hosted server can leave them out with `groups=`.

## Install

Needs Python 3.10 or later, and git on the PATH for the source code tools.

```bash
git clone https://github.com/diablo2org/D2-MCP.git
cd D2-MCP
python3 -m venv .venv
.venv/bin/pip install -e .
```

## Run

```bash
.venv/bin/python -m d2mcp      # or: .venv/bin/d2-mcp
```

It speaks MCP over stdio, so normally an MCP client starts it. Any client works. With Claude Code:

```bash
claude mcp add d2 --env D2MCP_DATA_DIR=/path/to/data -- /path/to/D2-MCP/.venv/bin/python -m d2mcp
```

Or in a client's JSON configuration:

```json
{
  "mcpServers": {
    "d2": {
      "command": "/path/to/D2-MCP/.venv/bin/python",
      "args": ["-m", "d2mcp"],
      "env": { "D2MCP_DATA_DIR": "/path/to/data" }
    }
  }
}
```

Settings are environment variables:

| Variable | What it does | Default |
|---|---|---|
| `D2MCP_DATA_DIR` | Where everything fetched or built is kept. | `./data` under the current directory |
| `DECOMP_DIR` | Your folder of Ghidra output, for the decompiled binaries tools. | not set |
| `D2MCP_REFRESH` | `0` turns the background downloads off. | on |
| `DIABLO2_ORG_URL` | The site the knowledge base comes from. | `https://diablo2.org` |
| `D2MCP_USER_AGENT` | The User-Agent sent to diablo2.org and GitHub. | `D2-MCP/<version>` |

The server starts with no data at all. A tool whose data is missing says it isn't set up.

## Host it

`--http` serves the same tools over HTTP (MCP's streamable HTTP transport, at `/mcp`), so people can add the server by URL with nothing to install:

```bash
D2MCP_ALLOWED_HOSTS=mcp.example.org .venv/bin/python -m d2mcp --http --host 0.0.0.0 --port 8000
```

| Setting | What it does | Default |
|---|---|---|
| `--host`, `--port` (or `D2MCP_HOST`, `D2MCP_PORT`) | Where it listens. Put a TLS proxy in front of it. | `127.0.0.1`, `8000` |
| `D2MCP_ALLOWED_HOSTS` | The public host name(s), comma-separated. Requests for any other Host are refused (DNS-rebinding protection). | unset: no check |
| `D2MCP_HTTP_PATH` | The path MCP is served at; `/` serves it at the bare URL. | `/mcp` |
| `D2MCP_GROUPS` | The tool groups to offer, comma-separated. | every group except `modcheck`, `archives` and `sprites` |

The mod check, archive, sprite and save tools read and write files at paths the caller gives, which on a hosted server would be the server's own disk, so they're left out unless you list them. The server is stateless, so it can run several copies behind a load balancer. Clients connect with the URL, for example `claude mcp add --transport http d2 https://mcp.example.org/mcp`.

## Data

Everything lives in the data folder. The first start with background refresh on fetches the knowledge base and clones the code repositories, which takes a few minutes and about 500 MB. After that, a restart loads from disk and fetches nothing: each job records when it last ran in `.refreshed/`, so several servers can share one data folder.

| Group | Where the data comes from | Kept in |
|---|---|---|
| Knowledge base | Fetched from diablo2.org's public endpoints (`/llms-kb.txt`, `/llms-full.txt`, `/api/kb`, `/api/downloads`), every 6 hours. | `library/` |
| D2R Data Guide | Clone it yourself: `git clone https://github.com/ThePhrozenKeep/D2R-RotW-DataGuide data/repos/D2R-RotW-DataGuide`. | `repos/` |
| 1.14d `.bin` field layouts | Clone it yourself: `git clone https://github.com/Nugwa628/d2-114d-codex data/repos/d2-114d-codex` (specs CC BY 4.0, read in place; builds on Legbreak's [Iblis Codex](https://github.com/CaptainLegbreak/Iblis-Codex)). Only `read_bin_table` uses it. | `repos/` |
| Source code | Shallow GitHub clones, updated daily. Legacy and servers: D2MOO, Redivivus, d2hausos, PvPGN, d2-dedicated-server, [Iblis Codex](https://github.com/CaptainLegbreak/Iblis-Codex) (Legbreak's 1.14d reconstruction, MIT), [d2-114d-codex](https://github.com/Nugwa628/d2-114d-codex) (1.14d specs CC BY 4.0, Ghidra tools MIT, builds on Legbreak's Iblis Codex), [d2gamma](https://github.com/Nugwa628/d2gamma) (1.14d Rust reimplementation, MIT). Resurrected: D2RMM and its mods, D2RVanillaFIles, ModdingDiablo2Resurrected, D2RL-Plugins, SpriteEdit, [d2rAI-toolkit](https://github.com/Nugwa628/d2rAI-toolkit) (engine, format and mechanics notes and Python modding tools, MIT). | `<name>_repo/` |
| Data tables, Legacy | Your own game files. Nothing is downloaded. See below. | `gamedata/<version>/` |
| Data tables, Resurrected | Converted from a clone of blizzhackers/d2data. See below. | `gamedata/d2r/`, `gamedata/d2r-base/` |
| Decompiled binaries | Your own Ghidra output. Nothing is downloaded. See below. | wherever `DECOMP_DIR` points |
| Saves | Your own `.d2s` files, read where they are; stat widths and item bases from an imported table set. Nothing is downloaded or kept. | nowhere |

### Data tables

Import each version's tables from your own copy of the game: a folder of the `.txt` files from `data/global/excel`, a `.zip` of them, or an MPQ that holds them (`patch_d2.mpq`, `d2exp.mpq`).

```bash
D2MCP_DATA_DIR=/path/to/data .venv/bin/python -m d2mcp.tables import 1.13c /path/to/patch_d2.mpq
D2MCP_DATA_DIR=/path/to/data .venv/bin/python -m d2mcp.tables import 1.10 /path/to/folder-of-txt
```

The version is the name the tools will use (`1.09d`, `1.13c`, your mod's name). A `patch.txt` beside the tables is kept as that patch's version history.

For Resurrected:

```bash
git clone --depth 1 https://github.com/blizzhackers/d2data /path/to/data/repos/d2data
D2MCP_DATA_DIR=/path/to/data .venv/bin/python -m d2mcp.tables d2r
```

The data tools' descriptions name the versions the tools were written against (1.09d to 1.14d, `d2r`, `d2r-base`) and that set's gaps. If yours differ, pass your own description with `doc_override` (see below).

### Decompiled binaries

Point `DECOMP_DIR` at a folder with one subfolder per game version (`1.09d`, `1.13c`...), each holding one file per binary, named `<binary>.c` (`D2Game.dll.c`, `Game.exe.c`). Each file is the binary's decompiled C from Ghidra, with every function headed by a line of this form:

```
/* ==== 6fce44f0 FUN_6fce44f0 ==== */
```

That is the address, then the function's name. A function that looks reached only through a function-pointer table can carry `(table-only...)` before the closing `====`; that is optional, and the script's detection of it is a heuristic. The folder is made from your own game files with [scripts/ghidra/ExportForD2MCP.java](scripts/ghidra/ExportForD2MCP.java), a Ghidra script (11 or 12) that writes `<outdir>/<version>/<binary>.c` for each program it runs on, every function in address order under that header. Per patch, in a folder of that patch's DLLs and EXE:

```sh
/path/to/ghidra/support/analyzeHeadless /path/to/projects D2MCP-1.13c -import /path/to/1.13c-files \
    -scriptPath /path/to/d2-mcp/scripts/ghidra \
    -postScript ExportForD2MCP.java /path/to/dump 1.13c
export DECOMP_DIR=/path/to/dump
```

Expect minutes of analysis per DLL and a few more for `Game.exe`; [scripts/ghidra/README.md](scripts/ghidra/README.md) has the options, re-export, versions and timings. The script is adapted from `tools/ghidra` in [Nugwa628/d2-114d-codex](https://github.com/Nugwa628/d2-114d-codex) (MIT, Copyright (c) 2026 Nugwa). The d2-114d-codex research builds on Legbreak's Iblis Codex (https://github.com/CaptainLegbreak/Iblis-Codex).

## Use the tools in your own server

`python -m d2mcp` is a thin wrapper. The tools can be added to any FastMCP server, alongside your own:

```python
from contextlib import asynccontextmanager
from mcp.server.fastmcp import FastMCP
import d2mcp   # set D2MCP_DATA_DIR before this import

codebases = {**d2mcp.default_codebases(), "mymod": d2mcp.CodeBase("MyMod", "me/my-mod")}

@asynccontextmanager
async def lifespan(_server):
    tasks = d2mcp.start_jobs(codebases)   # loads the code from disk, refreshes it and the knowledge base
    try:
        yield
    finally:
        for t in tasks:
            t.cancel()

mcp = FastMCP("my-server", lifespan=lifespan)
d2mcp.register(mcp, codebases, doc_suffix={"find_symbol": "    'mymod' is my mod's source."})
```

- `codebases` is what the code tools' `source` parameter offers.
- `groups=("knowledge", "gamedata", "code", "decomp", "calc")` picks groups. Tools are listed in the order they're registered, so call `register` once per group to put your own tools in between.
- `doc_suffix` and `doc_override` add to or replace a tool's description, by tool name.
- `d2mcp.gamedata.add_live_version(...)` adds a mod's tables, read live from a git clone you keep.
- `d2mcp.every(name, hours, job, reload)` schedules your own refresh job on the same shared stamps.
- Load what's on disk before you serve: `d2mcp.library.library.load_cache()` and `d2mcp.gamedata.gamedata.load()`.

## Add a source

A source is a module in `d2mcp/` that owns one kind of data, plus its tools in `d2mcp/tools.py`:

1. Write `d2mcp/<source>.py`. Keep its files under `config.DATA_DIR`, load them from disk on start, and never fetch at import. If it downloads anything, give it a `refresh()` the scheduler can call.
2. Add its tools as a group in `tools.py`: a function that returns them, listed in `GROUPS` and in `build_tools`. The docstring is the tool's description, so write it for the assistant that will read it. When the data is missing, return a short message that says it isn't set up and how to set it up.
3. If it refreshes, add its job to `refresh.start_jobs`.
4. Add the tool names to `tests/test_register.py` and to this README, with where its data comes from.

To add a code repository instead, add a `CodeBase` to `d2mcp/d2moo.py`. Only public repositories, and say in the tool descriptions what it is and which game version it's for.

A new repository, or one its own author proposes, is added with `pin=` set to the full commit id that was reviewed. The server then serves that commit and nothing newer: to update it, open a pull request that moves the pin, so the change is reviewed before it reaches anyone using the public server. Sources from long-standing projects follow their latest commit. `D2MCP_UNPIN=1` makes every source follow its latest commit, for a local server.

## Tests

```bash
.venv/bin/pip install pytest
.venv/bin/pytest
```

The tests use an empty temporary data folder and no network.

## Other Diablo II MCP servers

<!-- Add servers here: name, link, one line on what it covers. -->

- [Capybara's D2 Editor](https://github.com/Nugwa628/Capybara-d2-editor) – `capy mcp --profile <id>` serves MCP over stdio to edit, check, render and save `.ds1` maps and create custom `.dt1` tiles.

## Where it came from

D2-MCP grew out of DarkWanderer, a Discord bot that answers questions in Diablo II modding and private-server communities. People kept asking it things like what a column in a data file does, which patch changed a skill, or what a function in the game really does, and it kept needing to look things up rather than guess. So it got tools: the knowledge base, the data tables by patch, the reconstructed source and the decompiled binaries. Those tools turned out to be useful to anyone working on the game, so they were split out of the bot into this package, and the bot now uses D2-MCP like any other client.

## Licence

MIT. See [LICENSE](LICENSE).

TDQS

A3.8/5.0

Scored across 45 tools

Disambiguation4/5

Tools are organized by resource and domain (knowledge base, game data tables, source code, decompiled binaries, MPQ archives, strings, sprites, calculators, saves), so most purposes are clearly distinct. There is potential overlap among the several search/read tools and the function-index trio, but the descriptions make the boundaries clear enough.

Naming Consistency4/5

Almost all tool names are snake_case and follow predictable verb_noun or noun_noun patterns, with consistent prefixes such as mpq_, decomp_, sprite_, and png_to_. Minor deviations like calculate, function_across_versions, and domain abbreviations are readable and do not break the overall consistency.

Tool Count2/5

45 tools is far above the comfortable 3-15 range and creates significant selection overhead for an agent. The broad Diablo II research/modding scope justifies many tools, but the set is heavy and could be consolidated or namespaced further.

Completeness4/5

The surface covers knowledge search/reading, game data search/read/diff, source and decompiled code, function indexing, MPQ operations, string tables, sprites, gameplay calculators, and save inspection, which is unusually complete for the domain. Minor documented gaps remain, such as D2R save item decoding and lack of direct in-game verification, but agents can work around most of them.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues