# MysteryForge art integrations — for AI agents

How an agent connected to MysteryForge's MCP server works with the tools that make pictures: **QxSprite** (pixel sprites and animation, through its own MCP server or CLI), **Blender** (pre-rendered rooms and characters, through its command line), and anything else that writes files. Read https://mysteryforge.vivalainsurreccion.com/agents/quickstart.md first.

The division of labour is always the same:

1. **The art tool makes a file** and saves it inside the game, under `game/assets/<kind>/`.
2. **MysteryForge binds it** into the game data with its tools (`upsert_character`, `update_scene`, `add_hotspot`, `replace_asset`…), using **project-relative paths** (`game/assets/actors/keeper_walk.png`).
3. **MysteryForge checks it:** `validate_project` (0 errors), then `screenshot_scene` to look at it as the player will.

MysteryForge's tools import new files for you (Godot must import pictures before the game can show them). If you put files in place with another tool and then run the game yourself outside the MCP, run `MF/mysteryforge import <game>` first.

## Sizes and formats (all tools)

| Picture | Size | Bind with |
|---|---|---|
| Room | 1920 × 1080, WebP or PNG | `update_scene` `background` (or `replace_asset` over a placeholder) |
| 360° room | 2:1, 4096 × 2048 | `update_scene` `panorama: {image, h_span?}` |
| State patch | the changed part only | an overlay in `update_scene`: `{id, image, rect, visible_if}` |
| Item icon | 256 × 256, transparent | `upsert_item` `icon` |
| Portrait | 512 × 512 | `upsert_character` `portrait` |
| Actor pose | one canvas for every pose, transparent, untrimmed | `upsert_character` `actor.poses.<name>` |
| Animation | a sheet: equal cells, left→right, top→bottom, one animation, no spacing/border | `sheet: {image, columns, rows, count?}` + `fps` |

Fetch `get_spec` sections **"Actors"**, **"Animation"**, **"Living portraits"** and **"Asset pipeline"** before writing those fields. SVG you write yourself (`write_asset_text`): no `<text>`, no `hsl()`, no 8-digit hex.

## QxSprite (two MCP servers in one session)

QxSprite's MCP server (`qxsprite`) draws and exports; MysteryForge's (`mysteryforge`) binds and checks. Setup for the human, if `qxsprite` tools are not in your list:

```bash
claude mcp add qxsprite -e ELECTRON_RUN_AS_NODE=1 -- "/Applications/QxSprite.app/Contents/MacOS/QxSprite" "/Applications/QxSprite.app/Contents/Resources/cli/qxsprite.cjs" mcp
```

(Windows: `%LOCALAPPDATA%\Programs\qxsprite\QxSprite.exe` and `…\resources\cli\qxsprite.cjs`; Linux deb: `/opt/QxSprite/qxsprite` and `/opt/QxSprite/resources/cli/qxsprite.cjs`.) QxSprite's own agent guide: its `AGENTS.md` and `docs/MCP_TOOLS.md`.

**Recipe: a character who stands, walks and talks in a room**

