RPG-MCP is a comprehensive, rules-enforced D&D 5e-compatible RPG backend that turns any LLM into a game master with deterministic physics and persistent state management. The server provides anti-hallucination validation where LLMs propose intentions but cannot directly mutate world state—all actions are validated against rules.
Core Systems:
World Management: Generate procedural worlds with 28+ biomes, terrain-aware POI placement, dynamic environmental systems (time, weather, seasons, moon phases), and multi-world setups with forkable timelines for parallel simulations
D&D 5e Combat: Full tactical combat with initiative tracking, 3D spatial positioning, obstacles/difficult terrain, opportunity attacks, death saving throws, legendary creature lair actions, area-of-effect calculations, and ASCII map visualization
Magic System: 15+ SRD spells with slot tracking, class-based progression, Warlock pact magic, concentration mechanics, rest recovery, and anti-hallucination validation preventing unknown spell casting
Character & Party Management: Create characters with full D&D stat blocks, class/race support, level progression, equipment systems, and organize into parties with roles (leader, member, companion, hireling, prisoner, mount) and world map travel
Inventory & Economy: Complete system with equipment slots, weight tracking, item templates, currency with auto-conversion, and theft mechanics featuring heat levels, witness recording, and fence NPCs
Quest System: Create quests with typed objectives (kill, collect, deliver, explore, interact), track progress, define prerequisites for quest chains, and grant rewards (gold, items, XP)
NPC & Social: Relationship tracking, conversation history with importance levels, context injection for LLM prompts, corpse mechanics with decay states, loot tables with guaranteed/random drops, and harvestable resources
Narrative Memory: Persistent story layer tracking plot threads, canonical moments, NPC voices, foreshadowing, and session logs with visibility controls
Improvisation Engine: Rule of Cool stunts, custom effects (boons, curses, transformations), and arcane synthesis for dynamic spell creation
Grand Strategy: Nation simulation with leaders, ideologies, resources, personality traits, diplomacy, territorial claims, turn-based resolution, and fog of war
Math & Physics: D&D dice notation (advantage/disadvantage, exploding dice), probability calculations, algebra solver, and projectile trajectory computation
Spatial Navigation: Room-based dungeon networks, terrain-aware movement, and environmental observation tools
Technical Features:
Multi-tenant Architecture: Isolated projects with SQLite persistence and full audit trails
Real-time Eventing: Subscribe to world and combat events via JSON-RPC notifications
Tool Discovery: Search and load schemas for 135-145+ MCP tools by category or keyword
Token Efficiency: Composite tools and shorthand notation reduce LLM context overhead by 80-95%
Deterministic Execution: Seed-based randomness ensures reproducible results with 800+ tests ensuring system integrity
Runs as a Node.js application with support for standalone binary distribution, providing the runtime environment for the MCP server.
Uses SQLite as the persistence layer for storing world state, entities, inventories, combat encounters, quests, and all simulation data with full transaction support and migration system.
Implemented in TypeScript with full type safety across the codebase, providing strongly-typed schemas and APIs for all simulation systems.
Employs Zod for runtime schema validation of all entities, actions, world state, and constraints, ensuring type safety at API boundaries and preventing invalid data mutations.
Click on "Install 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., "@rpg-mcpI attack the goblin with my longsword"
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.
mnehmos.rpg.mcp: Agentic Embodied Simulation Kernel
A rules-enforced RPG backend that turns any LLM into a game master who can't cheat.
What Is This? (Start Here)
You are the player. The AI is the dungeon master.
You talk to an AI (Claude, GPT, etc.) in natural language. You say things like "I attack the goblin" or "I search the room for traps." The AI narrates what happens and describes the world.
The difference from pure AI storytelling: This engine enforces the rules. When you attack, it actually rolls dice, checks armor class, calculates damage, and updates HP in a real database. The AI can't just decide you hit or miss—the math happens, and both you and the AI see the result.
What can you actually do?
Explore procedurally generated worlds with 28+ biome types
Fight enemies using D&D 5e-style combat (initiative, AC, damage rolls, death saves)
Cast spells with real slot tracking—if you're out of slots, you can't cast
Manage inventory with equipment slots, weight, and item properties
Complete quests with tracked objectives and rewards
Interact with NPCs who remember your conversations across sessions
Everything persists—close the game, come back tomorrow, your character is exactly where you left them
Who is this for?
Solo RPG players who want AI-driven adventures with mechanical integrity
People frustrated with AI RPGs that fall apart when you ask "wait, how much HP do I have?"
Developers building AI game integrations who need a reference implementation
How do I play?
Install the MCP server (see Installation below)
Connect it to Claude Desktop (or any MCP-compatible client)
Tell the AI: "Let's start a new game. Create a character for me."
Play naturally—the AI handles narration, the engine handles mechanics
v1.0 Release (January 2026)
85% Tool Reduction: 195 → 28 Consolidated Tools
This release consolidates 195 individual tools into 28 action-based tools using:
Action enums - Each tool handles multiple operations via an
actionparameterFuzzy matching - Typo-tolerant action matching with suggestions
Guiding errors - Clear feedback when actions don't match
Before: create_character, get_character, update_character, delete_character, list_characters...
After: character_manage with actions: create, get, update, delete, list, search
Key Metrics
Metric | Before | After | Change |
MCP Tools | 195 | 28 | 85.6% reduction |
Tests | 1,242 | 2,080+ | +67% coverage |
Token overhead | ~50K | ~6-8K | 85% reduction |
Meta-Tools for Discovery
Two special tools help LLMs discover and use the consolidated tools:
Tool | Purpose |
| Search tools by keyword, category, or capability |
| Load full parameter schema before first use |
Architecture Philosophy
This engine implements the Event-Driven Agentic AI Architecture:
The Embodiment Model
Biological System | RPG-MCP Component | Role |
Brain | LLM Agent (external) | Strategic reasoning, planning, interpretation |
Nervous System | Engine + Orchestrator | Validates intent, enforces constraints, routes actions |
Reflex Arc | Constraint Validator | Blocks impossible actions before execution |
Sensory Organs | Observation Tools |
|
Muscles | Action Tools |
|
Environment | World State + Physics | SQLite-persisted, deterministic, forkable reality |
Key invariant: LLMs propose intentions. The engine validates and executes. LLMs never directly mutate world state.
Consolidated Tools Reference (28 Tools)
Character & Party
Tool | Actions | Description |
| create, get, update, delete, list, search | Full character CRUD with D&D stat blocks |
| create, get, update, delete, add_member, remove_member, set_leader, context | Party management and member operations |
Combat System
Tool | Actions | Description |
| create, get, end, load, advance, death_save, lair_action, add_participant, remove_participant | Encounter lifecycle and initiative |
| attack, cast, move, dash, dodge, disengage, help, ready | Combat actions with full D&D 5e rules |
| get_terrain, set_terrain, get_positions, calculate_aoe | Tactical grid and terrain management |
Inventory & Economy
Tool | Actions | Description |
| create, get, update, delete, list, search | Item template CRUD |
| give, remove, transfer, equip, unequip, use | Inventory operations between characters |
| create, get, list, loot, harvest, advance_decay, cleanup | Death and loot mechanics |
| steal, check_stolen, check_recognition, report | Theft with heat tracking |
World & Spatial
Tool | Actions | Description |
| generate, get, update, list, delete | Procedural world generation |
| get_overview, get_region, patch, preview | Map queries and modifications |
| look, move, generate_room, get_exits, list_rooms | Dungeon navigation and room networks |
Quests & NPCs
Tool | Actions | Description |
| create, get, list, assign, complete, fail, abandon, add_objective, update_objective | Quest lifecycle management |
| get_relationship, update_relationship, record_memory, get_history, interact | NPC memory and social interactions |
| create, list, get_affecting, process, remove, expire | Area effects and buffs/debuffs |
Magic & Rest
Tool | Actions | Description |
| use, create, identify, get_dc, get_details | Scroll mechanics |
| long_rest, short_rest | HP and spell slot recovery |
| check_save, break, get_state, check_duration | Spell concentration tracking |
Utility & Meta
Tool | Actions | Description |
| create, get, list, update, delete, reveal, check_conditions | DM secrets with reveal conditions |
| add, search, update, get, delete, get_context | Story notes and session history |
| resolve_stunt, apply_effect, get_effects, remove_effect, advance_duration, attempt_synthesis | Rule of Cool and custom effects |
| dice_roll, probability, algebra, physics | Dice and calculations |
| create_nation, get_state, propose_alliance, claim_region | Grand strategy simulation |
| init, get_status, submit_actions, mark_ready, poll_results | Async turn management |
| spawn_character, spawn_location, spawn_encounter, spawn_preset_location, spawn_tactical | Entity and encounter spawning |
| initialize_session, get_context | Session state management |
| travel, loot, rest | Party movement and field actions |
| create_characters, create_npcs, distribute_items, execute_workflow | Bulk operations |
Installation
Option 1: npm (Recommended)
Option 2: Standalone Binaries
Download pre-built binaries from Releases:
Option 3: From Source
MCP Client Configuration
Claude Desktop / MCP Clients:
Using Binary:
Core Systems
Combat & Encounters
Initiative tracking with advantage/disadvantage
Spatial combat with grid positioning and collision
Opportunity attacks with reaction economy
Death saving throws (D&D 5e rules)
Damage resistance/vulnerability/immunity
Legendary creatures with lair actions and legendary resistances
Encounter presets - Pre-balanced encounters by party level
Magic System
15+ SRD spells (Magic Missile, Fireball, Cure Wounds, etc.)
Spell slot tracking with class-based progression
Warlock pact magic with short rest recovery
Concentration tracking
Anti-hallucination validation - LLMs cannot cast spells they don't know
Theft & Economy
Stolen item tracking with heat levels (burning → cold)
Witness recording for theft detection
Fence NPCs with buy rates and heat capacity
Item recognition - original owners detect their stolen goods
NPC Memory
Relationship tracking (familiarity + disposition)
Conversation memory with importance levels
Context injection for LLM prompts
Interaction history across sessions
Improvisation Engine
Rule of Cool stunts - "I kick the brazier into the zombies"
Custom effects - Divine boons, curses, transformations
Arcane synthesis - Dynamic spell creation with wild surge risk
Project Structure
Design Principles
LLMs propose, never execute The brain suggests; the nervous system validates.
All action is tool-mediated No direct world mutation. Every change flows through MCP tools.
Validation precedes observation Act → Validate → Observe. The reflex arc pattern.
Deterministic outcomes Same inputs → same outputs. Always reproducible.
Schema-driven everything Zod validates all data at boundaries. Type safety end-to-end.
Anti-hallucination by design LLMs cannot cast spells they don't know or claim damage they didn't roll.
Token efficiency 28 consolidated tools with action routing reduce context overhead by 85%.
Guiding errors Invalid actions return suggestions, not just failures.
Test Coverage
Contributing
Contributions welcome! Please:
Fork the repo
Create a feature branch (
git checkout -b feature/your-feature)Write tests for new functionality
Follow existing code style (TypeScript + Zod + tests)
Submit a pull request
Roadmap
Full spellcasting system with validation
Theft and fence economy
Corpse and loot mechanics
NPC memory and relationships
Improvisation engine
Tool consolidation (195 → 28)
Fuzzy action matching
Preset systems (creatures, encounters, locations)
WebSocket real-time subscriptions
Dialogue tree system
Cover mechanics in combat
Quest chains with prerequisites
License
ISC — Use freely, attribution appreciated.
Related
Quest Keeper AI — Desktop AI dungeon master using this engine
Documentation
CLAUDE.md - Development instructions
docs/WHITE_PAPER.md - Design philosophy and architecture
docs/LLMSpatialGuide.md - LLM spatial navigation guide