run_lua
Execute custom Lua code in Civilization VI to query game state or run in-game commands when built-in tools don't cover a specific task.
Instructions
Run arbitrary Lua code in the game. Advanced escape hatch — prefer built-in tools.
Args:
code: Lua code to execute. Use print() for output, end with print("---END---").
context: "gamecore" (default) for read-only state queries.
"ingame" for commands and UI-dependent queries.
Context differences:
gamecore: Players[], GameInfo.*, Map.*, Game.* — safe read-only access.
CANNOT use: UI.*, UnitManager.*, CityManager.*, notifications.
ingame: All APIs including UI.*, UnitManager.*, CityManager.*.
Use for: moving units, setting research, diplomacy actions.
Always use print() for output (not return).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "run_lua"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| context | No | gamecore |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |