bryce-mcp
README.md
# bryce-mcp
MCP server for **MetaCreations Bryce 3D 3.0** under Wine on Linux, built around its native `.br3` scene format.
Other Bryce versions (4, 5, 6, 7) are not supported.
Bryce has no scripting API and an undocumented `.br3` format, so this server works in three layers:
| Layer | Needs Bryce? | What it does |
|---|---|---|
| **Assets** | no | Procedural terrains (heightmap PNG + colour texture + textured OBJ), boulders, tileable textures, arbitrary OBJ geometry, previews the model can see |
| **GUI** | yes | Runs Bryce under Wine on a private X display, takes screenshots, clicks, types, presses keys, and replays recorded macros (import object, open scene, render) |
| **Scenes** | to render | `scene_build` writes `.br3` files directly from JSON, then renders them in Bryce |
## Install
```sh
cd ~/bryce-mcp
uv sync
```
System tools: `wine`, `xdotool`, `Xvfb` (or `Xwayland`), ImageMagick (`import`).
### Register with omp
`~/.omp/agent/mcp.json`:
```json
{
"mcpServers": {
"bryce": {
"type": "stdio",
"command": "uv",
"args": ["run", "--project", "/path/to/bryce-mcp", "bryce-mcp"]
}
}
}
```
Claude Code: `claude mcp add bryce -- uv run --project ~/bryce-mcp bryce-mcp`
### Install Bryce
Run the Bryce 3D 3.0 installer from a Wine CD-ROM drive, or ask the agent to run `bryce_install` with its path; the
installer runs on the private display and the agent clicks through it with `window="screen"` screenshots. `bryce_status`
confirms the executable is found (auto-detected as `Bryce 3D.exe` under `drive_c/Bryce 3D` or `drive_c/Program Files*`;
override with `bryce_configure(exe=...)`).
## Tools
**Assets** (written to `~/BryceAssets`, override with `BRYCE_ASSETS` or `bryce_configure(assets=...)`):
| Tool | Output |
|---|---|
| `terrain_generate` | `rolling`, `mountains`, `canyon`, `island`, `dunes`, `mesa`; palettes `alpine`, `desert`, `temperate`, `volcanic`, `tropical`. Writes `<name>_height.png` (16-bit by default, for the Terrain Editor), `<name>_color.png`, `<name>.obj/.mtl`. Returns a top-down + 3D preview. |
| `rock_generate` | Faceted boulder OBJ with a rock texture |
| `texture_generate` | Seamless `rock`, `marble`, `wood`, `clouds`, `sand`, `grass`, `lava` |
| `mesh_write` | Arbitrary vertices/faces as OBJ |
| `assets_list`, `asset_preview` | List files with their Windows paths; view an image or render an OBJ |
**GUI:**
| Tool | Does |
|---|---|
| `bryce_status`, `bryce_configure` | Install/display/macro state; settings |
| `bryce_install`, `bryce_launch`, `bryce_quit` | Lifecycle (`bryce_quit(stop_display=True)` also stops the X server) |
| `bryce_screenshot`, `bryce_windows` | See the window, including open menus and dialogs |
| `bryce_click`, `bryce_key`, `bryce_type` | Input; coordinates are pixels in the screenshot of that window |
| `bryce_macro_save/run/list/delete` | Record and replay step lists |
| `bryce_open_scene` | Restart Bryce with a scene file on its command line (unsaved work is lost) |
| `bryce_import_object`, `bryce_render` | Macro shortcuts |
Built-in macros use Bryce 3.0's shortcuts: Ctrl+R render, Ctrl+Alt+R clear and render, Ctrl+O open, Ctrl+S save,
Ctrl+N new. **File > Save As and File > Import Object have no shortcut**, so the agent records them once from screenshots:
```json
[{"key": "Escape Escape"}, {"click": [fileX, fileY]}, {"click": [itemX, itemY]},
{"wait_window": "open|import"}, {"type": "{path}"}, {"key": "Return"}]
```
The leading double Escape matters: a single Escape leaves a Windows menu bar armed, and the next click on it closes the menu
instead of opening it.
Bryce 3.0 hides its menu until the pointer reaches the top edge. Record a `{"move":[100,0],"pause":0.6}` step
before clicking File. Its Open and Import Object dialogs are untitled, so use `{"wait_window":"open|^$","new":true}`.
For a `save_scene_as` macro, select the existing filename with `{"key":"Home shift+End"}` before typing the new path.
## Code in, scene out (`scene_build`)
`scene_build(spec, name)` writes a Bryce 3.0 `.br3` file straight from a JSON spec, with no GUI clicking. It then
restarts Bryce with that file, renders it, waits until the image stops changing, saves the render as
`~/BryceAssets/<name>_render.png` and returns it. The file is `~/BryceAssets/<name>.br3`, a normal scene you can open,
edit and save in Bryce.
```json
{
"sky": {"base_rgb": [0.22, 0.27, 0.46], "horizon_rgb": [1, 0.52, 0.31], "haze": 0.16, "cloud_cover": 32,
"fog": {"amount": 0.06, "thickness": 0.14, "rgb": [0.88, 0.64, 0.51]},
"sun": {"azimuth_deg": 328, "elevation_deg": 7}},
"camera": {"position": [135, 76, -218], "look_at": [0, 8, 15], "fov_deg": 50},
"objects": [
{"type": "water", "position": [0, 0, 0]},
{"type": "terrain", "heightmap": "~/BryceAssets/alpine_valley_height.png", "size": [176, 56, 176]},
{"type": "sphere", "position": [30, 15, 40], "size": [10, 10, 10], "color": [0.9, 0.2, 0.2]}
]
}
```
Object types: `terrain`, `sphere`, `cube`, `cylinder`, `cone`, `pyramid`, `torus`, `water`, `clouds`, `ground`,
`rock`, `square` and `mesh` (`"obj": path`). Units are the ones in Bryce's Object Attributes dialog, with Y up;
`position` is the centre of the object's bounding box, except for `mesh`, where it places the OBJ's origin.
Relative asset paths resolve against `~/BryceAssets`. `color`, `transparency`, `reflection` and `specular` (0..1)
override the object's material. Water with no overrides keeps Bryce's textured LowSmogg look. For an opaque sea,
use `"transparency": 0`, otherwise a terrain's flat floor shows through. `fov_deg` is the horizontal field of view;
Bryce stores a wider native angle, and the builder converts it. Setting `base_rgb`/`horizon_rgb` switches the sky to
Bryce's Custom Sky mode.
Each object is cloned from a prototype in `src/bryce_mcp/br3/templates/prototypes.br3`, a scene saved by Bryce 3.0.
The `.br3` format is reverse-engineered and documented in [`docs/br3-format.md`](docs/br3-format.md). The same
builder runs offline as `python -m bryce_mcp.br3.build spec.json out.br3`. Example specs are in `examples/`:
`island.json` uses `terrain_generate(name="isle", kind="island", seed=7)`, and `mesh.json` uses
`~/BryceAssets/boulder_a.obj`, made with `rock_generate(name="boulder_a")`.
## Why a private X display
On Wayland (sway here), XWayland delivers synthetic clicks to X windows only while your real mouse is over them, so driving
Bryce on the desktop would work or silently fail depending on where your cursor is, and it would take over your mouse.
The server starts its own X server instead:
- `display_mode: "xvfb"` (default): headless 1600x1000. You see Bryce through the screenshots the agent gets.
- `display_mode: "xwayland"`: the same private display, as a window on your desktop you can watch and use. On a tiling
compositor, float it (sway: `for_window [app_id="org.freedesktop.Xwayland"] floating enable`) or its size follows the tile.
- `BRYCE_DISPLAY=:0`: drive an existing X display instead (plain X11 sessions).
The private display has no window manager. Wine parks X focus on an internal window there, so the tools target the newest
titled Bryce window (the open dialog) when focus is unknown, and clicks never raise windows (raising would bury modal dialogs).
## Using Bryce by touch
`touch/bryce-touch` opens Bryce for your own hands (not the agent) on a Wayland touchscreen. It runs a fullscreen
Xwayland at half the panel resolution, so every control is drawn twice as large, and starts `touch/touch-bridge`.
Wine turns finger touches into Windows pointer messages, which Bryce 3.0 ignores. The bridge grabs touch on that
display first and replays the first finger as the left mouse button. Extra fingers are ignored. Defaults:
`WINEPREFIX=~/.wine`, `BRYCE_DISPLAY=:91`. Set `BRYCE_SIZE=WxH` to choose another scale. The bridge is compiled
on first run and needs the Xlib, XInput 2.2 and XTest headers.
## Files
- Config and recorded macros: `~/.config/bryce-mcp/config.json`
- Wine and display logs: `~/.cache/bryce-mcp/`