Skip to main content
Glama

LeviHead

LeviHead runs the real Minecraft Bedrock 1.26.66.1 headless on a hidden virtual display and exposes it to an AI agent over MCP. It is not a clone, not a web remake, and not a substitute engine. It launches the real APK / libminecraftpe.so through LeviLauncher.

  • 1920×1080 virtual display; the game runs at its native 58–63 fps.

  • 60 fps raw preview in the Android monitor (no per-frame JPEG).

  • App-side screenshots that work while the game is in the background.

  • Exact-schema MCP tools, a skill file, an agent file, and a terminal TUI.

  • Real .levipack build/install + crash-retry workflow.

  • Root-aware: live logs, doctor, repair.

Install

git clone https://github.com/HakaI963/levihead.git ~/levihead
cd ~/levihead
./install.sh

or:

curl -fsSL https://raw.githubusercontent.com/HakaI963/levihead/main/install.sh | bash

The installer:

  1. installs the levihead CLI wrapper (~/.local/bin/levihead),

  2. installs the levihead skill and agent context,

  3. registers the levihead MCP server with OpenCode,

  4. on a rooted Android chroot, installs the display APK and the LeviControl mod (and writes mods_config.json with only LeviControl enabled).

APK

dist/LeviHead-v1.1.apk is the Android display/input component. Install it on the phone:

adb install -r dist/LeviHead-v1.1.apk
# or, on the device:
pm install -r /data/local/tmp/LeviHead-v1.1.apk

The APK is debug-signed for personal use. The Python/MCP app is the agent surface; the APK owns the hidden display and fast input path.

Related MCP server: minecraft-mcp-server

MCP setup

Generic client (~/.levihead/mcp.json is generated):

{
  "mcpServers": {
    "levihead": {
      "command": "python3",
      "args": ["/home/you/levihead/levihead/mcp_server.py"]
    }
  }
}

OpenCode (~/.config/opencode/opencode.json):

{
  "mcp": {
    "servers": {
      "levihead": {
        "type": "local",
        "command": ["python3", "/home/you/levihead/levihead/mcp_server.py"],
        "enabled": true
      }
    }
  }
}

The MCP server is stdio JSON-RPC 2.0. It also exposes resources levihead://commands and levihead://status.

What the agent can do

Start with levihead_status / levihead_doctor, then:

levihead_world_list
levihead_world_enter {"name":"My World","retries":3}
levihead_screenshot {"path":"/tmp/shot.jpg"}
levihead_give {"item":"minecraft:diamond","count":1}
levihead_tp {"x":0,"y":64,"z":0}
levihead_gamemode {"mode":"creative"}
levihead_time {"value":"day"}
levihead_weather {"value":"clear"}
levihead_attack
levihead_jump
levihead_look {"dx":120}
levihead_logs {"lines":80,"grep":"error"}
levihead_root {"command":"id"}
levihead_fix

Full exact schemas are in the MCP tools/list response, SKILL.md, and AGENTS.md. Do not use input keyevent, input tap, OCR, or image-coordinate tapping for gameplay.

World entry

minecraft://connect/?localWorld=<name> is handled by Minecraft's own LocalWorldConnectArgumentHandler. The reliable path is cold-start: force-stop, launch the URI, and wait until the MinecraftActivity is top and the HUD ticks. levihead_world_enter does that and retries on crash. Do not start MinecraftActivity a second time — that triggers BootstrapConfig::initialize() should only be called once.

Performance

The game options are set to render distance 8 and fast graphics on each world load, to keep the 1080p view near 60 fps. The monitor receives raw 1920×1080 frames over a local socket; it is not JPEG/screencap. Screenshots come from the app frame pipeline, not Android screencap.

Touch latency

The root engine keeps a shell-UID TouchInjector process alive and feeds it MotionEvents over a pipe. The monitor sends touches through a background queue to the engine's local control socket; the UI thread never spawns input or blocks on a socket.

Mod workflow (.levipack)

levihead_mod_pack {"source":"/path/src","name":"MyMod","entry":"libmymod.so"}
levihead_mod_install {"path":"...levipack","force":true,"enable":false}
levihead_world_enter {"name":"My World","retries":3}

If the game crashes or the retry loop fails:

levihead_logs {"lines":120,"grep":"FATAL|crash|LeviControl"}
levihead_mods_enforce {"only":["LeviControl"],"quarantine":true}
levihead_world_enter {"name":"My World","retries":3}

Only LeviControl is auto-enabled. The installer and the app's config sync never turn every installed pack on.

Architecture

AI agent / MCP client
        │ stdio MCP (30+ tools)
        ▼
levihead/mcp_server.py ── LauncherShell ── Android root bridge
        │                                  (sudo chroot /proc/1/root)
        ├── TUI (curses + live frame)
        ├── root display engine 127.0.0.1:27402
        │      └── VirtualDisplay 1920x1080 + raw levihead.video
        └── native LeviControl mod 127.0.0.1:27404
               └── exact RVA hooks in libminecraftpe 1.26.66.1

Key paths:

  • levihead/mcp_server.py — MCP server (tools/resources).

  • levihead/launcher.py — device, worlds, mods, fix, world retry.

  • levihead/tui.py — non-blocking curses live view.

  • android/src/... — root display engine, monitor, shell-UID touch injector.

  • controlmod/ — LeviControl exact-RVA native mod source + .levipack.

  • dist/LeviHead-v1.1.apk — signed Android display APK.

  • SKILL.md, AGENTS.md, agents/levihead.md — agent instructions.

Verified

  • Real game: 1920×1080, 58–63 fps (options: render distance 8, fast graphics).

  • Monitor: raw 1920×1080 stream, observed 60 fps.

  • World enter: cold-start URI, top activity MinecraftActivity, HUD ticks.

  • Touch: shell-UID MotionEvent injection; a swipe changes the game frame.

  • Screenshot: app-frame capture with no screencap.

  • MCP: initialize, tools/list, status, doctor, logs, root, frame.

  • Mods: only LeviControl enabled; others quarantined.

Limitations

  • Native LocalPlayer capture (lp) is still being mapped, so levihead_move returns an explicit error and native inventory open depends on the HUD/LocalPlayer state. attack, jump, look, give, tp, gamemode, time, weather are verified.

  • place/pick are experimental.

  • The APK is debug-signed; use your own key for distribution.

  • The root bridge assumes KernelSU/root, /proc/1/root, sudo -n, and the LeviLauncher package paths. Adjust levihead/device.py for other setups.

  • MCP is local stdio; do not expose it to a network.

Security

This is a root-level controller. It can run device commands, install APKs, and modify Minecraft worlds. Run it only on a device you own, keep the MCP server local, and review agent actions.

License

MIT. See LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers