Skip to main content
Glama
construct2-mcp

construct2-mcp

by wjrosa
README.md
# construct2-mcp

An [MCP](https://modelcontextprotocol.io) server that gives an AI agent (Claude Code, Claude Desktop,
or any MCP client) full control of the **Construct 2** game editor: create projects, build layouts,
add objects and behaviors, write event sheets, open and reload them in the editor, and export
finished builds.

Construct 2 has no scripting API, so the server works in two layers:

| Layer | How | What it covers |
|---|---|---|
| **Project** | Reads and writes the `.caproj` folder project directly, in the editor's own byte-exact XML format | Layouts, layers, instances, object types, animations, instance variables, behaviors, families, event sheets (events, sub-events, groups, variables, comments, includes, OR blocks, Else), sounds, files, project settings |
| **Editor** | Drives the running editor through Windows UI Automation patterns | Open, reload, save, preview, the full **Export** wizard (HTML5, NW.js, Cordova...), dialogs, screenshots, and any ribbon button, tab, tree item or checkbox |

Every condition and action is checked against the **installed** plugins and behaviors: the server runs
each addon's `edittime.js` in an embedded JavaScript engine, so it knows exactly what your Construct 2
knows, third-party addons included. Parameters are converted to the stored form (combo index,
comparison, key code, object name), and an unknown action, wrong parameter or bad option is refused
with a message that lists the valid ones.

The editor tools use UI Automation patterns and window messages, so they **don't move the mouse or
take the keyboard**: you can keep using the PC while an agent works. `editor_send_keys` is the one
exception, and it's labeled as such.

## Requirements

