AI GM is a Model Context Protocol (MCP) server that provides intelligent game master assistance for tabletop RPGs. It can process rulebook PDFs, adjudicate rules, and integrate with Foundry VTT using local LLMs via Ollama.
- Universal Game System Support: Built-in support for D&D 5e and Cyberpunk RED, with extensible architecture for any RPG system
- PDF Rulebook Processing: Extract and index rules from PDF rulebooks
- Intelligent Rules Adjudication: Use local LLMs to interpret and adjudicate rules
- Foundry VTT Integration: Automate VTT operations and assist with game management
- Local LLM Integration: Uses Ollama for privacy-focused, offline AI assistance
- MCP Protocol: Compatible with Claude Code and other MCP clients
- D&D 5e: Full support for fifth edition mechanics, character generation, and rules
- Cyberpunk RED: Complete implementation of CP RED systems and mechanics
- Extensible: Easy to add new game systems with the base system architecture
-
Prerequisites:
- Node.js 18+
- Ollama installed and running
-
Install dependencies:
npm install
-
Build the project:
npm run build
Add to your Claude Code configuration:
{
"mcpServers": {
"ai-gm": {
"command": "node",
"args": ["/path/to/ai-gm/dist/index.js"],
"cwd": "/path/to/ai-gm"
}
}
}
-
process_rulebook: Process a PDF rulebook and extract rules
process_rulebook(file_path: "/path/to/rulebook.pdf")
-
adjudicate_rule: Get AI-powered rule adjudication
adjudicate_rule(query: "How does advantage work with critical hits?", context: "Combat situation")
-
set_game_system: Set the active game system
set_game_system(system_id: "dnd5e")
-
list_game_systems: See all available game systems
list_game_systems()
-
detect_game_system: Auto-detect game system from rule text
detect_game_system(rule_text: "Roll 1d20 + ability modifier vs AC")
-
generate_character: Generate characters for the active system
generate_character(level: 3, options: {"class": "Fighter", "race": "Human"})
-
foundry_assist: Automate Foundry VTT operations
foundry_assist(action: "roll_dice", parameters: {"formula": "1d20+5", "reason": "Attack roll"})
AI GM uses a modular system architecture that makes it easy to add new RPG systems:
// Example: Adding a new system
class MyGameSystem extends BaseGameSystem {
id = 'my_game';
name = 'My RPG System';
diceSystem = { primaryDie: 20, exploding: false };
// ... implement required methods
}
systemManager.registerSystem(new MyGameSystem());
Each system defines:
- Dice mechanics and modifiers
- Attribute and skill systems
- Combat rules and health systems
- Magic/special ability systems
- Equipment and advancement rules
-
Install Ollama: Follow instructions at https://ollama.ai
-
Pull a compatible model:
ollama pull llama3.2
-
Configure model (optional): Edit the default model in
src/llm/ollama-client.ts
Place your rulebook PDFs in an accessible directory and use the process_rulebook
tool:
await processRulebook("/path/to/players-handbook.pdf");
The system will:
- Extract text from the PDF
- Identify sections and rules
- Create searchable indexes
- Enable intelligent rule lookup
AI GM can assist with common Foundry operations:
- Dice Rolling: Automated rolls with reasoning
- Token Management: Create and manage tokens
- Scene Updates: Modify lighting, weather, backgrounds
- Combat Automation: Initiative tracking, NPC actions
- Character Generation: Create characters directly in Foundry
- Fork the repository
- Create a feature branch
- Add new game systems by extending
BaseGameSystem
- Add tests for new functionality
- Submit a pull request
MIT License - see LICENSE file for details.
- Additional game systems (Pathfinder, World of Darkness, Call of Cthulhu)
- Vector database integration for better rule search
- Web interface for standalone use
- Campaign management features
- Enhanced Foundry VTT API integration
- Multi-language support