1. `get_spec` section `"Actors"`; `get_scene` for the room (its `floor`, `markers`, existing `actors`).
2. QxSprite: `new_sprite` (transparent; e.g. 48 × 96), draw the figure with the feet at the bottom-centre, `frame` to add frames, `tag` each animation: `idle` (1 frame, or a short breathing loop), `walk` (4–8 frames, **walking right**: the engine mirrors it), `talk` (2–4 frames, mouth **closed first, widest last**), optionally `blink` (the idle frame with eyes shut).
3. QxSprite `export_spritesheet` once **per tag**: `path` = `<game>/game/assets/actors/<character>_<tag>.png`, `tag`, `layout: "horizontal"`, `scale` so the figure is drawn near its on-screen size (a figure half the screen tall is ~540 px: scale 6 for 96 px), spacing and border 0, `json: "hash"`. For `talk`, `export_frames` with `{frame}` in the path gives one file per mouth shape.
4. Work out each sheet block: `columns` = frames in the tag, `rows` = 1, `fps` = 1000 / the frame duration in ms. (The human's helper `MF/integrations/sprite_sheet.py <sheet.json> --asset game/assets/actors/<file>.png` prints it and flags a layout the engine cannot play.)
5. MysteryForge `upsert_character` with `actor`: `height` (fraction of the picture's height at scale 1), `poses` (`idle`: `{image}` or `{sheet, fps}`; `walk`: `{sheet, fps}`; `talk`: `{frames: [closed, …, widest]}`; `blink`), and `life: {sway, breathe, blink: "blink"}` for idle movement.
6. `update_scene`: the room's `actors` entry (where they stand: a `marker` or a position on the `floor`), and a hotspot for clicking them (talk).
7. `validate_project` → `screenshot_scene` (does the figure stand on the floor at a believable size?) → adjust `height` / position → `autoplay_game` if the story changed.

**Recipe: an animated thing in a room** (a fire, a clock pendulum): draw it at the size it covers on the 1920 × 1080 room, export one tag as a sheet, then add an overlay to the scene with `rect` (its place, fractions of the room) and `sheet` + `fps`.

**Recipe: item icons:** 256 × 256 canvas (or draw small and export with `scale`), `export_png` to `game/assets/items/<item>.png`, then `upsert_item` with `icon`, or `replace_asset` over the placeholder SVG.

## Blender (a command line)

Blender has no MCP server; run it as a command. The MysteryForge download ships `MF/integrations/blender/mf_blender.py`, which renders from the scene camera and projects every tagged object to a MysteryForge hotspot rectangle. Full guide: https://mysteryforge.vivalainsurreccion.com/docs/blender.md.

```bash
blender -b <file.blend> -P MF/integrations/blender/mf_blender.py -- --room <scene_id> --out <dir> [--preview] [--patch Obj1,Obj2] [--figure] [--panorama] [--camera Name]
```

Blender on macOS: `/Applications/Blender.app/Contents/MacOS/Blender`. **Render one at a time** (parallel renders exhaust GPU memory), and use `--preview` (half size, 24 samples) while iterating; a full render can take minutes. Objects are hotspots when they carry a custom property `mf_hotspot` (= the hotspot id; `mf_label` = the name players see) or sit in a collection `mf_hotspots`. You can add those yourself with a short `--python-expr` or script before rendering.

**Recipe: a rendered room into the game**

1. Render with `--room <scene_id>`. Read `<dir>/<scene_id>.hotspots.json`: `size`, and `hotspots[]` each with `id`, `label`, `shape`.
2. Convert to WebP (`cwebp -q 85 in.png -o out.webp`) into `<game>/game/assets/backgrounds/<scene_id>.webp`.
3. `replace_asset` (when the scene has a placeholder background: rewrites every reference) or `update_scene` with `background`.
4. For each reported hotspot: `update_hotspot` when the scene has that id (move it onto the model), else `add_hotspot` with the reported `shape`, a `label`, a `cursor`, and its `actions`. Hotspot ids must be snake_case and unique in the scene.
5. `screenshot_scene` with `show_hotspots: true`: every outline should sit on its object. Then `validate_project`.

**Recipe: a state** (a drawer opened): change the objects in the `.blend` (or set the frame of a keyframed change), render with `--patch Drawer,Letter --room <scene>_<state>`, put the PNG at the report's `overlay.image`, and add the report's `overlay` (`id`, `image`, `rect`) to the scene with a `visible_if` on the variable the story sets. Check it with `screenshot_scene` and `set: {"<variable>": true}`.

**Recipe: a character pose**: render inside the room's file with the room held out (so the light matches), `--figure` at a fixed canvas, the same canvas for every pose; never trim. Bind as actor poses (above). Loops: render frames, tile them into a sheet (`ffmpeg -i f_%04d.png -vf tile=8x1 sheet.png`), make both sides multiples of 4 if it will be VRAM-compressed for the web.

**Recipe: a 360° room**: camera level at eye height in the room's middle, `--panorama` (4096 × 2048), then `update_scene` with `panorama: {image}` and the reported hotspots (they are already in panorama sheet coordinates). A hotspot in `skipped` for straddling the seam must be split into two objects.

## Image models (MysteryForge's own art pipeline)

`art_plan` → `art_set_bible` (the style) → `art_estimate` (**show the cost to the user and wait for a yes**) → `art_generate` → `art_job` (poll) → `art_accept` → `art_calibrate` (checks each hotspot still sits on its object; writes nothing without `apply`). Keys come only from the environment (`OPENAI_API_KEY`, `BLOCKADE_API_KEY`); never ask for one, write one to a file or log it. Findings from a real run: https://mysteryforge.vivalainsurreccion.com/docs/ai-art.md.

## Any other tool

Krita, Photoshop, Aseprite, a scanner: save into `game/assets/<kind>/` at the sizes above and bind with the same tools. For an outside artist, `export_handoff` writes a layout guide per room at the delivery size (where each hotspot will be, what the interface covers), a shot list and a contact sheet. Reference: https://mysteryforge.vivalainsurreccion.com/docs/art-tools.md.