- Windows (Construct 2 is Windows-only)
- Construct 2 r279 or r280 (the final releases, still downloadable from
  [construct.net](https://www.construct.net/en/construct-2/download))
- Python 3.11+ and [uv](https://docs.astral.sh/uv/)

## Install

**Claude Code**

```
claude mcp add construct2 -- uvx --from git+https://github.com/wjrosa/construct2-mcp construct2-mcp
```

**Claude Desktop / other clients** (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "construct2": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/wjrosa/construct2-mcp", "construct2-mcp"]
    }
  }
}
```

Optional environment variables:

| Variable | Meaning |
|---|---|
| `C2_INSTALL_DIR` | Construct 2 folder, if it isn't found automatically |
| `C2_ADDON_DIRS` | Extra folders with `plugins/` and `behaviors/` subfolders |
| `C2MCP_EDITOR_SYNC` | `reload` (default) or `skip`: what to do when an edited project is open in the editor |
| `C2MCP_BACKUP_DIR` | Where backups go (default `%LOCALAPPDATA%\construct2-mcp\backups`) |

## What an agent can do

```
project_create      folder="D:/games/Dodge" name="Dodge"
object_create       name="Player" plugin="Sprite" image="player.png"
object_add_behavior object="Player" behavior="8 Direction"
instance_add        layout="Layout 1" object="Player" x=427 y=400
events_add          sheet="Event sheet 1" items=[
  {"conditions": [{"object": "System", "ace": "Every X seconds", "params": [0.5]}],
   "actions":    [{"object": "System", "ace": "Create object",
                   "params": {"Object to create": "Rock", "Layer": 0, "X": "random(854)", "Y": -20}}]},
  {"conditions": [{"object": "Player", "ace": "On collision with another object", "params": ["Rock"]}],
   "actions":    [{"object": "System", "ace": "Restart layout"}]}]
editor_open         project="D:/games/Dodge"
editor_export       folder="D:/games/Dodge-html5" platform="HTML5 website"
```

`event_sheet_read` shows a sheet the way the editor does, with an id on every line:

```
[8594137504185396] EVENT
  ? [6401295413349054] Keyboard: On space pressed
  > [3758869385639090] System: Add to (Score, 1)
  [8736377089486879] EVENT
    ? [6851630112316939] Hero: Compare instance variable (hp, ≤, 0)
    > [7911252092929822] Hero: Destroy
```

### Tools (55)

- **Project**: `project_info`, `project_create`, `project_templates`, `project_set_settings`,
  `capx_to_folder`, `folder_to_capx`, `backups_list`, `backup_restore`
- **Catalog**: `addons_list`, `addon_info`, `object_aces`, `catalog_learn`, `catalog_reload`
- **Objects**: `objects_list`, `object_create`, `object_add_frames`, `object_add_instance_variable`,
  `object_add_behavior`, `family_create`, `object_references`, `object_delete`
- **Layouts**: `layout_get`, `layout_create`, `layout_set`, `layer_add`, `layer_update`, `layer_delete`,
  `instances_list`, `instance_add`, `instance_update`, `instance_delete`
- **Events**: `event_sheet_read`, `event_get`, `event_sheet_create`, `events_add`, `event_replace`,
  `ace_add`, `events_delete`, `event_move`, `event_set_flags`
- **Files**: `file_import`
- **Editor**: `editor_status`, `editor_open`, `editor_reload`, `editor_close`, `editor_save`,
  `editor_preview`, `editor_export`, `editor_screenshot`, `editor_dialogs`, `editor_dialog_click`,
  `editor_dialog_set_text`, `editor_ui_tree`, `editor_ui_act`, `editor_send_keys`

## Safety

- **Your work in the editor comes first.** If the project is open in Construct 2 with unsaved changes,
  every project edit is refused, because saving in the editor would overwrite it. If the project is open
  and saved, the editor is reloaded after the edit.
- **Backups.** Before the first change to any file in a session, the original is copied to the backup
  folder. `backup_restore` puts it back.
- **Byte-exact files.** Unchanged files are never rewritten, and changed ones keep the editor's
  formatting, so diffs in git stay small. Tested by round-tripping 822 project files from shipped games.

## How it was tested

- 822 XML files from 9 released Construct 2 games re-serialize byte-identical.
- 20,355 conditions and actions in those games resolve against the catalog. The only unresolved ones
  come from third-party addons that weren't installed.
- A project built entirely through the tools opens in Construct 2 r279 without warnings, exports to
  HTML5 through the automated wizard, and runs in a browser with its events working.

## Limitations

- **Built-in ACE ids.** System conditions and actions, and the "common" ones every object gets
  (Set position, Destroy...), live in the editor's C++ code. Their ids were harvested from Scirra's
  bundled examples and real projects (107 so far, which covers the commonly used ones). If you need one
  that isn't known yet, add it once in the editor, save, and run `catalog_learn` on that project.
- Object **renaming** isn't supported yet (it has to rewrite every expression that names the object).
- `editor_preview` opens the project's preview browser, as Construct 2 always does.
- Construct 2 can't open sheets or layouts as tabs without a click, so read events with
  `event_sheet_read` rather than from screenshots.
- The Free edition's limits (events, layers) still apply in the editor.

## Development

```
uv sync
uv run python tools/roundtrip_check.py <folder with projects>   # byte-exact XML check
uv run python tools/resolve_check.py <folder with projects>     # every ACE resolves
uv run python tests/mcp_e2e.py <work dir> [--editor]            # full MCP run, optionally with the editor
uv run python tools/build_catalog.py --public <examples> --private <your projects>
```

`tools/build_catalog.py` only stores example parameter values from `--public` projects, so building the
catalog from private games never puts their code in the repository.

## License

MIT. Not affiliated with or endorsed by Scirra Ltd. "Construct" is a trademark of Scirra Ltd.

TDQS

C2.9/5.0

Scored across 55 tools

Disambiguation4/5

Tools are grouped by clear entity prefixes (project, object, layout, layer, instance, event, editor) and each usually targets a distinct resource+action. A few pairs are genuinely close: event_get vs event_sheet_read (text/json), editor_dialog_click vs editor_ui_act (both press buttons/dialogs), and object_create's frames argument vs object_add_frames. These overlaps are mostly resolvable from the descriptions, so misselection risk is moderate but not severe.

Naming Consistency4/5

A predictable <entity>_<verb> pattern dominates (object_create, layout_set, layer_delete, instance_update, events_add, editor_save, project_set_settings). Deviations are mostly plural/singular entity mismatches (instance_delete vs instances_list, event_get vs events_add/events_delete) and an odd ordering in ace_add and addons_list, but nothing chaotic. An agent can reliably infer prefixes.

Tool Count2/5

55 tools is well past the point where a set stays legible, even for a rich domain. The surface also mixes two largely independent concerns — editing project files on disk and automating the Construct 2 GUI (ui tree, dialogs, keys, screenshots) — so the set feels like two servers bundled together. Many granular event/ACE tools could have been consolidated.

Completeness4/5

Coverage is broad: project create/pack/unpack/settings, full object/family/behavior/instance lifecycle, layout/layer creation and updates, plus rich event-sheet editing (add, replace, move, flags, delete) and editor automation. Minor gaps exist — no layout_delete, event_sheet_delete/rename, or family update tools are exposed. Agents can work around these by editing files or deleting/recreating, so no hard dead ends.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues