Skip to main content
Glama
HMCL MCP Server

HMCL MCP Server

by vfyjxf

HMCL MCP Server

MCP (Model Context Protocol) server that lets AI agents drive HMCL (Hello Minecraft! Launcher, https://hmcl.huangyuhui.net) programmatically: install Minecraft versions, search/download/import modpacks (Modrinth + CurseForge), and launch/stop the game.

HMCL has no command line interface (no --launch, no --import, no headless mode), so this project injects a small javaagent into a headless HMCL JVM and drives HMCL's core classes directly. Modpack search/download/install all run through HMCL's own addon repositories inside the agent (Modrinth, and CurseForge with HMCL's embedded API key — no user key needed); listing installed versions/modpacks is a local filesystem scan.

Architecture

┌──────────────────────────────┐   stdio (JSON-RPC only)   ┌────────────────────────────────┐
│  MCP client / AI agent       │ ◀────────────────────────▶ │  Node MCP server (this repo)   │
└──────────────────────────────┘                            └───────────────┬────────────────┘
                                                      filesystem scans      │ HTTP JSON API
                                                <workdir>/versions/,        │ 127.0.0.1:<port>
                                                mcpacks/ (search/download)  │ X-HMCL-Agent-Token
                                                                             ▼
                                                              ┌────────────────────────────────┐
                                                              │  Headless HMCL JVM              │
                                                              │  java -javaagent:hmcl-agent.jar │
                                                              │  -Dhmcl.gameDir=<workdir> …      │
                                                              │  -cp HMCL.jar;javafx-*.jar       │
                                                              │  hmcl.agent.AgentMain            │
                                                              └────────────────────────────────┘
  • Node MCP server (src/, TypeScript, stdio transport): registers 13 tools, drives HMCL's own Modrinth/CurseForge modpack repositories for search/download/install, scans <workdir>/versions/ on disk for installed versions and modpacks, and talks to the agent over loopback HTTP.

  • Java agent (agent/, compiled by npm run build:agent): injected into HMCL with -javaagent; initializes HMCL core headlessly (SettingsManager.init() → DownloadProviders.init() → Accounts.init()) and exposes a loopback HTTP JSON API (/status, /versions/install, /modpack/install, /launch, /launch/stop, /shutdown) on 127.0.0.1:<port>. A non-daemon HTTP thread keeps the JVM alive.

  • No launcher GUI: the HMCL window never opens. When you launch the game, the game window itself opens normally (the game is a separate child process).

HMCL-compatible directory layout inside the workdir: versions/<id>/, libraries/, assets/, mcpacks/ (downloaded pack files), hmcl/ (HMCL.jar + hmcl-agent.jar + javafx jars), .hmcl/ (HMCL 3.16+ workspace config).

Related MCP server: Desktop Commander MCP Server

Requirements

  • Node.js 18+ (24 recommended) — MCP SDK 1.30.0, npm install

  • JDK 17+ with javac (21 recommended) — HMCL itself requires Java 17; javac is needed to compile the agent jar

  • Internet access on first run (HMCL jar, javafx jars, Minecraft versions/libraries/assets)

Tools (13)

Tool

Args

Description

check_environment

—

Java path + version, workdir, hmcl dir contents (HMCL.jar / hmcl-agent.jar / javafx jars), agent running status, version/modpack counts

install_hmcl

—

Download latest HMCL jar into <hmclDir>/HMCL.jar if missing, then build the agent jar (node agent/build.mjs, needs javac) and copy hmcl-agent.jar + javafx jars into <hmclDir>/

start_hmcl

—

Start the headless HMCL JVM with the agent (no-op if already running) and return agent /status

stop_hmcl

—

Stop the headless HMCL JVM (agent /shutdown) and confirm it is down

list_versions

—

Scan <workdir>/versions/; a dir counts as a version when it contains <id>/<id>.json → [{id, path, hasJar}]

install_version

mc_version (string)

Install a vanilla Minecraft version through the agent's HMCL download pipeline

search_modpacks

query (string), source (modrinth|curseforge, optional), limit (number, optional)

Search modpacks via HMCL's own repositories (CurseForge uses HMCL's embedded key — no user key needed)

get_modpack

id (string), source (optional)

Project details + latest version for one modpack (id = Modrinth slug or CurseForge numeric id)

download_modpack

id (string), versionId (string, optional), source (optional)

Download the pack file into <workdir>/mcpacks/ (sha1-verified); versionId picks a specific version, defaults to latest

install_modpack

id (string, optional), versionId (string, optional), path (string, optional), name (string, optional), source (optional)

Download (if id given, or path to a local file) then agent-install the pack as an instance under <workdir>/versions/<name>/

list_modpacks

—

Scan <workdir>/versions/*/modpack.json → [{name, path, format, gameVersion?, modLoader?}] (format: mrpack / curseforge / hmcl)

launch_game

version (string), username (string, default Steve), maxMemory (number, MB), javaPath (string), extraArgs (string[])

Launch an instance as an offline account; the game opens as a child process

stop_game

—

Stop the running game process (agent /launch/stop)

All handlers return structured data on success and an error message on failure (MCP isError result) — they never crash the server.

Quick start

npm install          # install dependencies
npm run build        # compile the MCP server → dist/
npm run build:agent  # download javafx jars + compile agent/build/hmcl-agent.jar (javac required)

Register the server in your MCP client:

{
  "mcpServers": {
    "hmcl-mcp": {
      "command": "node",
      "args": ["D:/ProjectDir/AgentFarm/HMCL-MCP/dist/index.js"]
    }
  }
}

Environment variables can be set in the client's env object, in your shell, or via a .env file — see .env.example and docs/setup.md.

Environment variables

Variable

Default

Description

HMCL_MCP_WORKDIR

~/.hmcl-mcp

HMCL working directory (game root + user data): versions/, libraries/, assets/, mcpacks/, .hmcl/

HMCL_MCP_HMCL_DIR

<workdir>/hmcl

Directory holding HMCL.jar, hmcl-agent.jar and the javafx jars

HMCL_MCP_JAVA

java on PATH

Java binary used to launch the headless HMCL JVM

HMCL_MCP_CURSEFORGE_API_KEY

(none)

Optional CurseForge API key override, passed to HMCL as -Dhmcl.curseforge.apikey; without it search/install still work via HMCL's embedded key

HMCL_MCP_AGENT_PORT

28501

Agent HTTP port on 127.0.0.1

HMCL_MCP_AGENT_TOKEN

hmcl-mcp

Shared token, sent as the X-HMCL-Agent-Token header

Typical agent workflows

  1. Modpack: search → install → launch

    search_modpacks(query: "fabulously optimized") → get_modpack(id: "fabulously-optimized") → install_modpack(id: "fabulously-optimized", name: "fabulously-optimized") (downloads and installs in one step, all through HMCL) → launch_game(version: "fabulously-optimized", username: "Steve") — note: launch_game's version is the instance name from install_modpack/list_modpacks, not the Minecraft version number

  2. Vanilla: install a version → launch

    install_version(mc_version: "1.21.4") → launch_game(version: "1.21.4", username: "Steve")

  3. First run / fresh setup

    check_environment (verify java + hmcl dir) → install_hmcl (downloads HMCL.jar, builds the agent jar) → start_hmcl (boots the headless JVM, agent responds on /status)

  4. Cleanup

    stop_game (stop the running game) → stop_hmcl (stop the headless JVM)

Troubleshooting

  • javac not found / java missing: installing a JDK is the user's responsibility — install JDK 17+ (21 recommended) and make sure both java and javac are on PATH (or set HMCL_MCP_JAVA).

  • First run downloads: install_hmcl downloads HMCL.jar (~10 MB) from GitHub releases and npm run build:agent downloads javafx-base/javafx-graphics from Maven Central — both need internet and can take a minute.

  • install_hmcl fails with HTTP 403/429: GitHub API rate limit — download HMCL-<version>.jar manually and place it at <hmclDir>/HMCL.jar (see docs/setup.md), then re-run.

  • CurseForge errors (403): missing/invalid API key — CurseForge is optional; use Modrinth (keyless) for search/install.

  • Headless means no launcher window: only the game window appears, on launch_game.

  • Port conflict: change HMCL_MCP_AGENT_PORT and restart; the agent binds 127.0.0.1 only.

  • Paths containing !: HMCL refuses to run when the working directory or jar path contains ! — use a path without it.

Docs

  • docs/setup.md — manual HMCL install, workdir layout, reusing an existing game directory, security notes

  • docs/research/ — research notes (MCP SDK, HMCL Java API, HMCL CLI/modpack formats, Modrinth/CurseForge APIs)

  • src/types.ts — the shared contract (tools, types, cross-module interfaces)

Available Tools

13 tools
check_environmentcheck_environmentA

Report the current environment: java (path + version), workdir, hmcl dir contents (HMCL.jar / hmcl-agent.jar / javafx jars), whether the headless HMCL agent JVM is running (loopback probe with short timeout), and counts of installed versions and modpacks. Run this first to diagnose setup problems. java is null when no JDK is found.

Inputs: no named parameters.

download_modpackdownload_modpackA

Download a modpack file through HMCL into /mcpacks/ (SHA-1 verified via HMCL's downloader). Pass versionId (a version name from get_modpack) to pick a specific version; defaults to the latest. Returns {id, version, gameVersions, filename, path, size, sha1}.

Inputs: id (required), source, versionId.

get_modpackget_modpackA

Get details of a modpack project (id = Modrinth slug or CurseForge slug) through HMCL: summary + available versions (id = version name, version, gameVersions, loaders) and the latest version.

Inputs: id (required), source.

install_hmclinstall_hmclA

Prepare the HMCL directory: if /HMCL.jar is missing, download the latest HMCL release jar from GitHub (asset ending in .jar); then run node agent/build.mjs (requires javac on PATH) to fetch the javafx jars and compile hmcl-agent.jar; copy hmcl-agent.jar and the javafx jars into . Returns the resulting paths. Safe to re-run.

Inputs: no named parameters.

install_modpackinstall_modpackA

Install a modpack as a game instance under /versions/. Either pass path to a local .mrpack/.zip file, or id (plus optional versionId) to download it first via HMCL; name is the instance name (defaults to the pack name). Requires the HMCL agent — it is started automatically if possible.

Inputs: id, name, path, source, +1 more.

install_versioninstall_versionA

Install a vanilla Minecraft version (e.g. "1.20.4") through the HMCL agent. Downloads the version json, client jar and libraries (via BMCLAPI/mojang mirrors) into /versions// and /libraries/ — this can take a few minutes on first run. Assets are downloaded by HMCL at first launch.

Inputs: version (required).

launch_gamelaunch_gameA

Launch a game instance through the agent as an offline account. version is an instance id (see list_versions / list_modpacks). username defaults to Steve; maxMemory is the max heap in MB; javaPath overrides the Java used for the game; extraArgs are appended after the default JVM args. The game runs as a separate child process — the game window opens normally.

Inputs: version, javaPath, username, extraArgs, +1 more.

list_modpackslist_modpacksA

List installed modpacks by scanning /versions/*/modpack.json (HMCL ModpackConfiguration). Returns [{name, path, format, gameVersion?, modLoader?}] where format maps Modrinth→mrpack, CurseForge→curseforge, HMCL→hmcl; gameVersion/modLoader are best-effort reads from the pack manifest. name is the instance id — pass it as version to launch_game.

Inputs: no named parameters.

list_versionslist_versionsA

List installed game versions by scanning /versions/ — a directory counts as a version when it contains /.json. Returns [{id, path, hasJar}], sorted by id.

Inputs: no named parameters.

search_modpackssearch_modpacksA

Search modpacks with HMCL's own repositories: Modrinth (default) or CurseForge (HMCL's embedded API key — no HMCL_MCP_CURSEFORGE_API_KEY needed). Returns ModpackSummary[]: id (slug), title, description, authors, url.

