ChatRPG
ChatRPG is a comprehensive D&D 5e MCP server providing AI Dungeon Masters with 30+ tools for tabletop gaming, featuring character persistence, real-time combat tracking, ASCII art rendering, and a web client interface.
Character Management: Create, update, delete, and level up characters with full D&D 5e stats, classes, races, equipment, and spell slots. Supports rest mechanics (short/long with hit dice spending), skill checks, saving throws, attack rolls, and spell slot management for all caster types including warlock pact magic.
Combat System: Initialize tactical encounters with initiative tracking, terrain, and lighting. Execute actions (attack, dash, dodge, cast spells, grapple, shove) with automatic hit/damage resolution. Manage turn advancement with automatic condition duration tracking, death saves, dynamic terrain modification, cover detection, and ASCII battlefield rendering.
Magic System: Track spell concentration with automatic DC calculation, manage aura effects (Spirit Guardians, Paladin auras), use spell scrolls with success/failure resolution, and enable improvised magic through arcane synthesis with Arcana checks.
Spatial Mechanics: Calculate grid-based distances with elevation, determine areas of effect (sphere, cone, line, cube, cylinder) with automatic target detection, check line of sight with obstacle detection and special vision modes, calculate movement paths considering terrain, and place interactive props (barrels, doors, chests) with cover, HP, AC, locks, and traps.
World & Session Management: Create location graphs with interconnected areas, move the party between locations with locked/hidden passage mechanics, manage party composition with role assignments, handle inventory operations (give/take/equip/transfer), maintain searchable session notes with tags and importance levels, and retrieve comprehensive session context snapshots.
Dice Rolling: Supports standard notation (2d6+4, 4d6kh3) with advantage/disadvantage and batch rolling for simultaneous expressions.
Technical Features: Persistent storage in AppData/config directories, WebSocket broadcasting for real-time encounter updates, dual transport support (stdio for Claude Desktop, SSE for web clients), fuzzy enum matching for forgiving input parsing, and D&D 5e SRD-compliant mechanics.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ChatRPG roll a perception check for my rogue Finn"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ChatRPG
D&D 5e MCP Server for AI Dungeon Masters
A Model Context Protocol (MCP) server providing 30+ D&D 5e tools for LLM-powered tabletop gaming. Features real-time combat tracking, character persistence, ASCII art rendering, and a web client interface.
Features
30+ D&D 5e Tools - Character creation, combat encounters, spell tracking, dice rolling
ASCII Art Output - Retro-style box drawing for immersive terminal/chat display
Dual Transport - stdio for Claude Desktop, SSE for web client
Real-time Sync - WebSocket broadcasting for encounter updates
Persistent Storage - Characters and encounters saved to AppData
Web Client - Browser-based interface with typing indicators
Related MCP server: rpg-mcp
Quick Start
1. Build & Run
npm install
npm run build
# Run with stdio (for Claude Desktop)
npm start
# Run with SSE (for web client, port 3001)
node dist/index.js --sse2. Configure Claude Desktop
Add to your Claude Desktop config:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"chatrpg": {
"command": "node",
"args": ["C:\\path\\to\\ChatRPG\\dist\\index.js"]
}
}
}3. Web Client
The web client connects to the SSE endpoint:
# Start server with SSE
node dist/index.js --sse
# Open web-client/index.html in browserAvailable Tools
Character Management
Tool | Description |
| Full D&D 5e character creation with auto-calculated stats |
| Retrieve by ID/name, supports listing and filtering |
| Modify stats with before/after comparison |
| Remove with cascade cleanup, batch support |
| Level progression with HP rolls, spell slots |
| Short/long rest with hit dice and recovery |
| Full/half/third casters, warlock pact magic |
| Skill checks, saves, attacks, initiative |
Combat System
Tool | Description |
| Initialize combat with participants and terrain |
| Retrieve state with verbosity levels |
| Attack, dash, dodge, disengage, grapple, shove, cast |
| Turn management with condition ticking |
| Close with outcome tracking |
| D&D 5e death save mechanics |
| Apply/remove conditions with duration |
| Composite operations with state sync |
| ASCII tactical map |
| Hazards, obstacles, difficult terrain |
Magic System
Tool | Description |
| Concentration checks and tracking |
| Spirit Guardians, Paladin auras, etc. |
| Spell scroll mechanics |
| Improvised magic with Arcana checks |
Spatial Mechanics
Tool | Description |
| Grid-based distance (5e rules) |
| Sphere, cone, line, cube, cylinder |
| Obstacle detection |
| Half, three-quarters, full cover |
| Interactive battlefield objects |
| Pathfinding with terrain |
World & Session
Tool | Description |
| Location graph for navigation |
| Travel between locations |
| Party composition and roles |
| Item management and equipping |
| Session notes with tagging |
| Comprehensive state snapshot |
Dice
Tool | Description |
| Standard notation, advantage/disadvantage, batch rolls |
Project Structure
ChatRPG/
├── src/
│ ├── index.ts # MCP server (stdio + SSE transports)
│ ├── registry.ts # Tool registration (30+ tools)
│ ├── types.ts # Shared Zod schemas
│ ├── fuzzy-enum.ts # Fuzzy enum matching
│ ├── websocket.ts # Real-time broadcasting
│ └── modules/
│ ├── ascii-art.ts # Box drawing, formatting
│ ├── characters.ts # Character CRUD, leveling
│ ├── combat.ts # Encounters, conditions, actions
│ ├── data.ts # Locations, party, inventory, notes
│ ├── dice.ts # Dice parsing and rolling
│ ├── magic.ts # Spells, concentration, auras
│ └── spatial.ts # Distance, AoE, movement
├── web-client/ # Browser-based interface
├── tests/ # Vitest test suites
├── dist/ # Compiled output
└── design docs/ # ADRs and documentationDevelopment
Commands
# Development with auto-rebuild
npm run dev
# Type check
npx tsc --noEmit
# Build
npm run build
# Run tests
npm test
# Run tests once
npm test -- --runAdding a New Tool
Define Zod schema in
src/modules/[module].tsWrite handler function
Export schema from module
Register in
src/registry.tsAdd tests in
tests/[module]/
Git Workflow
main - Production-ready, auto-deploys to Railway
development - Active development branch
Data Storage
Character and session data is stored in:
Windows:
%APPDATA%\rpg-lite-mcp\macOS/Linux:
~/.config/rpg-lite-mcp/
rpg-lite-mcp/
├── characters/ # Character JSON files
├── encounters/ # Active encounter state
├── locations/ # Location graph
├── party/ # Party composition
└── notes/ # Session notesExample Usage
Ask Claude:
"Create a level 5 halfling rogue named Finn with high dexterity"
Response:
╔═══════════════════════ CHARACTER SHEET ════════════════════════╗
║ Finn ║
║ PC - Halfling Rogue (Level 5) ║
║ ║
║ HP: [████████████████] 35/35 ║
║ ║
║ ────────────────────────────────────────────────────────────── ║
║ ║
║ AC │ Speed │ Initiative │ Prof Bonus ║
║ 15 │ 25 ft │ +4 │ +3 ║
╚════════════════════════════════════════════════════════════════╝Other commands:
"Roll 4d6 drop lowest for ability scores"
"Start a combat encounter with 3 goblins"
"Cast fireball centered at position 5,5"
"Move the party to the tavern"
Deployment
The server is deployed on Railway and auto-deploys from the main branch.
SSE Endpoint: https://chatrpg-production.up.railway.app/
Troubleshooting
Server Won't Start
Verify build:
npm run buildCheck path in config is absolute
Test manually:
node dist/index.js
Tool Calls Failing
Rebuild:
npm run buildRun tests:
npm test -- --runCheck TypeScript:
npx tsc --noEmit
Encoding Issues
If ASCII art displays as garbled text (e.g., ââ€â‚¬ instead of ─), ensure:
Source files are UTF-8 encoded
Terminal/client supports Unicode
No double-encoding in transport layer
Architecture
MCP Protocol
Transports: stdio, SSE (Server-Sent Events)
Format: JSON-RPC 2.0
Capabilities: Tools (30+)
Design Principles
ASCII Art First - All output uses box drawing for terminal aesthetics
Zod Validation - Strict input schemas with fuzzy enum matching
Stateful Persistence - JSON files in AppData
D&D 5e Accurate - SRD-compliant mechanics
Real-time Updates - WebSocket broadcasting for encounters
Contributing
This project follows TDD:
Write failing tests
Implement minimal code to pass
Refactor
PRs must:
Include tests
Pass TypeScript strict mode
Follow existing patterns
License
Proprietary - Personal, non-commercial use permitted. See LICENSE.
Credits
@modelcontextprotocol/sdk - MCP TypeScript SDK
Zod - Schema validation
Vitest - Testing framework
D&D 5e SRD (System Reference Document)
Available Tools
35 toolsadvance_turnA
Advance to the next combatant's turn in an encounter. Handles round transitions when all combatants have acted, ticks condition durations (removing expired conditions), clears action economy for the previous combatant, and provides death save reminders for combatants at 0 HP. Returns ASCII-formatted turn info with initiative order preview.
Inputs: encounterId (required), processEffects, processAuras.
calculate_aoeC
Calculate area of effect for D&D 5e spells/abilities (sphere, cone, line, cube, cylinder)
Inputs: shape (required), origin (required), encounterId, length, +7 more.
calculate_movementC
Calculate movement paths, reachable squares, or adjacent squares with terrain support
Inputs: from (required), mode, encounterId, to, +4 more.
check_coverC
Check cover between attacker and target, returning AC and Dex save bonuses
Inputs: attacker (required), target (required), obstacles, creatures, +1 more.
check_line_of_sightC
Check line of sight between positions with obstacle/cover detection
Inputs: encounterId, from, to, fromId, +9 more.
create_characterC
Create a new D&D 5e character with stats, class, race, and equipment
Inputs: name (required), race, class, level, +20 more.
create_encounterC
Create a D&D 5e combat encounter with participants, terrain, and initiative tracking
Inputs: participants (required), seed, terrain, lighting, +1 more.
delete_characterB
Permanently delete a D&D 5e character by ID or name. Supports batch deletion.
Inputs: characterId, characterName, batch.
end_encounterA
End a combat encounter with outcome tracking and optional summary generation. Supports victory, defeat, fled, negotiated outcomes. Can preserve encounter log for review.
Inputs: encounterId (required), outcome (required), generateSummary, preserveLog, +1 more.
execute_actionC
Execute a combat action in an encounter (attack, dash, disengage, dodge, etc.). Phase 1 supports attack and dash actions.
Inputs: encounterId (required), actionType (required), actorId, actorName, +24 more.
get_characterC
Retrieve an existing D&D 5e character by ID
Inputs: characterId, characterName, batch.
get_encounterA
Get the current state of a combat encounter. Supports verbosity levels: minimal (LLM context), summary (quick overview), standard (default DM view), detailed (full state dump).
Inputs: encounterId (required), verbosity.
get_session_contextB
Get comprehensive session context snapshot. Includes location, party, notes, combat state, and summary. Options: include (array of sections), format (detailed|compact|brief), maxNotes (limit), includeTimestamps (boolean).
Inputs: include, format, maxNotes, includeTimestamps.
level_upA
Level up a character. Increases level, HP (roll/average/max/manual), proficiency bonus, and spell slots. Supports custom class hit dice and resource scaling. Multi-level jumps allowed (e.g., 1→5). Batch support for party level-ups. Optionally track new features and spells learned.
Inputs: characterId, characterName, targetLevel, hpMethod, +5 more.
manage_auraC
Manage D&D 5e aura effects (Spirit Guardians, Aura of Protection, etc.). Operations: create (new aura), list (active auras), process (apply effects to targets in range), remove (end aura). Supports damage, healing, conditions, and saving throws.
Inputs: operation, ownerId, spellName, radius, +18 more.
manage_concentrationA
Manage D&D 5e concentration on spells. Operations: set (begin concentrating), get (query state), check (roll save after damage), break (end concentration). DC = max(10, damage/2). Supports advantage/disadvantage on saves.
Inputs: characterId, operation, spellName, targets, +7 more.
manage_conditionC
Manage D&D 5e conditions on targets (add, remove, query, tick duration)
Inputs: targetId, encounterId, operation, condition, +8 more.
manage_encounterC
Composite tool for encounter management with state synchronization. Operations: create (with characterId linking), get (with verbosity), end (with participantUpdates), commit (sync to persistent characters), list (active encounters). Supports bridging encounter simulation state with persistent character records.
Inputs: operation, seed, participants, terrain, +13 more.
manage_inventoryC
Manage character inventory. Operations: give (add items), take (remove items), equip (equip to slot), unequip (remove from slot), move (change container), list (show inventory), transfer (move between characters).
Inputs: batch.
manage_locationC
Manage location graph for party navigation. Operations: create (new location), get (retrieve location + connections), update (modify properties), delete (remove location), link (connect two locations), unlink (disconnect locations), list (all locations). Supports location types, lighting, hazards, tags, and connection types (door, passage, stairs, ladder, portal, hidden).
Inputs: operation, name, description, locationType, +18 more.
manage_notesC
Manage session notes. Operations: add (add note with content/tags/importance), search (search by query/tagFilter), get (get by noteId), delete (remove by noteId), list (list recent with limit).
Inputs: operation, content, tags, importance, +4 more.
manage_partyA
Manage party composition. Operations: add (add character to party with optional role), remove (remove character from party), list (show party roster), get (get party member details), set_role (assign role to party member), clear (remove all members). Roles: leader, scout, healer, tank, support, damage, utility, other.
Inputs: operation, characterId, characterName, role.
manage_spell_slotsA
Manage D&D 5e spell slots. Operations: view (display slots), expend (use slot), restore (regain slots), set (DM override). Supports warlock pact magic (short rest recovery). Full/half/third casters calculated by class and level. Batch support for party spell tracking.
Inputs: characterId, characterName, operation, slotLevel, +4 more.
measure_distanceC
Measure distance between two positions using D&D 5e grid mechanics
Inputs: from (required), to (required), encounterId, mode, +1 more.
modify_terrainA
Add, remove, or clear terrain in a combat encounter. Supports obstacles, difficult terrain, water, and hazards. Use for dynamic battlefield changes from spells (Wall of Stone, Spike Growth), abilities, or environmental effects.
Inputs: encounterId (required), operation (required), terrainType (required), positions, +3 more.
move_partyB
Move the party between connected locations. Operations: move (travel to connected location), status (show current location and exits), history (show travel history). Validates connections, handles locked/hidden passages, one-way paths, and tracks travel history.
Inputs: operation, toLocationId, toLocationName, force, +3 more.
place_propC
Place or manage interactive props on the battlefield (barrels, doors, chests, etc.)
Inputs: encounterId (required), operation, name, type, +16 more.
render_battlefieldB
Render an ASCII map of the current combat state showing participant positions, obstacles, and terrain. Returns a text-based grid visualization.
Inputs: encounterId (required), showLegend, showCoordinates, showElevation, +3 more.
roll_checkC
Roll D&D 5e checks including skill checks, ability checks, saving throws, attack rolls, and initiative
Inputs: checkType (required), characterId, characterName, skill, +7 more.
roll_death_saveA
Roll a death saving throw for a character at 0 HP. D&D 5e rules: 10+ success, 9- failure, nat 1 = 2 failures, nat 20 = revive at 1 HP. 3 successes = stable (unconscious but not dying), 3 failures = death. Supports modifiers from spells like Bless and roll modes (advantage/disadvantage). Returns ASCII-formatted death save result with visual tracker.
Inputs: encounterId (required), characterId (required), modifier, rollMode, +2 more.
roll_diceA
Roll dice using standard notation (e.g., "2d6+4", "4d6kh3"). Supports single rolls or batch rolling multiple expressions at once. Supports advantage/disadvantage for d20 rolls. Provide either "expression" for single roll or "batch" for multiple rolls.
Inputs: expression, batch, reason, advantage, +1 more.
synthesize_spellA
Arcane Synthesis for improvised magic. Caster proposes a custom spell effect; Arcana check DC = 10 + (level × 2) + modifiers. Success creates temporary spell effect, failure may cause mishaps. Supports circumstance modifiers (ley lines, desperation, material components).
Inputs: casterId (required), intent (required), proposedSpell (required), encounterId, +7 more.
take_restA
Process short or long rest for D&D 5e character. Short rest: spend hit dice to heal. Long rest: restore all HP, half hit dice (rounded up), and clear until_rest conditions. Supports batch for party rests.
Inputs: characterId, characterName, restType, hitDiceToSpend, +6 more.
update_characterC
Update an existing D&D 5e character with new stats, HP, level, equipment, etc.
Inputs: characterId, characterName, name, race, +25 more.
use_scrollA
Use a spell scroll in D&D 5e. If spell is on your class list and same/lower level: auto-success. If spell is higher level: Arcana check DC 10 + spell level. On failure: scroll is consumed with no effect. On success: spell is cast from scroll, scroll consumed.
Inputs: characterId (required), scrollName (required), spellLevel (required), casterLevel (required), +9 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 35 tools
Most tools have distinct purposes with clear boundaries, such as 'advance_turn' for combat flow and 'calculate_aoe' for area calculations. However, some overlap exists, like 'manage_encounter' potentially duplicating functions of 'create_encounter', 'get_encounter', and 'end_encounter', which could cause confusion in selection.
Tool names consistently follow a verb_noun pattern throughout, such as 'advance_turn', 'calculate_aoe', and 'manage_condition'. This uniformity makes the set predictable and easy to navigate, with no mixing of naming conventions like camelCase or other styles.
With 35 tools, the count is excessive for a D&D 5e server, leading to potential overwhelm and redundancy. A more focused set of 10-20 tools could better cover the domain without unnecessary complexity, as some tools like 'manage_encounter' and 'execute_action' might be consolidated.
The tool set comprehensively covers D&D 5e gameplay, including character management, combat simulation, spell handling, and session tracking. There are no obvious gaps; it supports CRUD operations, lifecycle events, and edge cases like death saves and improvised magic, ensuring agents can handle most scenarios.
Maintenance
Related MCP Connectors
Play and build AI RPG worlds: your agent tells the story, Worldtable keeps HP, items and the map.
D&D and TTRPG campaign manager for GMs: your AI reads and writes a live, typed campaign database.
Dungeons & Dragons (D&D) and TTRPG companion: SessionKeeper sessions, NPCs, wiki, DM prep.
Mess in, magic out: your D&D and TTRPG notes become a private world store any AI app can read.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables creation and management of structured game worlds for text adventures and RPGs with character creation, world generation, and natural language interaction through AI integration.1MIT
- AlicenseCqualityBmaintenanceRPG game engine that lets AI run tabletop sessions without hallucinating mechanics. SQLite-backed persistence, D\&D 5e-style combat, procedural world generation, and deterministic dice.1010047MIT
- AlicenseAqualityDmaintenanceEnables playing RPGs with LLMs through tools for dice rolling (e.g., '1d6'), success checks with criticals, and random event generation.62MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that enables AI agents to act as dynamic dungeon masters for text-based RPGs with dynamically generated rule systems and comprehensive game state management.15MIT