← Player handbook

Quick reference

MCP agent tools reference

Every tool the desktop game's MCP server gives an AI assistant, what each needs, where it works, and a first session that gets an agent playing.

Before you start: Your first colonyConnect an AI assistant with the MCP server
Browse handbook
In this article

This reference lists the tools an AI assistant receives from the game’s MCP server, as shipped in the 0.11.6.2 desktop release. Earlier releases have fewer tools: game_guide and every game_* tool need 0.11.6.2 or later, and ui_inspect, ui_act, ui_wait, ui_renew_control and the hive_* tools need 0.11.5.0 or later. Download the current build from the Globulation 2 releases page.

Your assistant can read the exact arguments of each tool from the server itself. This page explains what the tools are for, so you know what to ask for and what to expect.

Three families of tools

Scroll to compare all columns ↔

FamilyWhat it doesWhere it works
ui_*Sees and operates the game window: screenshots, named on-screen controls, mouse and keyboard.Any screen of the desktop game.
game_*Reads your colony and acts on it in map tiles: place buildings, change them, paint zones, move the camera. Includes game_guide.game_guide works anywhere. The others work in a local match you are playing yourself.
hive_*Runs JavaScript player scripts for your colony and manages standing orders.A local match you are playing yourself.

Reading needs no control. Screenshots, inspection, waiting, game_guide, game_world, hive_status, hive_api, hive_result and listing or inspecting standing orders work without a token. Everything that changes the game needs the token from ui_acquire_control. See How control works.

game_guide: the built-in manual

game_guide is written for an assistant that knows nothing about Globulation 2. Point a new assistant at it first. Pass a topic; the default is overview. Every topic also returns links to the game’s source and documentation.

Scroll to compare all columns ↔

TopicWhat it covers
overviewWhat the game is and the first five calls to make.
gameplayRules: units, buildings, food, flags, zones and victory.
screensMenus and how to start a tutorial or a custom game.
hudReading the in-game screen.
actionsNamed controls versus coordinate gestures, placing and selecting.
controlThe control lease and token workflow.
hiveReading the world and scripting your colony with JavaScript.
troubleshootingWhat common errors mean and what to do next.
linksSource code, documentation and tutorial content.

ui_* tools: the game window

These tools work on every screen: menus, settings, the tutorial, matches, the map editor and replays. They operate the window as a person would, so they also work where the game_* and hive_* tools do not.

Look

Scroll to compare all columns ↔

ToolWhat it does
ui_statusWhether the window is available (not minimized or behind an operating-system dialog), its size, and who holds control.
ui_screenshotA PNG of the next rendered frame. max_width and max_height shrink it. The returned capture_id lets later clicks use this image’s pixel coordinates.
ui_inspectThe current screen’s name and its controls, each with a key, label, role, available actions, value and revision. compact: true gives a much smaller result and is recommended. surface or subtree narrows it; screenshot: true adds an image.
ui_waitWaits until something happens, for example {"screen": "game_session"} after starting a match, or a control becoming enabled or changing value. Default 10 seconds, at most 30. On timeout it returns the latest state.

Act on named controls

Scroll to compare all columns ↔

ToolWhat it does
ui_actOperates a control found by ui_inspect, by surface, key and revision. Actions are activate (press), select (choose by index), set_value (slider, toggle or text) and scroll. The game checks the control again when it receives the action, so a stale, hidden, disabled or covered control is refused rather than mis-clicked.

Named controls are the reliable way to use menus and panels. Prefer ui_act over clicking by coordinates whenever the thing you want is a button, tab, slider or field.

Mouse and keyboard

Scroll to compare all columns ↔

ToolWhat it does
ui_clickClicks at x, y: left (default), middle or right, single or double. A right click cancels placement.
ui_dragDrags through a list of points, for example to paint a zone or pan the map.
ui_scrollMouse wheel at x, y: zooms the map or scrolls a list.
ui_moveMoves the pointer (hover).
ui_mouse_buttonHolds or releases a mouse button across calls.
ui_keyPresses, holds or releases a key by name, such as Escape, Return, Space or A, with optional modifiers. Escape cancels placement or selection, then opens the game menu.
ui_type_textTypes text into the focused text field.
ui_release_inputsLets go of every key and button the assistant is holding. It keeps control.

The map, minimap and replay bar are pictures rather than controls, so use a screenshot and coordinates there. Pass the screenshot’s capture_id so x and y refer to that image. Any input tool can also return a fresh screenshot with capture_after: true.

Control

Scroll to compare all columns ↔

ToolWhat it does
ui_acquire_controlTakes control and returns the token. Fails while another client holds control. inspect: true also returns the current screen.
ui_renew_controlExtends the five-minute control lease without sending input.
ui_release_controlReleases held keys and buttons and gives up control.

game_* tools: your colony in map tiles

These tools let an assistant think in map tiles instead of screen pixels. Apart from game_guide, they work only in a local match where you are the human player. They are unavailable online, in LAN games, replays, spectating, or when an AI has taken over your colony.

Scroll to compare all columns ↔

