A comprehensive Model Context Protocol (MCP) server designed to assist with Tabletop Role-Playing Games (TTRPGs). This project provides a complete assistant ecosystem for Dungeon Masters and Game Runners, featuring AI-powered content search, campaign management, and real-time collaboration tools.
The TTRPG Assistant is a modern, production-ready application that combines:
- MCP Server: FastMCP-based protocol server for AI assistant integration
- Web Application: Responsive SvelteKit frontend for browser use
- Desktop Application: Cross-platform Tauri + Rust desktop app with native features
- Real-time Collaboration: WebSocket-based multi-user gaming sessions
- ๐ PDF Processing: Extracts and indexes content from TTRPG rulebooks and source materials
- ๐ Hybrid Search: Combines semantic (vector) and keyword search for accurate, contextual results
- ๐ฒ Campaign Management: Complete campaign data storage and retrieval system
- โ๏ธ Session Tracking: Initiative tracking, monster health, condition management
- ๐ญ Personality System: Adapts AI responses to match different game system tones
- ๐ฅ Character Generation: Create NPCs and characters with appropriate stats and backstories
- ๐ง Adaptive Learning: Improves PDF processing accuracy through machine learning
- ๐ Multi-Platform: Web application + cross-platform desktop app (Windows, macOS, Linux)
- ๐ค AI Provider Integration: Support for Anthropic Claude, OpenAI GPT, Google Gemini, and Ollama
- ๐ Enterprise Security: OAuth2, JWT tokens, AES-256-GCM encryption, sandboxed execution
- โก Real-time Collaboration: WebSocket-based multi-user sessions with conflict resolution
- ๐ฑ Responsive Design: Mobile-first UI that works on all devices
- ๐ Offline Support: Service Worker-based offline capabilities
- Language: Python 3.11+
- MCP Framework: FastMCP with stdio/WebSocket communication
- Web Framework: FastAPI for bridge services and HTTP endpoints
- Database: ChromaDB (vector database) + SQLite (structured data)
- Search: Hybrid vector embeddings + BM25 keyword search
- AI Integration: Multi-provider support with automatic failover
- Framework: SvelteKit 2.6+ with SSR and static generation
- Language: TypeScript with strict type checking
- Styling: TailwindCSS with responsive design
- State Management: Svelte 5 runes and stores
- Real-time: WebSocket client with automatic reconnection
- Framework: Tauri 2.1 (Rust) with SvelteKit frontend
- Size: 12-18MB (96% smaller than Electron)
- Communication: JSON-RPC 2.0 over stdio (no network required)
- Features: System tray, native dialogs, auto-updater, file associations
- Performance: <1ms IPC latency vs 5-10ms for WebSocket
- Code Quality: Black, isort, flake8, mypy (Python) + ESLint, Prettier (TypeScript)
- Testing: Pytest, Vitest, Playwright for comprehensive coverage
- Build System: Unified build script with auto-detected package managers
- Deployment: Docker, systemd service, automated packaging
The project includes a comprehensive build script that automatically detects and uses your preferred package managers:
# Clone and setup
git clone https://github.com/Raudbjorn/MDMAI.git
cd MDMAI
# Install all dependencies (auto-detects uv, poetry, pnpm, yarn, npm)
./build.sh setup
# Build all components
./build.sh build
# Start development servers
./build.sh dev-backend # Python MCP server
./build.sh dev-webapp # SvelteKit web app
./build.sh dev-desktop # Tauri desktop appIf you prefer manual setup or want more control:
# Recommended: Use uv for fastest setup
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv && uv pip install -e ".[dev,test,docs]"
# Alternative: Use poetry
poetry install --with dev,test,docs
# Alternative: Use pip with venv
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,test,docs]"cd frontend
npm install # or yarn/pnpm
npm run devcd desktop/frontend
npm install
npm run tauri:devThe unified build script provides comprehensive development commands:
./build.sh setup # Install all dependencies./build.sh build # Build all components
./build.sh backend # Build Python backend only
./build.sh webapp # Build web app only
./build.sh desktop # Build desktop app (dev)
./build.sh desktop-release # Build desktop app (release)./build.sh dev-backend # Start MCP server (stdio mode)
./build.sh dev-webapp # Start web app (http://localhost:5173)
./build.sh dev-desktop # Start desktop app with hot reload./build.sh test # Run all tests
./build.sh lint # Lint all code
./build.sh format # Format all code./build.sh clean # Clean all build artifacts
./build.sh help # Show detailed help# All tests
./build.sh test
# Python tests only
source .venv/bin/activate # or poetry shell
pytest -v
# Frontend tests
cd frontend && npm test
# Type checking
./build.sh lint- Python: Unit, integration, and performance tests with pytest
- Frontend: Component tests with Vitest, E2E tests with Playwright
- Desktop: Rust unit tests + TypeScript validation
- Target: 80% overall coverage, 95% for critical paths
MDMAI/
โโโ src/ # Python MCP server source
โ โโโ main.py # MCP server entry point
โ โโโ tools/ # MCP tool implementations
โ โโโ search/ # Hybrid search engine
โ โโโ campaign/ # Campaign management
โ โโโ bridge/ # WebSocket bridge server
โโโ frontend/ # SvelteKit web application
โ โโโ src/lib/ # Shared components and utilities
โ โโโ src/routes/ # SvelteKit routes
โ โโโ src/app.html # HTML template
โโโ desktop/ # Desktop application
โ โโโ frontend/ # SvelteKit frontend (desktop)
โ โ โโโ src-tauri/ # Rust/Tauri backend
โ โ โโโ src/ # TypeScript/Svelte frontend
โ โโโ backend/ # Python MCP wrapper
โโโ tests/ # Python tests
โโโ docs/ # Documentation
โโโ deploy/ # Deployment scripts and configs
โโโ scripts/ # Build and utility scripts
โโโ build.sh # Unified build script
โโโ Makefile # Traditional make targets
โโโ pyproject.toml # Python project configuration
- Core Architecture: Multi-platform build system with Tauri + SvelteKit
- Desktop Framework: Full Tauri 2.1 integration with native features
- Communication Layer: JSON-RPC 2.0 over stdio for zero-latency IPC
- Process Management: Robust Python subprocess lifecycle management
- Data Management: Enterprise-grade SQLite + ChromaDB with AES-256-GCM encryption
- File Operations: Streaming file processing with integrity verification
- Native Features: System tray, drag-drop, native dialogs, auto-updater
- Error Handling: Comprehensive error-as-values patterns throughout
- Type Safety: Full TypeScript + Rust type safety with zero compilation errors
- Code Quality: Refactored codebase with 14% line reduction, eliminated dead code
- Core MCP Server: FastMCP implementation with tool definitions
- PDF Processing: Advanced extraction pipeline with table preservation
- Search Engine: Hybrid vector + keyword search with ChromaDB
- Campaign Management: Backend data models and API endpoints
- Web Frontend: Complete SvelteKit application with real-time features
- MCP Tools: 30+ specialized tools for TTRPG assistance
- AI Integration: Multi-provider support with Ollama local models
- Deployment: Production packaging and systemd service integration
The server provides 30+ specialized MCP tools optimized for TTRPG gameplay:
search_rules- Hybrid semantic + keyword search across rulebooksget_monster- Monster stat blocks with party scaling suggestionsadd_source- Add PDF rulebooks to the knowledge baselist_sources- Manage indexed source materials
create_campaign- Initialize new campaigns with metadatamanage_timeline- Track in-game time and eventstrack_resources- Party inventory and resource managementmanage_quests- Quest objectives and progress tracking
roll_dice- Advanced dice rolling with modifiers and advantagemanage_initiative- Combat initiative with conditions and delaystrack_damage- HP tracking with resistances and temporary effectstake_notes- AI-categorized session notes with entity linking
generate_character- Complete character creation with backstoriesgenerate_npc- NPCs with relationships and motivationsgenerate_location- Detailed locations with maps and encountersgenerate_plot_hook- Context-aware story seeds and adventures
broadcast_to_players- Selective information sharingsync_game_state- Automatic state synchronizationrequest_player_action- Interactive prompts and decision points
Copy .env.example to .env and configure:
# MCP Server Configuration
MCP_STDIO_MODE=true # Use stdio for MCP (recommended)
MCP_LOG_LEVEL=INFO # Logging level
# AI Provider Settings (choose one or more)
ANTHROPIC_API_KEY=your_key_here # Claude integration
OPENAI_API_KEY=your_key_here # OpenAI integration
GOOGLE_API_KEY=your_key_here # Gemini integration
# Database Configuration
DATABASE_PATH=./data/ttrpg.db # SQLite database location
VECTOR_DB_PATH=./data/chroma # ChromaDB vector storage
# Security Settings
SECRET_KEY=your_secret_key # JWT signing key
ENCRYPTION_KEY=your_encryption_key # Data encryption keyThe build system automatically detects and uses available package managers:
- Python: uv (fastest) โ poetry โ pip
- Node.js: pnpm โ yarn โ npm
- Rust: cargo (required for desktop builds)
# Build Docker image
./build.sh clean && docker build -t ttrpg-assistant .
# Run with Docker Compose
docker-compose up -d# Install as systemd service
make deploy-install
# Configure service
make deploy-configure
# Start service
systemctl start ttrpg-assistant# Build release packages
./build.sh desktop-release
# Packages created in: desktop/frontend/src-tauri/target/release/bundle/
# - Windows: .msi installer
# - macOS: .dmg disk image
# - Linux: .AppImage + .deb package- Fork and clone the repository
- Install dependencies:
./build.sh setup - Run tests:
./build.sh test - Start development:
./build.sh dev-desktopor./build.sh dev-webapp
- Python: Follow PEP 8, use type hints, maintain 90%+ test coverage
- TypeScript: Strict mode enabled, use error-as-values patterns
- Rust: Follow Rust best practices, use
cargo clippy - Commits: Use conventional commits with clear descriptions
- Create feature branch:
git checkout -b feature/your-feature - Run quality checks:
./build.sh lint && ./build.sh test - Update documentation if needed
- Submit PR with clear description and test results
This project is licensed under the MIT License - see the LICENSE file for details.
- FastMCP: Modern MCP framework for Python
- SvelteKit: Outstanding frontend framework
- Tauri: Revolutionary desktop application framework
- ChromaDB: Excellent vector database for embeddings
- Claude: AI assistance in development and documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
Happy Gaming! ๐ฒ
Built with โค๏ธ for the TTRPG community