Inputs: query (required), limit, source.

start_hmclstart_hmclA

Start the headless HMCL JVM with the injected javaagent (no-op if already running, per ensureAgent) and return the agent status ({hmclVersion, workdir, java, versions, running, gamePid}). The launcher GUI never opens; only the game window appears when a game is launched.

Inputs: no named parameters.

stop_gamestop_gameA

Stop the currently running game process via the agent (POST /launch/stop).

Inputs: no named parameters.

stop_hmclstop_hmclA

Stop the headless HMCL JVM by POSTing /shutdown to the agent on 127.0.0.1, then confirm the agent is down with a status probe. Fails when no agent is reachable (run start_hmcl first).

Inputs: no named parameters.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 13 tools

    Disambiguation5/5

    Each tool targets a distinct resource (HMCL setup, agent lifecycle, versions, modpacks, game launch) with clear verbs like install, start, stop, list, search, get, download. No two tools perform the same action on the same resource, and descriptions make boundaries explicit.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun snake_case pattern, with paired verbs (start/stop, launch/stop, install/list) and objects (hmcl, versions, modpacks, game). This makes the API predictable and easy to navigate.

    Tool Count5/5

    13 tools is well within the ideal 3-15 range and covers setup, environment, modpacks, versions, and game control without redundancy or bloat. Each tool has a clear, non-overlapping role.

    Completeness4/5

    The server covers core workflows: install/setup, status checking, version installation and listing, modpack search/download/install/list, and game launch/stop. Minor gaps like uninstall/delete tools or per-mod management are not critical for the stated purpose.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers