An AI-powered Minecraft player that uses LLMs (GPT-4, Claude, Ollama) to autonomously play the game.
- Autonomous Gameplay: Survives, explores, gathers resources, crafts tools, and builds shelters
- Multiple LLM Providers: OpenAI, Anthropic Claude, or local Ollama models
- Skill System: Navigation, mining, crafting, combat, building, and inventory management
- Memory & Goals: Tracks past actions, learns from failures, and manages objectives
- Chat Interaction: Responds to player commands via in-game chat
- Node.js 18+ (LTS recommended)
- Minecraft Java Edition 1.20.4
- API key for OpenAI, Anthropic, or local Ollama installation
-
Install dependencies:
npm install
-
Configure environment:
cp .env.example .env # Edit .env with your API keys and server details -
Start a Minecraft server (singleplayer with LAN, or dedicated server)
-
Run the bot:
npm start
| Variable | Description | Default |
|---|---|---|
LLM_PROVIDER |
LLM provider (openai, anthropic, ollama) | openai |
OPENAI_API_KEY |
OpenAI API key | - |
ANTHROPIC_API_KEY |
Anthropic API key | - |
OLLAMA_HOST |
Ollama server URL | http://localhost:11434 |
OLLAMA_MODEL |
Ollama model name | llama3.2 |
MC_HOST |
Minecraft server host | localhost |
MC_PORT |
Minecraft server port | 25565 |
MC_USERNAME |
Bot username | AIPlayer |
MC_VERSION |
Minecraft version | 1.20.4 |
AUTONOMOUS_MODE |
Enable autonomous play | true |
DEBUG |
Enable debug logging | false |
npm start -- [options]
Options:
--profile, -p Bot profile (default, explorer)
--host, -h Minecraft server host
--port Minecraft server port
--username, -u Bot username
--provider LLM provider
--debug, -d Enable debug mode
--no-autonomous Disable autonomous mode
--help Show helpCreate custom profiles in src/config/profiles/:
{
"name": "MyBot",
"personality": "A brave adventurer...",
"goals": ["Explore caves", "Find diamonds"],
"survivalPriority": 0.7,
"explorationDrive": 0.9,
"aggressiveness": 0.5
}goto(x, y, z)- Navigate to coordinatesgotoPlayer(username)- Go to a playerfollow(username)- Follow a playerstop()- Stop movementwander(radius)- Wander randomlyflee(distance)- Run away from danger
mine(x, y, z)- Mine specific blockcollect(blockName, count)- Collect block typefindAndMine(oreName, maxCount)- Find and mine oresdigDown(depth)- Dig down safelydigArea(width, height, depth)- Clear an area
craft(itemName, count)- Craft with 2x2 gridcraftTable(itemName, count)- Craft with crafting tablesmelt(itemName, count)- Smelt in furnacelistCraftable()- List craftable items
attack(entityName)- Attack an entityhunt(animalType, count)- Hunt animalsdefend(duration)- Defend against mobsequipWeapon()- Equip best weaponequipArmor()- Equip best armor
place(blockName, x, y, z)- Place a blockbuildWall(blockName, width, height, direction)- Build a wallbuildFloor(blockName, width, depth)- Build a floorbuildShelter(blockName)- Build a simple shelterplaceTorch(x, y, z)- Place a torch
inventory()- List inventoryequip(itemName, slot)- Equip an itemdrop(itemName, count)- Drop itemsstoreChest(itemName, count)- Store in chesttakeChest(itemName, count)- Take from chesteat(foodName)- Eat foodtoss(itemName, playerName, count)- Toss to player
Talk to the bot in-game chat:
"come here" - Bot will navigate to you
"follow me" - Bot will follow you
"stop" - Stop current action
"mine some stone" - Mine nearby stone
"craft a pickaxe" - Craft if materials available
"build a shelter" - Build a basic shelter
src/
├── index.ts # Entry point
├── config/ # Configuration and profiles
├── llm/ # LLM provider abstraction
├── bot/ # Mineflayer bot controller
├── agent/ # AI agent core
│ ├── memory.ts # State and history tracking
│ ├── goals.ts # Goal management
│ ├── prompter.ts # LLM prompt construction
│ └── self-loop.ts # Autonomous behavior loop
└── skills/ # Action implementations
MIT