ToolWhat it does
game_worldReads your colony: free and total units, prestige and win chance; recent alerts such as attacks, with their tiles; your buildings with id, type, top-left tile, size, level, construction state and workers; unit counts and your warriors by training level; hungry and injured units; known resources with the nearest tile; other teams’ buildings you can see or remember; how recent placements went; and the names and sizes of everything you can place. detail: "full" adds unit lists. area limits it to a tile rectangle. No token needed.
game_placePlaces a building site or flag by name, with its top-left corner on a tile, through the same checks as a click. near: true searches outward for room and reports where it went. Buildings need explored ground. Refusals say why.
game_buildingChanges one of your buildings or flags by its id and generation from game_world: units requested (workers), priority (low, medium, high), Swarm production ratios, flag range, or an action: upgrade, repair, cancel_upgrade, destroy, cancel_destroy, or move (a flag, to x, y). A request above the building’s limit is capped, and the reply says so.
game_zonePaints or erases a forbidden, guard or clearing zone over a tile rectangle, up to 64 by 64 tiles.
game_viewCentres the camera on a tile and returns where it now appears on screen, so the assistant can click what is there.

Fog of war applies. The game_* tools report only what your colony sees now or has seen before. Other teams’ buildings out of sight are reported as last seen, and are corrected only when that ground is in view again. They never reveal another team’s hit points or warrior training. An assistant using these tools learns nothing your colony has not seen.

Placements pass the same checks as your own clicks. A placement is confirmed on a later simulation step, so the assistant should check game_world rather than assume success.

hive_* tools: scripts for your colony

The hive_* tools run small step(ctx) JavaScript player scripts in a local match on your own computer. They need no account and no credits, and they work in today’s desktop releases. These are the same kind of scripts that the upcoming online Hive Mind commander will use. Call hive_api for the exact script contract your game version accepts; Hive Mind standing orders explains the standing-order idea from a player’s point of view.

Where they work: only a local match where you are the human player. Online and LAN games, replays, spectating and AI takeover all refuse local scripting. Scripts see only what your colony may see.

Scroll to compare all columns ↔

ToolWhat it does
hive_statusWhether scripting is available now, the current match session id, and the limits. No token needed.
hive_apiThe script API: world queries, order formats and limits. Read it before the first script. No token needed.
hive_runRuns one script once. Needs token, session, a new operation_key and source. A queued reply means the script was accepted, not that it succeeded.
hive_resultReads a run’s or program change’s output, errors and order results by session and operation_key. It never runs anything again.
hive_programManages standing orders, named scripts that run again every interval_ticks (at least 25): list, inspect, install, replace (with expected_revision from inspect), pause, resume, cancel. Changes need the token, session and a new operation key.

Limits and lifetime

Scroll to compare all columns ↔

LimitValue
Script source128 KiB
Standing orders per match8
Orders returned by one invocation32
Minimum interval for standing orders25 ticks
  • Use a fresh operation key for each change. Repeating a key with the same arguments returns the earlier result without running it again. Reusing a key with different arguments fails.
  • One-shot runs share nothing. Each hive_run starts fresh. A standing order keeps its variables between its own successful runs; replacing it resets them.
  • Standing orders outlive the assistant. They keep running after the assistant disconnects or its control lease expires. Each has an in-game Hive card showing recent output and errors, with pause, resume and cancel controls. If a program’s worker fails, that program is paused.
  • Nothing is saved. Standing orders, their variables and run history are never saved with the game. Leaving or loading a match discards them. A new match has a new session id.
  • Accepted is not achieved. Orders a script returns still go through the normal order queue, and the game decides what actually happens.

Give your assistant this sequence, or simply ask it to call game_guide and follow the overview.

  1. game_guide with topic overview (and later gameplay and screens) to learn the game.
  2. ui_status to check the window is available and nobody else holds control.
  3. ui_acquire_control and keep the token.
  4. ui_inspect with compact: true to see the current screen and its controls.
  5. From the main menu, ui_act to activate Tutorial (key menu/1), then Introduction (key tutorial/lesson/0). On a brand-new profile the first screen may instead offer intro/start.
  6. ui_wait for {"screen": "game_session"}, then inspect again. Control numbers and revisions change whenever a screen is rebuilt.
  7. Read the lesson card and follow it. Use game_world to see the colony, game_place and game_building to act, and game_view with ui_screenshot to look around the map.
  8. Optionally, hive_status and hive_api, then a small read-only hive_run followed by hive_result.
  9. ui_release_control when finished.

Two rules keep a session safe:

  • Never retry an input call automatically. The game may have received it before an error or timeout was reported. Inspect first, then decide.
  • Re-inspect after every screen change. An action’s reply can describe the screen as it was when the input arrived; wait for the new screen before acting again.

Troubleshooting

Scroll to compare all columns ↔

What the assistant seesWhat to do
Window not availableThe game is minimized, hidden or behind an operating-system dialog. Restore it, then call ui_status again.
Another client controls the gameWait for it to finish, or press Revoke control in Settings → MCP server.
Token rejectedControl was lost. Call ui_acquire_control again.
Stale controlThe screen changed. Call ui_inspect again and use the new surface and revision.
Hidden controlScroll its container with ui_act (scroll) first.
Blocked controlA dialog or panel covers it. Close or answer the dialog.
Stale viewport or expired captureTake a new ui_screenshot and use its capture_id.
Wait timed outThe condition did not happen. Read the returned state.
game_* or hive_* unavailableYou are not in a local match as the human player, or the match is online, LAN, a replay, spectated or under AI takeover.
Match session expiredA new match started. Get the new session from hive_status.
Nothing happens in the matchCheck the game is not paused and the building or flag requests more than zero units.