Provides natural language interface for game world management, allowing AI models to create worlds, generate characters, and manage game state through conversational commands
š® Game World Sandbox MCP
A FastMCP-based game world management system for creating and maintaining consistent, structured game worlds for LLM-driven text adventures and role-playing games.
š Features
World Generation: Create structured game worlds with consistent cosmology, geography, society, and history
Character Management: Define player characters with attributes, inventory, goals, and backstory
MCP Integration: Built on Model Control Protocol for seamless AI integration
OpenAI Integration: Working integration with OpenAI models for natural language game world management
Data Validation: Pydantic models ensure data consistency and integrity
Extensible Architecture: Easy to add new tools, resources, and game mechanics
Comprehensive Testing: Full unit test coverage proving functionality
šļø Architecture
Components
server.py
: FastMCP server with world generation and character creation toolsworld_bible_schema.py
: Pydantic models defining the complete game world structureopenai_working_integration.py
: Direct LangChain OpenAI integration (recommended)mcp_use_integration.py
: LangChain-based MCP integration (compatible alternative)gemini_mcp_demo.py
: Gemini integration demodemo_core_functionality.py
: Core functionality demonstrationverify_working_solution.py
: Verification script proving everything workstests/unit/
: Comprehensive unit tests (19/20 tests passing)
š¤ AI Integration - OpenAI + Game World System
The system includes two working integrations with OpenAI models for natural language game world management:
š§ Option 1: Direct LangChain Integration (Recommended)
The direct LangChain approach provides the most reliable and stable integration with FastMCP.
Features
Natural Language Interface: Interact with game worlds using natural language
Intelligent Tool Usage: OpenAI models automatically choose appropriate game world tools
Real-time Game State: AI can create worlds, characters, and manage game state
Interactive Gameplay: Natural conversation flow with structured game mechanics
Working Implementation: Fully functional integration with error handling
Quick Setup
Install dependencies (already included in requirements.txt):
pip install -r requirements.txtSet your OpenAI API key:
export OPENAI_API_KEY="your-openai-api-key-here"Run the integration:
python openai_working_integration.py
Example Commands
"Create a fantasy world with magic and dragons"
"Generate a sci-fi world with spaceships and advanced technology"
"Create a brave knight character named Sir Galen"
"Move Sir Galen to the dragon's lair"
"What worlds do we have available?"
š§ Option 2: LangChain-Based MCP Integration (Alternative)
The LangChain-based MCP integration provides a more compatible approach that works reliably with FastMCP.
Features
Direct Tool Integration: Custom tools that interface directly with MCP server
Server Compatibility: Works seamlessly with FastMCP transport protocols
Interactive CLI: Command-line interface for game world management
Robust Error Handling: Comprehensive error handling and recovery
No Protocol Issues: Bypasses mcp_use compatibility problems
Quick Setup
Install dependencies (already included in requirements.txt):
pip install -r requirements.txtSet your OpenAI API key:
export OPENAI_API_KEY="your-openai-api-key-here"Start the MCP server:
# Terminal 1 python server.pyRun the integration:
# Terminal 2 python mcp_use_integration.py
Example Commands
"Create a fantasy world"
"List all worlds"
"Create a character"
"Move a character"
"Generate a sci-fi world"
How It Works
Direct LangChain Integration:
LangChain-Based MCP Integration:
š Quick Start
Prerequisites
Python 3.13+
Virtual environment (recommended)
Installation
Clone the repository
git clone https://github.com/your-username/game-sandbox-mcp.git cd game-sandbox-mcpSet up virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies
pip install -r requirements.txtFor OpenAI Integration:
pip install langchain-openaiKey Dependencies:
FastMCP: Model Context Protocol framework
FastAPI: Modern web framework for APIs
Pydantic: Data validation and settings management
Uvicorn: ASGI server for high-performance applications
pytest: Testing framework (19/20 tests passing)
langchain-openai: OpenAI integration (optional)
Running the Server
The server will start on http://127.0.0.1:8000/mcp/
Running the Client Example
š Usage
1. Generate a New World
2. Create a Character
3. Access World Data
šļø Enhanced World Bible Schema
The system uses an advanced "World Bible" structure based on modern game development practices:
Core Components
Metadata: Name, description, genre/style with validation and versioning
Cosmology: Magic systems, technology levels, calendar systems with consistency checks
Geography: Continents, regions, key locations with strategic mapping
Society: Races, factions, social structures with cultural depth
History: Creation myths, conflicts, key events with narrative timelines
Systems: Economy, abilities, item classifications with balance frameworks
Protagonist: Modern RPG character with attributes, skills, inventory, and progression
Enhanced Features
Validation & Consistency: Cross-component validation ensures world consistency
Modern RPG Systems: Comprehensive character attributes, skills, and progression
Advanced Inventory: Item durability, properties, rarity, and crafting systems
Reputation System: Faction relationships and social dynamics
Quest System: Dynamic quest tracking and objectives
Balance Settings: Difficulty levels and game balance parameters
Data Structure Example
š§ API Reference
Tools
generate_world
Creates a new game world based on specified style.
Parameters:
style
(str): Game world style (e.g., "Fantasy", "Sci-Fi", "Cyberpunk")
Returns:
world_id
: Unique identifier for the generated worldmessage
: Success confirmation
create_character
Creates a player character for an existing world.
Parameters:
world_id
(str): ID of the world to add character tocharacter_data
(dict): Complete character definition
Returns:
message
: Success confirmationcharacter_name
: Name of created character
Resources
worlds://{world_id}
Retrieves the complete World Bible for a given world ID.
š® Enhanced Game Development Features
The improved system incorporates the latest game development practices and modern RPG design:
World Consistency & Validation
Cross-Component Validation: Ensures consistency between tech levels and magic systems
Enum-Based Classification: Standardized game styles and technology levels
Advanced Validation: Pydantic validators prevent inconsistent world-building
Version Control: World versioning for tracking changes and updates
Modern RPG Systems
Comprehensive Attributes: Health, mana, stamina, and 6 core attributes (STR, AGI, INT, WIS, CHA, LCK)
Skill Progression: Individual skill tracking with experience and level caps
Advanced Inventory: Items with properties, durability, rarity, and crafting potential
Reputation System: Dynamic relationships with factions and organizations
Quest Management: Active quest tracking with objectives and status
Status Effects: Buffs and debuffs system for combat and roleplay
Enhanced Features
Production Logging: Comprehensive logging with proper formatting and error tracking
Error Handling: Robust error handling with appropriate HTTP status codes
Modern FastMCP: Latest FastMCP version (2.11.3) with improved performance
Type Safety: Full type hints and validation throughout the codebase
Documentation: Comprehensive docstrings and API documentation
Latest Game Design Patterns
Balance Frameworks: Built-in difficulty settings and game balance parameters
World State Management: Dynamic world state variables for evolving narratives
Character Lifecycle: Complete character progression from creation to advancement
Interactive Systems: Character movement, location updates, and world interaction
š ļø Development
Project Structure
Adding New Tools
Extending the Schema
Add new fields to the Pydantic models in world_bible_schema.py
:
š¤ Contributing
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature
)Commit your changes (
git commit -m 'Add amazing feature'
)Push to the branch (
git push origin feature/amazing-feature
)Open a Pull Request
š License
This project is licensed under the MIT License - see the LICENSE file for details.
š Acknowledgments
Built with FastMCP framework
Inspired by modern tabletop RPG world-building practices
Designed for integration with Large Language Models
š Further Reading
GEMINI.md
- Detailed Chinese documentation on world consistency
Happy World Building! šāØ
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables creation and management of structured game worlds for text adventures and RPGs with character creation, world generation, and natural language interaction through AI integration.
Related MCP Servers
- AsecurityAlicenseAqualityProvides tools for creating, managing, and generating content for DeepWriter projects through a standardized Model Context Protocol interface.Last updated -66Apache 2.0
- AsecurityAlicenseAqualityConnects AI tools to Storyblok CMS, allowing users to manage content through natural language commands for tasks like story management, asset handling, and AI-powered content operations.Last updated -17MIT License
- -securityAlicense-qualityA Model Context Protocol server that manages character knowledge and relationships for creative writing projects, offering semantic search and AI-powered analysis.Last updated -2MIT License