|
| 1 | +# Live-Editing an Open Studio Pro Project with mxcli (MCP) |
| 2 | + |
| 3 | +Use mxcli to change the model **while Studio Pro has the project open**, with edits |
| 4 | +appearing live in Studio Pro — no save-and-reopen cycle. This is the workflow when |
| 5 | +Claude Code runs on the same machine as Studio Pro (e.g. an in-IDE terminal). |
| 6 | + |
| 7 | +## When to use this skill |
| 8 | + |
| 9 | +- Studio Pro is open on the project and you want mxcli changes to show up live. |
| 10 | +- mxcli and Studio Pro run on the **same machine** (same `localhost`). |
| 11 | + |
| 12 | +If Studio Pro is **not** open, use the normal file-based flow instead |
| 13 | +(`mxcli -p app.mpr -c "..."` with no `--mcp`), which edits the `.mpr` on disk. |
| 14 | + |
| 15 | +## How it works (hybrid: local reads, live writes) |
| 16 | + |
| 17 | +- **Reads** come from the local `.mpr` you pass with `-p`. |
| 18 | +- **Writes** go to Studio Pro's live, in-memory model via its built-in MCP server. |
| 19 | +- Therefore **`-p` MUST be the exact project Studio Pro currently has open**, or |
| 20 | + reads and writes will describe different projects. |
| 21 | + |
| 22 | +## Connect |
| 23 | + |
| 24 | +Studio Pro's MCP server listens on `localhost:7782` and requires the HTTP |
| 25 | +`Host` header to be `localhost` (a DNS-rebinding guard). Same-machine, **no |
| 26 | +port-forwarding/socat is needed**: |
| 27 | + |
| 28 | +```bash |
| 29 | +mxcli --mcp http://localhost/mcp --mcp-dial localhost:7782 \ |
| 30 | + -p /path/to/app.mpr \ |
| 31 | + -c "create entity MyModule.Customer" |
| 32 | +``` |
| 33 | + |
| 34 | +`--mcp-dial localhost:7782` keeps the `Host` header `localhost` while dialing the |
| 35 | +port. (Plain `--mcp http://localhost:7782/mcp` may also work if your Studio Pro |
| 36 | +accepts a port-suffixed `Host` — try it; fall back to the `--mcp-dial` form if it |
| 37 | +is rejected.) |
| 38 | + |
| 39 | +Run a script the same way: `mxcli --mcp http://localhost/mcp --mcp-dial localhost:7782 -p app.mpr exec changes.mdl`. |
| 40 | + |
| 41 | +## What you can change via MCP |
| 42 | + |
| 43 | +Modules, entities (and attributes), associations, enumerations, view entities, |
| 44 | +microflows, and pages — plus `ALTER PAGE` (INSERT / DROP / REPLACE widgets, SET |
| 45 | +DataSource, SET Layout). New modules and their dependents resolve within the same |
| 46 | +run, so `create module X; create enumeration X.Status (...)` works in one script. |
| 47 | + |
| 48 | +## Two MCP servers — use the built-in one by default |
| 49 | + |
| 50 | +The machine may run two MCP servers: |
| 51 | + |
| 52 | +- **Studio Pro built-in (port 7782)** — model authoring. **Use this by default.** |
| 53 | +- **Concord (port 7783)** — a temporary gap-filler with operational/refactor tools |
| 54 | + (`delete_document`, `save_all`, `run_app`, `check_model`). **Only** reach for |
| 55 | + Concord when the built-in server lacks the capability you need. |
| 56 | + |
| 57 | +## Caveats |
| 58 | + |
| 59 | +- **Writes are unsaved.** They land in Studio Pro's in-memory model (shown as |
| 60 | + unsaved). Save in Studio Pro to persist to disk. |
| 61 | +- **No DROP of standalone documents** (enumeration / microflow / page) through the |
| 62 | + built-in server — it has no delete tool. Remove them in Studio Pro (or via |
| 63 | + Concord's `delete_document`). |
| 64 | +- **`-p` must match the open project.** A mismatched `-p` silently reads the wrong |
| 65 | + model. |
| 66 | + |
| 67 | +## Verify your change |
| 68 | + |
| 69 | +Read it back through the same connection (in-session edits are visible), or look |
| 70 | +in Studio Pro: |
| 71 | + |
| 72 | +```bash |
| 73 | +mxcli --mcp http://localhost/mcp --mcp-dial localhost:7782 -p app.mpr -c "show entities in MyModule" |
| 74 | +``` |
0 commit comments