🎓 Educational Project: This is a teaching example of AI system prompts and tool use, built as part of the AI 101 course. Perfect for learning how LLMs can interact with real systems!
Alfred is a small Go service that watches a Minecraft server log, detects when players ask for help, and routes those prompts to an LLM hosted on Demeterics. Approved replies are sent back into the running server via screen, so players see a friendly counselor-style response directly in chat.
This project demonstrates three key AI concepts:
- System Prompts: How to craft detailed instructions that shape an AI's personality, tone, and behavior (see the 96-line prompt in
config.go!) - Tool Use (Function Calling): How LLMs can call real-world functions like
/tp(teleport),/time set, and/weathercommands - AI Safety with Drama: When players use bad language, Alfred responds with a calm message... AND summons a safe lightning bolt nearby! ⚡ It's moderation that kids actually remember.
Perfect for understanding how ChatGPT plugins, Claude tools, or GitHub Copilot actually work under the hood!
Player: "shut up you idiot"
[💥 LIGHTNING BOLT strikes 3 blocks ahead of player 💥]
Alfred: Let's keep the chat kind. Adventures are better when everyone feels welcome.
Why this works:
- Visual + verbal feedback (kids see AND hear consequences)
- Logged for parent/educator review in
chat_history.log - Harmless but dramatic (no damage, just theatrics!)
- Makes AI safety education memorable and fun
- Tails the Minecraft log in real time and parses async chat events.
- Heuristics decide when to answer (name mentions, trigger word, alert keywords, or any question/engage terms).
- Uses Groq Tool Use to drive
/tp,/time, and/weathercommands whenever the LLM decides it’s appropriate (teleport to players, coordinates, or spawn). - Sends prompts to the configured Demeterics chat-completions model and posts the answer in-game.
- Fun Easter eggs for morale boosts, including a golem rescue when someone shouts “Alfred to the rescue” or “Alfred, help me!”.
- Prevents spam with a configurable reply cooldown and trigger words.
- Records every answered question in
chat_history.log(or a custom file) for audits.
- Go 1.22+
- Access to the Minecraft server log and
screensession running the server. - Demeterics API key with access to the chosen model.
rsyncfor the deployment step in the Makefile.
- Copy
.env.exampleto.envand fill in the secrets/paths. OnlyDEMETERICS_API_KEYis mandatory; everything else falls back to sane defaults. - Build locally with
make buildorgo build ./.... - Run locally with
go run .or deploy withmake install(see below).
Environment variables allow the agent to be customized without code edits:
| Variable | Default | Description |
|---|---|---|
DEMETERICS_API_KEY |
– | Required API token for Demeterics. |
DEMETERICS_MODEL |
meta-llama/llama-4-scout-17b-16e-instruct |
Override the LLM model ID. |
MCCHATBOT_LOG_PATH |
/usr/local/games/minecraft_server/MyServer/logs/latest.log |
Path to the Minecraft chat log to watch. |
MCCHATBOT_SCREEN_NAME |
mc-MyServer |
Name of the screen session controlling the server. |
MCCHATBOT_SPAWN_POINT |
0 80 0 |
Coordinates Alfred uses for spawn teleports (x y z or comma-delimited). |
MCCHATBOT_SPAWN_DIMENSION |
minecraft:overworld |
Dimension for the spawn point teleport. |
MCCHATBOT_SYSTEM_PROMPT |
Friendly counselor script | Tune the persona/instructions for Alfred. |
MCCHATBOT_NAME |
Alfred |
Name Alfred listens for when deciding to answer and prefixes responses with. |
MCCHATBOT_TRIGGER |
!bot |
Prefix that always causes a response (!bot how do I fly). |
MCCHATBOT_REPLY_COOLDOWN |
30s |
Minimum time between replies to avoid flooding chat. |
MCCHATBOT_ENGAGE_WORDS |
help,how,where,why,what,can,anyone,tip,idea,question |
Lowercase comma-separated engagement keywords. |
MCCHATBOT_ALERT_WORDS |
stupid,idiot,hate,kill,dumb,shut up,noob,trash,bully |
Lowercase comma-separated alert words that trigger a kindness reminder. |
MCCHATBOT_ENABLE_NAME_TRIGGER |
true |
Respond when someone mentions the bot’s name. |
MCCHATBOT_ENABLE_PREFIX_TRIGGER |
true |
Respond to the configured trigger prefix (e.g., !bot). |
MCCHATBOT_ENABLE_QUESTION_TRIGGER |
true |
Respond to questions (?) or configured engage words. |
MCCHATBOT_ENABLE_ALERT_TRIGGER |
true |
Send kindness reminders when alert words show up. |
MCCHATBOT_ENABLE_TOOL_USE |
true |
Allow Groq Tool Use across teleport/time/weather helpers. |
MCCHATBOT_ENABLE_WORLD_TOOL |
true |
Permit Alfred to call the /time and /weather helpers (via Tool Use) when campers politely ask for daytime, rain, etc. |
MCCHATBOT_ENABLE_EASTER_EGGS |
true |
Toggle the fun Easter-egg commands (floating cat, firework, heart particles, etc.). |
MCCHATBOT_RESPONSE_LOG |
chat_history.log |
File (relative or absolute) where JSONL interaction logs are written. Set empty to disable logging. |
Every successful response appends a JSON line to MCCHATBOT_RESPONSE_LOG. Example entry:
{"time":"2024-06-01T12:34:56Z","player":"Camper123","question":"Alfred how do I build a redstone door?","response":"Place sticky pistons facing each other, add redstone and a lever. Simple and fun!"}Keep or rotate this file as needed for moderation reviews.
make buildThis runs go vet ./... and go build ./....
make installPerforms the following:
- Runs the
buildtarget. - Stops
mcchatbot.service(ignoring failures if it was not running). rsyncs the repo (including.env) into/usr/local/games/mcchatbot(override withTARGET_DIR=...).chown -R minecraft:minecrafton the target directory.- Restarts
mcchatbot.service.
Requires sudo access because it manipulates files in
/usr/local/gamesand controls the systemd service.
mcchatbot.service expects the binary and .env inside /usr/local/games/mcchatbot. Enable/start it on boot:
sudo cp mcchatbot.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now mcchatbot.serviceFor troubleshooting you can run the bot in the foreground:
source .env
go run .Press Ctrl+C to exit; the service will continue tailing the log and posting replies through the configured screen session.
Player in Minecraft Alfred (Go Service) Demeterics LLM
───────────────── ─────────────────── ───────────────
"Alfred how do I Watches log file
make a redstone door?" ──────> Parses chat event
Checks triggers:
✓ Name mentioned!
Builds request:
- System prompt (personality)
- User message
- Available tools ──────> "You are Alfred..."
+ Tool definitions
Thinks... 🤔
<────── "Place sticky pistons..."
Sends to Minecraft:
screen -X stuff "say ..."
"[Alfred] Place sticky <────── Logs to chat_history.log
pistons facing each
other..."
Easter Egg Example (when tools are involved):
Player: "Alfred can you make it daytime?"
Alfred: Calls set_time("day") tool → Minecraft runs `/time set day`
Response: "Sure thing! ☀️ Daytime activated for building adventures!"
Quick Tips for Learners:
- Read
config.gofirst to see the massive system prompt—it's the "instruction manual" for Alfred's personality - Check
llm_tools.goto see how tools are defined (JSON schema) and executed (actual Minecraft commands) - Run
make showto see the conversation history and understand what Alfred is actually doing
For Contributors:
- Format with
gofmt -w *.gobefore committing - Update
.env.examplewhen adding new configuration knobs - Interaction logging happens in the working directory; ensure the service user has write permissions
This project pairs with AI 101 to teach:
- How system prompts work (the "personality" of an AI)
- How function calling/tools let AIs interact with the real world
- How to build safe, moderated AI experiences for kids
Want to experiment? Try:
- Modify the system prompt in
config.goto change Alfred's personality - Add a new tool in
llm_tools.go(maybe a joke command or compliment generator?) - Adjust trigger words to make Alfred more/less chatty
"Alfred isn't responding!"
- Check if your trigger is working: type
Alfred helloor!bot test - Look at logs:
journalctl -u mcchatbot.service -f(production) or just watch terminal output - Verify cooldown hasn't kicked in (default 30s between replies)
"I want to test locally without a real Minecraft server"
- Create a fake log file:
touch test.log - Set
MCCHATBOT_LOG_PATH=./test.login.env - Manually append chat lines:
echo '[12:34:56] [Async Chat Thread - #1/INFO]: <TestPlayer> Alfred help' >> test.log - Alfred will detect and respond (though screen commands will fail - that's OK for learning!)
"What's this 'screen' thing?"
screenis a Linux tool that keeps programs running in the background- Minecraft servers often run in screen so you can attach/detach from them
- Alfred uses
screen -X stuffto send commands to the running server - Think of it like "remote control" for the server console
"How do I see what Alfred is actually sending to the AI?"
- Check the logs - every prompt is logged before sending
- Use
make showto seechat_history.logwith full conversation records - Add more
log.Printf()statements in the code to see everything!
MIT-style license (add one if needed).