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.
RPG-MCP: Agentic Embodied Simulation Kernel
A deterministic, schema-driven, multi-world simulation engine for embodied AI agents.
RPG-MCP is not a game—it's a world kernel. It provides the physics, constraints, persistence, and deterministic execution layer that allows LLM agents to inhabit a simulated reality with real bodies, real limits, and real consequences.
What's New (December 2025)
Latest Release
145+ MCP Tools - Complete RPG mechanics coverage with new composite tools
800+ Passing Tests - Comprehensive test coverage across all systems
Composite Tools (TIER 1) - Reduce token overhead by 80-95% for common workflows
Preset Systems - 1100+ creature presets, 50+ encounter presets, 30+ location presets
Schema Shorthand (TIER 2) - Token-efficient position/stats parsing
Batch Repository Methods - Optimized for world generation workflows
Location Presets - Tavern, dungeon, temple, market presets with full population
Encounter Presets - Level-scaled encounters (goblin ambush, undead crypt, dragon's lair)
Core Systems
Full Spellcasting System - 15+ SRD spells, class progression, slot tracking
Theft & Fence System - Heat decay, witness tracking, black market economy
Corpse & Loot System - Decay states, harvestable resources, loot tables
NPC Memory System - Relationship tracking, conversation history, context injection
Improvisation Engine - Rule of Cool stunts, custom effects, arcane synthesis
Legendary Creatures - Lair actions, legendary resistances, boss mechanics
Death Saving Throws - Full D&D 5e rules with stabilization
Spatial Navigation - Room networks, terrain-aware POI placement
Narrative Memory Layer - Session notes, plot threads, NPC voices, foreshadowing
Currency System - Gold/silver/copper with auto-conversion
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.
Features
Core Systems
Multi-tenant & Multi-world
Isolated projects (
projectId) and parallel worlds (worldId)Fork worlds for branching timelines or "what-if" simulations
Embodied Entities
Position, velocity, orientation in 3D space
Stats, inventories, status effects, controller links
Sensory radius, line-of-sight, perception limits
Intent-Based Actions
Agents submit intentions:
MOVE_TO,ATTACK,CAST_SPELL,INTERACTEngine validates against physics, rules, and constraints
Invalid actions rejected with structured feedback
Deterministic Physics
Collision detection, projectile trajectories, movement costs
Reproducible world steps—same inputs always yield same outputs
Full audit trail: snapshots, event logs, action history
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
Rest mechanics restore spell slots and HP
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
Heat decay over time
Corpse & Loot
Corpse creation on creature death
Loot tables with guaranteed and random drops
Harvestable resources (pelts, fangs, etc.)
Decay system (fresh → decaying → skeletal → gone)
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
Installation
Option 1: Standalone Binaries (Recommended)
Download the pre-built binary for your platform from the Releases page:
Windows:
macOS:
Linux:
The binaries are self-contained and include all dependencies. No Node.js installation needed.
Option 2: From Source
To build binaries yourself:
MCP Client Configuration
To use with an MCP-compatible client (Claude Desktop, etc.), add to your client's configuration:
Using Binary:
Using Source:
MCP Tools Reference (145+ Tools)
🚀 Composite Tools - TIER 1 (NEW)
Reduce token overhead by 80-95% for common workflows
Tool | Description |
| Spawn balanced combat with enemies, terrain, initiative |
| Create location with NPCs, items, terrain in one call |
| Create from preset (tavern, dungeon, temple, etc.) |
| Handle all encounter loot distribution |
| Party-wide short/long rest with HP/slot recovery |
| Move party to location with travel events |
World Management (12 tools)
Tool | Description |
| Create a new world |
| Retrieve world by ID |
| List all worlds |
| Delete world (cascades) |
| Procedural generation with Perlin noise |
| Full world state dump |
| Summary stats & biome distribution |
| Full tile grid |
| Single region details |
| DSL for map modifications |
| Dry-run of patch |
| Time, weather, season |
POI Location Tools (2 tools)
Tool | Description |
| Terrain-aware placement for points of interest |
| Suggest multiple valid POI locations |
Character Management (5 tools)
Tool | Description |
| Full D&D stat block support |
| Retrieve by ID |
| Update any field |
| List all characters |
| Remove from DB |
Inventory & Items (15 tools)
Tool | Description |
| Define item types |
| Get template by ID |
| All templates |
| Query by name/type/value |
| Modify template |
| Remove template |
| Add to character inventory |
| Take from inventory |
| Move between characters |
| Consume items |
| Assign to equipment slot |
| Return to inventory |
| Basic inventory list |
| Full item info, sorted |
| Transfer gold/silver/copper with auto-conversion |
Combat & Encounters (8 tools)
Tool | Description |
| Initialize combat with participants |
| Current combat status |
| Resume saved encounter |
| End combat, sync HP |
| Attack/heal/move/cast spell |
| Move to next in initiative |
| D&D 5e death saving throws |
| Legendary creature lair actions |
Spellcasting (integrated with combat)
Action | Description |
| Cast known spell with slot consumption |
Rest System (2 tools)
Tool | Description |
| Restore all HP and spell slots |
| Hit dice healing, Warlock pact slots |
Theft & Fence System (10 tools)
Tool | Description |
| Record theft with heat tracking |
| Check if item is stolen |
| List all stolen items held |
| NPC recognition check |
| Sell stolen goods |
| Register NPC as fence |
| Report to guards (adds bounty) |
| Process heat decay |
| Get fence details |
| List all fences |
Corpse & Loot System (14 tools)
Tool | Description |
| Create corpse from dead character |
| Get corpse by ID |
| Get by original character |
| Items on corpse |
| Corpses in combat |
| Corpses near position |
| Loot single item |
| Harvest resources |
| Generate from loot table |
| Custom loot tables |
| Get table by ID |
| List all tables |
| Process decay |
| Remove decayed corpses |
NPC Memory System (7 tools)
Tool | Description |
| Get relationship status |
| Create/update relationship |
| Store conversation summary |
| Get memories with NPC |
| Recent memories across NPCs |
| Full context for LLM injection |
| Spatial-aware conversations |
Narrative Memory System (8 tools)
Tool | Description |
| Create plot threads, NPC voices, canonical moments |
| Get single note |
| Update note content/status |
| Remove note |
| Query by type/tags/status |
| Get notes for LLM context |
| Archive completed threads |
| Full narrative context bundle |
Improvisation System (8 tools)
Tool | Description |
| Rule of Cool resolution |
| Apply boons/curses/transformations |
| Get active effects |
| Remove effect |
| Fire effect triggers |
| Tick effect durations |
| Dynamic spell creation |
| Get mastered spells |
Quest System (8 tools)
Tool | Description |
| Define quest with objectives |
| Single quest details |
| All quests |
| Give quest to character |
| Increment progress |
| Mark objective done |
| Complete entire quest |
| Full quest objects |
Secrets System (9 tools)
Tool | Description |
| Hidden info with reveal conditions |
| DM-only view |
| All secrets for world |
| Modify properties |
| Remove secret |
| Show to player |
| Test if conditions met |
| Format for LLM injection |
| Scan text for accidental reveals |
Party System (17 tools)
Tool | Description |
| Create adventuring party |
| Get party details |
| All parties |
| Modify party properties |
| Remove party |
| Add character to party |
| Remove from party |
| Modify party member role |
| Change leadership |
| Set active PC |
| Get members with details |
| Party summary for LLM |
| Characters not in a party |
| Move entire party on world map |
| Party location |
| Parties in specific region |
Spatial Navigation (4 tools)
Tool | Description |
| Observe current location details |
| Create room in dungeon network |
| List exits from current room |
| Move character between rooms |
Math & Dice (5 tools)
Tool | Description |
| Full D&D notation (2d6+3, 4d6dl1, adv/dis) |
| Calculate odds |
| Solve equations |
| Simplify expressions |
| Trajectory calculations |
Grand Strategy (11 tools)
Tool | Description |
| Create nation with resources |
| Private nation state |
| World with fog of war |
| Diplomatic action |
| Territorial claims |
| Initialize turn management |
| Check nation readiness |
| Batch action submission |
| Signal turn complete |
| Process all actions |
| Get resolution results |
Preset Systems
Creature Presets (1100+ templates)
Categories: Humanoids, Undead, Beasts, Dragons, Demons, Elementals, and more.
Encounter Presets (50+ balanced encounters)
Location Presets (30+ templates)
Types: Taverns, Temples, Dungeons, Markets, Camps, Ruins, Lairs.
Use Cases
Tabletop RPG Backend Run D&D, Pathfinder, or custom systems with AI dungeon masters and NPCs that have real bodies and spatial reasoning.
Multi-Agent Simulation Test agent coordination, emergent behavior, or adversarial scenarios in a controlled, reproducible environment.
Embodied AI Research Study how LLMs behave when constrained by physics, resources, and perception limits—not just text.
Game Development Use as a headless game server with deterministic state, replay capability, and clean API boundaries.
Training Data Generation Fork worlds, run thousands of parallel scenarios, collect structured action/outcome pairs.
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.
Events trigger tasks JIT execution. No polling, no stale state.
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 Composite tools and schema shorthand reduce LLM context overhead.
Test Coverage
Key test areas:
Combat encounters and HP persistence
Spellcasting validation (anti-hallucination)
Inventory integrity and exploit prevention
Theft/fence mechanics with heat decay
Corpse/loot system with decay states
NPC memory and relationship tracking
Improvisation system (stunts, effects, synthesis)
Composite tool workflows
Preset system expansion and validation
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
See CONTRIBUTING.md for detailed guidelines.
Roadmap
Full spellcasting system with validation
Theft and fence economy
Corpse and loot mechanics
NPC memory and relationships
Improvisation engine
Composite tools (TIER 1)
Preset systems (creatures, encounters, locations)
Narrative memory layer
WebSocket real-time subscriptions
Dialogue tree system
Cover mechanics in combat
Quest chains with prerequisites
Visual debugger / world inspector UI
License
ISC — Use freely, attribution appreciated.
Related
Quest Keeper AI — Desktop AI dungeon master using this engine
Documentation
CLAUDE.md - Claude Code development instructions
Agents/TOOL_CATALOG.md - Complete tool reference with examples
Agents/EMERGENT_DISCOVERY_LOG.md - Bug tracking and playtest findings
Agents/PROJECT_CONTEXT.md - Architecture and frontend integration