A Python-based learning MOO (Multi-User Dungeon, Object Oriented) in the spirit of LambdaMOO, designed for family collaboration and learning.
- Multi-player Support: Multiple users can connect simultaneously
- World Navigation: Players can move between rooms and explore the virtual world
- Object Creation: Players can create and manipulate objects in the world
- Communication: Players can communicate via chat, whispers, and emotes
- AI Players: Integration with OpenAI API for AI-driven players
- World Persistence: World state is maintained between sessions
- Multiple Interfaces: Web interface, telnet server, and interactive shell
- Cloud Storage: Support for persistent storage on Heroku via AWS S3
- Clone the repository:
git clone <repository-url>
cd monkamoo- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
cp .env.example .env
# Edit .env and set your OPENAI_API_KEY- Start the web server:
python app.py- Or start the telnet server:
./moo -s- Or use the interactive shell:
./moo- Set up Heroku environment variables:
heroku config:set OPENAI_API_KEY=your_openai_api_key
heroku config:set STORAGE_TYPE=heroku
heroku config:set CLOUD_STORAGE_BUCKET=your-s3-bucket-name
heroku config:set AWS_ACCESS_KEY_ID=your-aws-access-key
heroku config:set AWS_SECRET_ACCESS_KEY=your-aws-secret-key
heroku config:set AWS_REGION=us-east-1- Deploy to Heroku:
git push heroku mainMonkaMOO supports multiple storage backends for world state and AI player history:
- Uses local files (
world.jsonandbots/*.json) - Suitable for development and testing
- No additional configuration required
- Uses AWS S3 for persistent storage
- Required for Heroku deployment
- Configure with environment variables:
STORAGE_TYPE=herokuCLOUD_STORAGE_BUCKET=your-bucket-nameAWS_ACCESS_KEY_ID=your-keyAWS_SECRET_ACCESS_KEY=your-secretAWS_REGION=us-east-1
To migrate your local data to S3:
- Set up your .env file with AWS credentials and S3 bucket
- Run the migration script:
python migrate_to_cloud.py
- Deploy to Heroku with the same environment variables
The system automatically falls back to local storage if cloud storage is unavailable, ensuring the application continues to work even if S3 is temporarily unavailable.
- OPENAI_API_KEY: Required for AI player functionality (works with OpenAI and OpenRouter)
- OPENAI_BASE_URL: Base URL for AI API (e.g., "https://openrouter.ai/api/v1" for OpenRouter)
- AI_MODEL: AI model to use (e.g., "openai/gpt-4o-mini", "anthropic/claude-3.5-sonnet")
- SECRET_KEY: Web session security (default: 'JGS123#')
- PORT: Web server port (default: 5432)
- TELNET_PORT: Telnet server port (default: 8888)
- STORAGE_TYPE: Storage backend ('local' or 'heroku')
- CLOUD_STORAGE_BUCKET: S3 bucket name for cloud storage
- AWS_ACCESS_KEY_ID: AWS access key for S3
- AWS_SECRET_ACCESS_KEY: AWS secret key for S3
- AWS_REGION: AWS region (default: us-east-1)
look- Look around the current roomgo north/south/east/west- Move in a directionsay hello- Say something to everyone in the roomwhisper player message- Send a private messageemote smiles- Perform an actiontake object- Pick up an objectdrop object- Drop an objectgive object to player- Give an object to another player
create flower as Object- Create a new objectdescribe flower as "A beautiful red flower"- Set object descriptionname flower as rose- Set object namedig north as "A dark tunnel"- Create a new roombot Poe- Create an AI playersave- Save the world stateload- Reload the world state
You can add AI players to the MOO and give them roles or personalities.
Configure your OpenAI API key:
cp .env.example .env
Edit .env and set the OPENAI_API_KEY value.
In the MOO, type bot [name] to create an AI player. Then say something to it to give it an initial prompt.
MonkaMOO supports OpenRouter, which provides access to hundreds of AI models through a single API. This allows you to use different models like Claude, Gemini, and others.
-
Get an OpenRouter API key from openrouter.ai
-
Configure environment variables:
# For local development export OPENAI_API_KEY=your_openrouter_api_key export OPENAI_BASE_URL=https://openrouter.ai/api/v1 export AI_MODEL=anthropic/claude-3.5-sonnet # or any other model # For Heroku deployment heroku config:set OPENAI_API_KEY=your_openrouter_api_key heroku config:set OPENAI_BASE_URL=https://openrouter.ai/api/v1 heroku config:set AI_MODEL=anthropic/claude-3.5-sonnet
Models with Tool Support (Recommended):
openai/gpt-4o-mini- Fast and cost-effectiveanthropic/claude-3.5-sonnet- Good reasoning capabilitiesopenai/gpt-4o- More capable but more expensive
Models without Tool Support (Text-only):
google/gemini-pro- Google's latest modelmeta-llama/llama-3.1-8b-instruct- Open source option- Most free models on OpenRouter
Note: Models without tool support will still work but won't be able to perform actions like moving, creating objects, etc. They'll only be able to chat.
- If
OPENAI_BASE_URLis set → Use OpenRouter/custom endpoint - If
AI_MODELis set → Use specified model - Fallback to OpenAI with default model
The system automatically detects if your chosen model supports tools (function calling). If a model doesn't support tools, it will fall back to text-only mode. You'll see a warning message in the logs when this happens.
For the best experience, use models that support tools so AI players can perform actions in the world.
AI players have a set of functions available to them so they can take actions in the MOO, like moving around, creating rooms and objects, and describing things. But they generally need to be told to take these actions.
Some things we've found when experimenting with AI players:
- A prompt like "You are the character Data from Star Trek." works really well.
- If multiple bots get in the same room together, they'll happily keep talking to each other.
- They sometimes get carried away with the narrative and will speak or emote for other players.
The application uses a comprehensive logging system with the following components:
- Web Server (
monkamoo.web): HTTP requests, WebSocket connections, user sessions - Telnet Server (
monkamoo.server): Client connections, command processing - Shell Interface (
monkamoo.shell): Interactive commands, user input - World Engine (
monkamoo.world): World loading/saving, object management - Player System (
monkamoo.player): Player actions, movements, interactions - AI Players (
monkamoo.aiplayer): OpenAI API calls, AI responses - Communication (
monkamoo.broker): Message publishing, subscriptions - Interpreter (
monkamoo.interpreter): Code execution, errors - Storage (
monkamoo.storage): File and cloud storage operations
2025-07-13 21:46:52 - monkamoo.web - INFO - Server starting on port 5432...
2025-07-13 21:46:52 - monkamoo.world - INFO - Loading world using storage abstraction
2025-07-13 21:46:52 - monkamoo.storage.factory - INFO - Initializing storage with type: local
2025-07-13 21:46:52 - monkamoo.world - INFO - World loaded successfully: 21 objects
2025-07-13 21:46:52 - monkamoo.web - INFO - WebSocket connection established for player: jim
2025-07-13 21:46:52 - monkamoo.player - INFO - Player jim creating object: flower as Object
2025-07-13 21:46:52 - monkamoo.world - INFO - Player jim successfully created object: flower