An AI-powered mythology world generator that creates complete, interconnected mythological universes from a single seed concept using Gemini, LlamaIndex, and Gradio.
"From a whisper of an idea, entire pantheons are born."
Try MythForge: https://huggingface.co/spaces/MCP-1st-Birthday/mythforge
MCP Server (Blaxel): Available for AI agents to generate mythologies programmatically.
Enter a seed concept like "A civilization that worships volcanoes as living gods" and watch an entire mythology come to life.
| Category | Technology |
|---|---|
| LLM | Google Gemini 2.0 Flash for mythology generation and Oracle Q&A |
| RAG Framework | LlamaIndex for knowledge graph indexing and semantic search |
| Embeddings | HuggingFace sentence-transformers for local embeddings |
| UI Framework | Gradio 6.0 for immersive, themed web interface |
| Text-to-Speech | ElevenLabs for dramatic audio narration |
| MCP Integration | Blaxel for deploying MythForge as an MCP Server |
| Data Models | Pydantic 2.0 for robust entity validation |
| Visualization | Plotly for interactive timelines and relationship graphs |
| Language | Python 3.11+ |
mythforge/
├── app.py # Main Gradio application entry point
├── requirements.txt # Python dependencies
├── mythforge/
│ ├── __init__.py
│ ├── app.py # Multi-page Gradio app with 8 chambers
│ ├── core/
│ │ ├── config.py # Environment & settings management
│ │ └── exceptions.py # Custom exceptions
│ ├── models/
│ │ ├── entities.py # Pydantic models (Deity, Creature, Myth, etc.)
│ │ └── mythology.py # Main Mythology container model
│ ├── services/
│ │ ├── gemini_service.py # Gemini API integration & generation
│ │ ├── llamaindex_service.py # RAG & knowledge graph management
│ │ └── elevenlabs_service.py # Audio narration service
│ ├── ui/
│ │ ├── theme.py # Custom dark fantasy theme & CSS
│ │ └── pages/ # 8 unique page modules
│ │ ├── genesis.py # Mythology creation chamber
│ │ ├── sanctum.py # Dashboard overview
│ │ ├── codex.py # Entity wiki browser
│ │ ├── oracle.py # RAG-powered Q&A chat
│ │ ├── theater.py # Audio narration player
│ │ ├── timeline.py # Divine history visualization
│ │ ├── realms.py # Interactive world map
│ │ └── language.py # Constructed language generator
│ ├── prompts/
│ │ └── mythology_prompts.py # Structured generation prompts
│ └── blaxel/
│ ├── mcp_server.py # MCP Server with 7 tools
│ ├── agent.py # FastAPI HTTP agent
│ └── blaxel.toml # Blaxel deployment config
└── data/
├── mythologies/ # Saved mythology JSON files
└── sessions/ # User session data
- Multi-phase generation: Cosmology → Pantheon → Creatures → Places → Myths → Prophecies
- Streaming progress: Real-time status updates during 60-90 second generation
- Coherent worldbuilding: All elements interconnected through relationships
- Statistics overview: Entity counts, relationship graphs
- Quick navigation: Jump to any entity or chamber
- Mythology summary: Key themes and concepts at a glance
- Filterable browser: Search by entity type (Deity, Creature, Place, Myth, etc.)
- Relationship mapping: See connections between entities
- Rich details: Descriptions, attributes, quotes, abilities
- Conversational interface: Ask anything about your mythology
- Context-aware responses: Powered by LlamaIndex semantic search
- Source attribution: See which entities informed each answer
- Dramatic narration: ElevenLabs text-to-speech with epic voices
- Content selection: Narrate myths, prophecies, deity descriptions
- Playback controls: Full audio player with download option
- Visual chronology: Plotly-powered interactive timeline
- Era organization: Creation, Golden Age, Wars, Prophecies
- Event details: Click to explore each historical moment
- Interactive visualization: Explore the cosmic geography
- Realm connections: See how different planes connect
- Location details: Sacred places, temples, forbidden zones
- Complete languages: Phonology, grammar, vocabulary
- Writing systems: Runic, hieroglyphic, cuneiform options
- Sacred texts: Sample prayers and inscriptions
- Audio pronunciation: Hear words spoken aloud
MythForge is deployed as an MCP Server on Blaxel, allowing any AI agent to create and query mythologies:
| Tool | Description |
|---|---|
create_mythology |
Generate a complete mythology from a seed concept |
query_lore |
Ask questions about an existing mythology (RAG) |
list_mythologies |
List all available mythologies |
get_entity |
Get details about a specific entity |
generate_language_vocabulary |
Create a constructed language |
expand_myth |
Expand a myth into a full narrative |
get_mythology_summary |
Get comprehensive mythology overview |
https://run.blaxel.ai/hetansh-waghela/functions/mythforge-mcp/mcp
- Python 3.11+
- Google Gemini API key
- (Optional) ElevenLabs API key for audio
- Clone the repository
git clone https://github.com/HetanshWaghela/mcp-project-hackathon
cd mcp-project-hackathon- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r mythforge/requirements.txt- Set environment variables
# Create .env file in mythforge/
cp mythforge/.env.example mythforge/.env
# Edit with your API keys
GEMINI_API_KEY="your-gemini-api-key"
ELEVENLABS_API_KEY="your-elevenlabs-api-key" # Optional- Launch the application
cd mythforge
python app.py- Open in browser
http://localhost:7860
- "A civilization that worships volcanoes as living gods who demand sacrifice"
- "An underwater kingdom where dreams become physical reality"
- "Star-worshippers who believe constellations are frozen gods"
- "A realm where shadows have consciousness and wage war against light"
- "A world where death is just the beginning of true existence"
- "Beings who feed on forgotten memories and lost hopes"
- "A forest where every tree contains the soul of an ancestor"
- "Mountain spirits who carve the faces of heroes into stone"
- "Wind deities who carry whispered secrets across continents"
- "Ancient beings sleeping beneath the ocean, dreaming reality into existence"
- "A pantheon of gods who are themselves mere thoughts of something greater"
- "The space between stars where exiled deities plot their return"
MythForge employs sophisticated context engineering techniques to ensure coherent, interconnected mythology generation:
Seed Concept → Pydantic Models → JSON Schema → Validated Output
- Pydantic 2.0 Models: Every entity (Deity, Creature, Myth, etc.) has strict type validation
- Nested Relationships: Entities reference each other by ID, creating a graph structure
- Schema-Guided Generation: LLM outputs are parsed and validated against predefined schemas
Phase 1: Cosmology → Context A
Phase 2: Pantheon → Context A + B
Phase 3: Creatures → Context A + B + C
Phase 4: Places → Context A + B + C + D
Phase 5: Myths → Full Context (references all entities)
Phase 6: Prophecies → Full Context + Temporal awareness
Each generation phase receives accumulated context from previous phases, ensuring:
- Deities reference realms from cosmology
- Creatures inhabit places that exist
- Myths involve characters already created
- Prophecies reference established lore
Entities + Relationships → LlamaIndex Graph → Semantic Embeddings → Contextual Retrieval
- Graph Construction: Mythology converted to nodes (entities) and edges (relationships)
- HuggingFace Embeddings: Local sentence-transformers for semantic search
- Context-Aware Retrieval: Oracle queries retrieve relevant entities + their relationships
| Pattern | Implementation | Purpose |
|---|---|---|
| System Prompts | Role-based instructions for Gemini | Set mythology expert persona |
| Few-Shot Context | Entity examples in prompts | Guide output structure |
| Chain-of-Thought | Multi-phase generation | Build complexity progressively |
| Output Schemas | Pydantic JSON schemas | Ensure parseable responses |
| Context Windowing | Phase-based accumulation | Manage token limits |
MythForge addresses genuine needs across multiple creative and educational domains:
- Indie Game Studios: Generate complete lore systems for RPGs, MMOs, and adventure games in minutes instead of months
- Procedural Content: Create unique mythology for each playthrough in roguelikes and procedural games
- World Consistency: Ensure all game lore is internally consistent with relationship tracking
- Fantasy Worldbuilding: Instant foundation for novel series, short stories, and screenplays
- Writer's Block Solution: Generate seed mythologies to spark creative inspiration
- Consistency Checking: Query the Oracle to verify lore details while writing
- Campaign Creation: Generate pantheons, creatures, and prophecies for D&D, Pathfinder campaigns
- Session Prep: Create rich lore handouts with audio narration for immersive sessions
- Custom Settings: Build unique campaign settings with interconnected history
- Mythology Studies: Generate comparative mythology examples for classroom discussion
- Creative Writing Classes: Teaching tool for worldbuilding techniques
- Language Learning: Constructed languages demonstrate linguistic concepts
- Film/TV Writers' Rooms: Rapid mythology prototyping for fantasy productions
- Podcast Creators: Generate lore for fiction podcasts with audio narration ready
- Content Creators: Unique mythology content for YouTube, TikTok worldbuilding channels
- MCP Server: Any AI assistant can generate mythologies via tool calls
- Creative AI Pipelines: Chain mythology generation with image/music generation
- Interactive Storytelling: Power AI dungeon masters and narrative games
| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY |
Yes | Google Gemini API key |
ELEVENLABS_API_KEY |
No | ElevenLabs TTS API key |
DEBUG |
No | Enable debug logging |
APP_PORT |
No | Server port (default: 7860) |
| Parameter | Default | Description |
|---|---|---|
| Deities | 5-8 | Number of gods/goddesses |
| Creatures | 6-10 | Mythological beasts |
| Places | 5-8 | Sacred locations |
| Myths | 4-6 | Origin stories and legends |
| Prophecies | 3-5 | Foretold events |
- Image Generation: AI-generated artwork for deities and creatures
- Music Composition: Procedural hymns and ceremonial music
- Interactive Fiction: Choose-your-own-adventure myth exploration
- Mythology Fusion: Combine multiple mythologies into hybrid worlds
- Persistent Storage: Database backend for mythology archives
- Collaboration: Multi-user mythology building
- Export Formats: PDF compendiums, ePub books, wiki exports
- Version History: Track mythology evolution over time
- API Access: RESTful API for third-party integrations
- Game Engine Plugins: Unity/Unreal mythology import
- Tabletop RPG Export: D&D/Pathfinder stat blocks
- World Anvil Integration: Export to worldbuilding platforms
- Multi-mythology Queries: Cross-reference multiple mythologies
- Mythology Comparison: Analyze similarities between generated worlds
- Lore Consistency Checker: Validate internal mythology logic
- Expansion Suggestions: AI-recommended lore additions
- Google Gemini - Powering the mythology generation engine
- LlamaIndex - RAG framework for semantic search and knowledge graphs
- Gradio - Beautiful UI framework for the immersive interface
- ElevenLabs - Dramatic voice narration
- Blaxel - MCP Server deployment platform
- Hugging Face - Spaces hosting
This project is licensed under the MIT License.
✧ May your mythologies echo through eternity ✧
