Skip to content

justinritchie/dnd-rules-mcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

D&D Rules MCP Server

An MCP server that looks up D&D 5e rules — spells, monsters, conditions, classes, magic items, rules sections — through the Open5e API. Defaults to the 2024 SRD (5.5e) and falls back to the original 2014 SRD on demand.

Designed to pair with roll20-character-mcp-server. The Roll20 server reads your character; this one looks up the rules. Together they answer questions like "I have Spirit Guardians prepared — what does it actually do at my level, and do I have a slot to cast it?"

What It Does

Tool Returns
dnd_search_spells Spells by name / level / school / class / ritual / concentration.
dnd_get_spell Full description, components, casting time, range, duration, source.
dnd_search_creatures Creatures by name / CR range / type / size.
dnd_get_creature Full stat block (AC, HP, speed, abilities, CR).
dnd_list_conditions All standard + third-party conditions.
dnd_get_condition Full description (Charmed, Frightened, Stunned, …).
dnd_search_rules Rules section search (Combat, Resting, Ability Checks, …).
dnd_get_rule Full rule text.
dnd_list_classes Classes (and 2024 subclasses, which are first-class entries).
dnd_get_class Class details.
dnd_get_race Race / species details.
dnd_get_background Background details.
dnd_search_magic_items Magic items by name / rarity / attunement.
dnd_get_magic_item Full magic item description.

All tools accept an edition arg: "2024" (default — the 5.5e ruleset most current campaigns use) or "2014" (the original 5e SRD). Switching edition rewires the API call to Open5e v2 (2024) or v1 (2014) under the hood and normalizes the response shape so the LLM doesn't see the difference.

Why Open5e (and not dnd5eapi.co)

dnd5eapi.co has a beautifully clean 2014 SRD but its 2024 endpoints are a stub — only conditions are populated, monsters has 3 entries, spells returns malformed JSON. Open5e has the actual 2024 SRD content (339 spells, 330 creatures, 24 classes + subclasses, 56 rules sections) under its srd-2024 source, and full 2014 coverage under v1 wotc-srd. One API, both editions, no second integration to maintain.

Setup

No auth. No env vars required.

npm install
npm run build
node build/index.js

For Claude Desktop, add to claude_desktop_config.json:

{
  "mcpServers": {
    "dnd-rules": {
      "command": "node",
      "args": ["/Users/<you>/justin-mcp-servers/dnd-rules-mcp-server/build/index.js"]
    }
  }
}

Smoke Test

npm run smoke

Exercises every category against live api.open5e.com and prints sample output. Includes a 2014/2024 Counterspell comparison so you can see the edition switch working (2014 = old auto-counter on level ≤ 3, 2024 = new Constitution save-based mechanics).

Edition Examples

dnd_get_spell({ query: "Counterspell" })
  → 2024: "The creature makes a Constitution saving throw…"

dnd_get_spell({ query: "Counterspell", edition: "2014" })
  → 2014: "If the creature is casting a spell of 3rd level or lower, its spell fails…"

dnd_search_creatures({ crMin: 1, crMax: 3, type: "undead" })
  → Ghast, Ghoul, Mummy, Wight, Specter, Will-o'-Wisp, …  (2024 SRD)

Architecture Notes

Edition routing. Open5e exposes both versions. v2 holds the new 2024 SRD with cleaner DRF filtering and richer object-shaped fields (school: {name, key}, rarity: {name, key, rank}). v1 holds the original 2014 SRD with flat string fields (school: "Abjuration", rarity: "Legendary"). The client normalizes v1 responses into v2-shaped TypeScript interfaces before they reach the formatters or the LLM, so you don't see the version skew.

Filter quirks. A few v2 endpoint quirks worth knowing about — they're encoded in the client:

  • Spells filter type and size via type__key / size__key, but creatures use the flat type=undead / size=large (no __key suffix). Discovered via probing.
  • Magic items' rarity filter is broken at the URL level — every variant returns the full set. The client fetches a wider window and filters rarity client-side.
  • Conditions live mostly in the core source, not srd-2024 — so the conditions tools ignore the edition arg and just query without a source filter.

Default source.

  • edition: "2024" → Open5e v2 with document__key=srd-2024 (official WotC 2024 / 5.5e).
  • edition: "2014" → Open5e v1 with document__slug=wotc-srd (original 5e Core Rules).

Override via documentKey per call to query other sources: a5e-ag (Advanced 5th Edition), tob / tob2 / tob3 (Kobold Press Tome of Beasts), cc (Creature Codex), dmag (Deep Magic), or "" (empty string) to query everything.

Roadmap

Done

  • 14 tools across spells, creatures, conditions, rules, classes, races, backgrounds, magic items.
  • Edition-aware routing (2024 / 2014) with response normalization.
  • Open5e v2 schema quirks handled (creature filter naming, magic item rarity client-side filter).
  • Exact-name match preference over substring (so Fireball doesn't return Delayed Blast Fireball first).

Planned

  • Companion tool: dnd_compare_editions — fetch the same item in both editions and diff the descriptions ("what changed for Counterspell between 2014 and 2024?").
  • Class-spell-list expansion: given a class + level, return the full prepared/known spell list filtered to what's available.
  • Universal text search across all categories at once (dnd_search) for "I heard about a spell that…" queries.
  • Light response caching (Open5e is fast and rate-limit-friendly, but identical lookups within a session don't need to re-hit the wire).

Out of scope

  • D&D Beyond integration. Their API isn't open and reverse-engineering their auth isn't worth the maintenance cost when Open5e covers the SRD properly.

License

Private / personal use. Open5e content is licensed Creative Commons Attribution 4.0 (the 2024 SRD ships as CC-BY 4.0); third-party sources retain their original licenses.

About

MCP server for D&D 5e rules lookup (spells, monsters, conditions, classes, magic items). Powered by Open5e. Defaults to 2024 SRD (5.5e); supports 2014 fallback. Companion to roll20-character-mcp-server.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors