d2r_chargen_list
Retrieve and display character names defined in chars/*.yaml files for Diablo II Resurrected modding, enabling quick review of configured characters.
Instructions
List character names defined in chars/*.yaml.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- d2r_mcp/server.py:176-179 (registration)MCP tool registration via @mcp.tool() decorator for d2r_chargen_list. The async function delegates to the imported _chargen_list (alias for list_chars in d2r_mcp/chargen.py).
@mcp.tool() async def d2r_chargen_list() -> dict: """List character names defined in chars/*.yaml.""" return _chargen_list() - d2r_mcp/chargen.py:19-28 (handler)Core handler function list_chars() that lists character names from chars/*.yaml files. Scans the CHARS_DIR directory for .yaml files, excludes merc_templates.yaml, and returns a list of character names (file stems).
def list_chars() -> dict: """List character names defined in chars/*.yaml (excludes merc_templates).""" cdir = _chars_dir() if not os.path.isdir(cdir): return ok(characters=[], chars_dir=cdir) names = [] for f in sorted(os.listdir(cdir)): if f.endswith(".yaml") and f != "merc_templates.yaml": names.append(f[:-5]) return ok(characters=names, chars_dir=cdir) - d2r_mcp/chargen.py:13-16 (helper)Helper _chars_dir() that resolves the CHARS_DIR path from d2r_chargen.config at call time.
def _chars_dir() -> str: """Resolve CHARS_DIR at call time (respects monkeypatched env).""" from d2r_chargen.config import CHARS_DIR return CHARS_DIR - d2r_mcp/envelope.py:9-11 (helper)Envelope helper ok() used by list_chars to return a success response with status='ok'.
def ok(**payload) -> dict: """Return a success envelope with the given payload merged in.""" return {"status": "ok", **payload} - d2r_mcp/server.py:168-173 (registration)Import statement that binds list_chars from d2r_mcp.chargen as _chargen_list, which is then called by the tool handler.
from d2r_mcp.chargen import ( list_chars as _chargen_list, validate as _chargen_validate, build as _chargen_build, import_save as _chargen_import, )