Skip to content
Back to skills

Servicestudio Mcp Oml

ASecurity

Provides the C# Model API contract for Service Studio's in-process MCP Server — full `eSpace => { ... }` lambdas (no `eSpace.Save(...)`) that mutate the open `.oml` module via the `applyModelApiCode` MCP tool. Covers the full-lambda contract, the Model API surface (entities, attributes, screens, server / client actions, structures, roles), the sandbox, the edit session that chains edits, the camelCase tool catalogue (`getDataModel`, `getScreen`, `runQuery`, `getValidationMessages`, `listOpenM...

  • 40 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added October 9, 2026
ai-agentsjavascriptrustgojavac#sqlreactnodeexpresstesting

Works with

  • cli
  • api
  • mcp

Security analysis

A92/100
  • mediumUses curl or wget to download content

Pro scans all 19 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add OutSystems/outsystems11-mcp --skill servicestudio-mcp-oml --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Servicestudio Mcp Oml?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Servicestudio Mcp Oml
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/outsystems-servicestudio-mcp-oml/badge)](https://www.skillsdirectory.com/skills/outsystems-servicestudio-mcp-oml)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: servicestudio-mcp-oml
description: >-
  Provides the C# Model API contract for Service Studio's in-process MCP
  Server — full `eSpace => { ... }` lambdas (no `eSpace.Save(...)`) that mutate
  the open `.oml` module via the `applyModelApiCode` MCP tool. Covers the
  full-lambda contract, the Model API surface (entities, attributes, screens,
  server / client actions, structures, roles), the sandbox,
  the edit session that chains edits, the camelCase tool
  catalogue (`getDataModel`, `getScreen`, `runQuery`, `getValidationMessages`,
  `listOpenModules`, `openModule`, …), the session token + `input` envelope, and the host-only
  `omlReset` / `omlMerge` / `omlRefreshReferences` / `omlPublish`
  tools. Use when calling `applyModelApiCode`, working with the Service Studio
  MCP oml tools, editing an open module via Service Studio MCP, editing or
  modifying `.oml`, writing Model API code, or asking to add an entity /
  attribute via the Model API. Not for runtime OutSystems platform debugging:
  design-time only. This skill is written for MCP contract 2.
---

# OutSystems Model API for `applyModelApiCode`

This skill teaches you to write C# Model API **lambdas** for the
`applyModelApiCode` MCP tool exposed by Service Studio's in-process MCP Server.
It also points you at an example corpus, namespace doc files, and end-to-end
integration walkthroughs. **Read this file fully** — the invocation contract
differs from ODC's published examples in one important way (see § 1).

> **Naming note.** This MCP server's tools use **camelCase, no `oml_` prefix**
> (`applyModelApiCode`, `getDataModel`, `omlMerge`, `listOpenModules`, …). Earlier
> versions of this skill used `oml_`-prefixed snake_case names like
> `oml_apply_model_api_code` — those **no longer exist**; every tool name here
> is the exact camelCase name the host advertises.

> **Beta Feature (write tools).** The write capabilities this skill teaches — mutating
> `applyModelApiCode` lambdas, `startOmlEditSession`, `endOmlEditSession`, `omlMerge`,
> `omlReset`, `omlRefreshReferences` and `omlPublish` — are a Beta Feature: a non-final OutSystems capability provided to collect
> customer feedback. They can change significantly, including through breaking changes, or be
> discontinued. **The first time you use a write tool in a conversation, tell the user it's a
> Beta Feature and share https://www.outsystems.com/legal/beta-features-agreement.** The read tools are Generally Available and need no notice.
> A throw-probe (`applyModelApiCode` that ends in `throw new Exception("PROBE:…")`, § 1.1) saves
> nothing, so it's allowed when the user asks you not to change anything. It still needs an edit
> session (§ 2), and the session tools are write tools, so give the notice.

## Contents

- [When to Use](#when-to-use)
- [§ 0 — Contract check, session token and argument envelope](#0-contract-check-session-token-and-argument-envelope)
- [§ 0.1 — Choosing the module: `eSpaceName`, opening and closing](#01-choosing-the-module-espacename-opening-and-closing)
- [§ 1 — The full-lambda contract](#1-the-full-lambda-contract--read-this-first)
- [§ 1.1 — The code sandbox](#11-the-code-sandbox)
- [§ 2 — Reading before writing](#2-reading-before-writing)
- [§ 2.1 — The edit session: start it before the first write](#21-the-edit-session-start-it-before-the-first-write)
- [§ 3 — The `applyModelApiCode` invocation shape](#3-the-applymodelapicode-invocation-shape)
- [§ 3.1 — Finalising — auto-merge after the last mutation](#31-finalising--auto-merge-after-the-last-mutation)
- [§ 3.2 — Refreshing references and publishing](#32-refreshing-references-and-publishing)
- [§ 4 — Default imports](#4-default-imports)
- [§ 4.1 — Module style support](#41-module-style-support)
- [§ 5 — Common patterns (pointers)](#5-common-patterns-pointers)
- [§ 6 — Where to dig deeper](#6-where-to-dig-deeper)
- [§ 7 — Integration walkthroughs](#7-integration-walkthroughs)
- [§ 8 — Known gaps](#8-known-gaps)
- [Common Mistakes](#common-mistakes)
- [§ 9 — Security caveat](#9-security-caveat)

## When to Use

**Use this skill when:**

- Calling `applyModelApiCode` to mutate the open `.oml` module.
- Calling any of the `get*` read tools, `runQuery`, `listOpenModules`,
  `getValidationMessages`, or the host-only `startOmlEditSession` /
  `endOmlEditSession` / `omlReset` / `omlMerge` tools.
- Finding, opening or closing a module through Service Studio MCP
  (`searchApps`, `openModule`, `closeModule`).
- Writing C# Model API code — entities, attributes, screens, server / client
  actions, structures, roles, integrations — that targets `IESpace`.
- Reasoning about the per-module edit session and session pointer, the
  silent-no-op trap, or how the host wraps your lambda.

**Do NOT use for:**

- Runtime OutSystems platform debugging (this is strictly design-time OML
  mutation).
- Driving the standalone tool directly. The MCP host bundles and spawns the
  sidecar per call, but the contract you write to is the MCP tool's, described here.
- ODC-side OML editing — those tools wrap differently and surface a
  different verb catalogue.

## 0. Contract check, session token and argument envelope

**This skill is written for MCP contract 2.** The first line of the server's instructions names the
server's contract: `Service Studio <version>, MCP contract <N>.` Compare it with 2:

- **2:** carry on.
- **Higher than 2:** the server is newer than this skill. The second line of its instructions says
  where to get the latest skill: tell the user, offer to install it, and install it only if they
  agree. The new skill only loads in a new session.
- **Lower than 2, or no contract line** (contract 1): follow that contract's notes in
  [`reference/contracts.md`](reference/contracts.md).

On any contract, where a tool's live description differs from this skill, follow the description.

If your client doesn't show you the server's instructions, `createSessionToken`'s description says
the same (`This server speaks MCP contract <N>.`, then the skill pointer). Neither saying anything
means contract 1.

1. **Call `createSessionToken` once, first**, passing `clientName` (your agent's
   name — shown to the user in Service Studio's approval dialog). The result is a
   token string. The call waits until the user answers that dialog, and you get no
   signal that it is showing: **before calling it, tell the user to approve the
   request in Service Studio**, and if it hasn't returned after a few seconds, remind
   them that the dialog may be behind other windows. Keep it for the whole agent session and **reuse it after a
   reconnect** — never request a second one for the same session.
2. **Pass `sessionToken` as a top-level argument on every other call** —
   including `omlPublish`, `omlRefreshReferences` and `getRoleExceptions`:
   their schemas don't declare it, but send it anyway: each rejects a call without it ("This tool requires a valid session token"; `getRoleExceptions` verified 2026-10-01, `omlPublish` 2026-10-17). If your client refuses to send a parameter missing from the schema, ask the user to publish or refresh from Service Studio.
3. **Every tool except `listOpenModules` takes its arguments wrapped in `input`:**

```jsonc
// applyModelApiCode
{ "input": { "eSpaceName": "MyModule", "code": "eSpace => { … }", "imports": [] }, "sessionToken": "<token>" }
// listOpenModules (listApps on early contract 1 builds): the only tool with no input object
{ "sessionToken": "<token>" }
```

Full per-tool shapes: [`reference/verb-reference.md`](reference/verb-reference.md).

## 0.1 Choosing the module: `eSpaceName`, opening and closing

Use the tool names the server advertises. **Early contract 1 builds** list the open
modules with `listApps` (rows under `apps`) instead of `listOpenModules`, and have no
`searchApps`, `openModule` or `closeModule`. There, address a module by its row's
`tabId` when rows carry one, otherwise by `name`, and ask the user to open any module
that isn't open. Later contract 1 builds have some of these tools: see
[`reference/contracts.md`](reference/contracts.md).

1. **Call `listOpenModules`** and pass an open row's **`tabId`** as `eSpaceName`. Its
   `key` (stable across reopens) or `name` also work. A key or name open in several tabs
   fails with `MODULE_AMBIGUOUS`, whose message lists each candidate's `tabId`. Retry
   with one of them; don't guess. `isSelected` marks the tab in front of each Studio
   window, which is "this module". When several rows have it, ask the user which one.
2. **Not open?** `searchApps` (`input: { search, application, moduleType, environment }`,
   all optional) searches the environment Service Studio is logged in to, grouped by
   application. It returns at most 50 modules: narrow the search rather than paging.
   Its `isOpen` / `tabIds` show modules already open. When Studio's windows are logged in
   to several environments, it fails with `ENVIRONMENT_REQUIRED`: ask the user which one
   and pass it as `environment`.
3. **Open a module only when the user's request names it.** Pass its `key` from
   `searchApps` to `openModule` as `moduleKey`, and the same `environment` if you passed
   one to `searchApps`. If several modules match or none, ask the user and open nothing.
   On `status: "opening"`, call again with the same `moduleKey` and `environment`.
   On `opened` or `alreadyOpen`, use the returned `module.tabId`. Tell the user which
   module you opened.
4. **Close what you opened** with `closeModule` (`eSpaceName` = its `tabId`) when you are
   done, and before opening more in a long task, because a window holds 12 tabs. It refuses
   a module the user opened. After a merge, tell the user first that Studio will ask them
   to save. On `status: "closing"`, call again.

Statuses, refusals, waits and errors: [`reference/module-discovery.md`](reference/module-discovery.md).

## 1. The full-lambda contract — read this first

The `code` argument you pass to `applyModelApiCode` is a **full
`Action<IESpace>` lambda** — `eSpace => { … }` — but **without** the
`eSpace.Save(...)` call. The host rewrites your lambda before forwarding it to
the bundled sidecar's `applyModelApiCode` verb: it strips the trailing `}`
from your `code`, appends `eSpace.Save("<host-allocated-path>")`, and
re-closes the lambda. Specifically:

```csharp
// what the host literally builds
<your code, minus its final '}'>
eSpace.Save("<host-allocated-out-path>");
}
```

So when you call the tool, pass the complete lambda **ending in `}`**, with no
save:

```jsonc
// GOOD — full lambda, ends in '}', no Save call.
{
  "code": "eSpace => { var key = eSpace.Key.CreateNewKeyBasedOnThis(new object[] { \"Customer\" }); eSpace.CreateServerEntity(\"Customer\", key); }"
}
```

```jsonc
// BAD — calls eSpace.Save yourself. The host appends its own Save against a
// host-controlled path; yours is redundant, and because the host strips your
// final '}' the wrap can end up malformed.
{
  "code": "eSpace => { eSpace.CreateServerEntity(\"Customer\", key); eSpace.Save(\"out.oml\"); }"
}
```

```jsonc
// BAD — body-only statements, no 'eSpace => { ... }' wrapper. The host strips
// your last character and appends 'eSpace.Save(...);}', producing a dangling
// '}' with no lambda head → the compiler rejects it. (This was the OLD contract;
// it is now inverted.)
{
  "code": "eSpace.CreateServerEntity(\"Customer\", key);"
}
```

Four rules follow directly from how the host rewrites your code:

1. **Pass a full `eSpace => { ... }` lambda.** The host no longer wraps a bare
   body — it only injects the save and re-closes. A body-only snippet leaves a
   dangling `}` and fails to compile.
2. **Use the literal identifier `eSpace`** for the parameter. The injected
   `eSpace.Save(...)` is hardcoded to that name — `m`, `app`, `model`, or
   anything else fails with `CS0103: The name 'X' does not exist in the current context`.
3. **Your `code` must end with `}` and nothing after it** — no trailing
   newline, whitespace, or semicolon. The host removes the **last character**
   assuming it is the closing brace; a stray character there corrupts the wrap.
4. **Do NOT call `eSpace.Save(...)`.** The host appends one against a path it
   controls. The agent never names the output path.

Full discussion of the wrap mechanics + the silent-no-op trap:
[`reference/lambda-contract.md`](reference/lambda-contract.md).

## 1.1 The code sandbox

The host screens `code` and `imports` **before compiling** and rejects anything
outside the OutSystems Model API with a tool error:

- **`code`** must not mention `Console`, any `System.…`-qualified name
  (`System.Text.StringBuilder`, `System.Enum.GetNames`, …), or reflection
  (`GetProperties`, `GetProperty`, `GetMethod`, `Invoke`, …) — nor file, process, environment,
  registry, interop or network access. → `'code' must only reference the
  OutSystems Model API … (found 'X')`. Unqualified basics still work: `List<T>`,
  `Exception`, `string.Join`, LINQ, `Action<…>`, `obj.GetType().Name`.
- **`imports`** may only contain `OutSystems.Model` or its sub-namespaces →
  otherwise `Import 'X' is not allowed`. Write other types fully qualified in the
  code instead — `ServiceStudio.Plugin.NRWidgets.IInput` and
  `ServiceStudio.Plugin.RESTService.IRestService` are allowed there.
- Service Studio's internal `ServiceStudio.Model.*` types are not available.
- The pre-parser rejects C# 12 **collection expressions** (`[a, b]`) with
  `'code' is not valid C#: Invalid expression term '['` — write `new[] { a, b }`.

**To see values, throw them.** There is no `Console` output any more. Build a
string and end the lambda with `throw new Exception("PROBE:" + s);` — the text
comes back verbatim in `exceptionMessage`, nothing is saved, the session
pointer does not move, and `validationMessages` for the in-memory model are
**still returned** — so a throw-probe also previews TrueChange for an edit
without committing it. Like any `applyModelApiCode` call, a probe needs an open edit
session (§ 2.1). Template: [`examples/ProbeModelWithException.cs`](examples/ProbeModelWithException.cs).

Older recipes that reached members by reflection have typed replacements;
see [`reference/lambda-contract.md`](reference/lambda-contract.md) § "Sandbox".

**Reading an existing expression's text** (verified 2026-10-01): call `ToString()`
on any expression property (`widget.Value`, `widget.Visible`, `image.ImageContent`,
or a block-instance `arg.Value`). It returns `"<expression text> [Value[…]]"`;
cut the string at the first `" ["`. With this you can rewrite existing expressions
in place: read the text, transform it, then call `SetValue`, `SetArgumentValue` or
`SetVisible`. Run a probe that prints a few values first, because the suffix
differs by property (`[ValueExpression[…]]`, `[Visible[…]]`).
`obj.GetType().GetInterfaces()` also passes the sandbox. Use it to find which
interfaces a widget actually implements when a cast or member fails to compile.
It is the only reflection call that passes — `GetProperties` is still rejected.
To list a type's settable members, read its interface in [`docs/`](docs/)
(e.g. `IInput` in `docs/ServiceStudio.Plugin.NRWidgets.Generated.cs`).

## 2. Reading before writing

Before mutating an OML, **always** call `getDataModel` first. Its output is the
existing data model rendered as the same Model API dialect you have to emit —
pattern-match against it.

**To get oriented, or to answer a read-only question about the whole module, run the
inventory probe first:** [`examples/ProbeModuleInventory.cs`](examples/ProbeModuleInventory.cs).
One throw-probe returns entities with attribute types, structures, screens per flow with
their roles, server actions with folders, client actions, roles, integrations and
references, plus the module's TrueChange messages. Verified 2026-10-17: a 17-entity,
15-screen module came back as ~5.6k characters, where `getDataModel` alone was ~113k and
too large to return inline. Then drill in with the `get*` tools only where the question
or the edit needs detail. A module summary built from one getter per element took over
11 minutes and 28 calls in testing.

> **A throw-probe is a read, even though it goes through `applyModelApiCode`.** It
> saves nothing, the session pointer doesn't move, and the module is untouched (§ 1.1).
> Use it when the user says "don't change anything". It still needs an edit session
> (§ 2.1), so a read-only task runs `startOmlEditSession`, the probe, then
> `endOmlEditSession` (expect `discardedChanges: false`), and gives the Beta notice for
> those session calls. If `startOmlEditSession` says a session is already open and you
> didn't start it, don't probe inside it, because it would read that session's working
> copy rather than the live module, and don't end it. The sidecar `get*` reads show that
> same working copy (§ 2.1), so they can't give a live summary either. Tell the user a session
> is open, and ask them how to resolve it before you summarise. In testing, an agent told "don't change anything" avoided `applyModelApiCode`
> altogether and fell back to one `getScreen` per screen: 36 calls for a summary the
> inventory probe returns in one. For a structured summary (names, types, counts,
> roles), the probe plus at most two or three follow-up reads is the budget. Call
> `getScreen` and similar only when the user asks for screen-level detail.

| Tool | When to use |
|---|---|
| `getDataModel` | Entities, attributes, foreign keys, identifier attributes (this module + entities reachable through references) |
| `getStructures` | All structures and their attributes |
| `getActionNames` + `getServerAction` / `getClientAction` / `getServiceAction` | `getActionNames` takes `objectType: "server" \| "client" \| "service"` and lists the module's actions, including those inside folders, plus referenced ones (`IsReferenced: true`). Then fetch one by name |
| `getScreenNames` + `getScreen` | Screen layout, widgets, screen actions |
| `getWebBlockNames` + `getWebBlock` | Web blocks |
| `getRoleNames` + `getRole` | Roles |
| `getClientVariables` / `getSessionVariables` / `getSettings` | Collection-only reads |
| `getEvents` / `getEventHandlers` / `getIntegrations` / `getTimers` / `getUserExceptions` / `getRoleExceptions` / `getLocales` | Other top-level element collections |
| `getException` / `getImage` / `getResource` / `getScript` / `getEmailTemplate` / `getExternalSite` / `getTheme` | Single named element |
| `getSerializedObject` / `getSerializedObjectByKey` / `getSerializedObjectByNameAndType` | Raw JSON serialization of an object (by current pointer, by key, or by name + fully-qualified type) |
| `getObjectByCompoundKey` | **You already hold a compound key** (an object address) for a screen action, which has no tool of its own, or for something nested inside a screen, block or action (a widget, variable, aggregate or node): read that one object instead of its owner. A key for a screen, block, role, server, client or service action, or anything else that has a tool of its own: use that tool |
| `getReferrers` | **What uses an element in this module**, before you delete or rename it. `name` + `type` list every caller and consumer. Empty means nothing in this module: a Public element can still be used by other modules |
| `getDataExposure` | **What reaches the browser**, for a security or data-exposure audit: every aggregate, SQL query, data action and variable with the entities and attributes it exposes, grouped by entity. `includeServerSide` adds server-side aggregates and session variables. For an audit pass `includeServerSide: true`: the default leaves out the aggregates and SQL queries inside server actions, yet a server action that a client action calls sends its outputs to the browser. A starting point, not the audit: review by hand every source with `resolutionFailed: true` (`unresolvedCount` above 0) and every SQL query, which reports only its output entities |
| `runQuery` | Generic ModelQL query against the eSpace — use when no specific read tool fits. Query always starts with `Root { … }` |
| `getValidationMessages` | TrueChange validation messages against the current pointer's OML; optional `filter` of `info` / `warning` / `error` |
| `listOpenModules` | The open modules (one row per tab, with `tabId`), each with `moduleType` (see § 4.1). `listApps` on early contract 1 builds |
| `searchApps` | The environment's modules, open or not, grouped by application (§ 0.1) |

Every read tool except `getReferrers` and `getDataExposure` goes through the sidecar.
Without an edit session, those reads snapshot the live module and reuse that snapshot while
the module is unchanged. While an edit session is open, they read its working copy instead
(§ 2.1). `getReferrers` and `getDataExposure` run inside Service Studio on the live module:
they take no snapshot, are safe in parallel, and miss your unmerged applies, so run them
before editing or after `omlMerge`. See
[`reference/mcp-session-pointer.md`](reference/mcp-session-pointer.md).
Full catalogue with input shapes: [`reference/verb-reference.md`](reference/verb-reference.md).

> **Outside an edit session, read one module one call at a time** (the sidecar reads;
> `getReferrers` and `getDataExposure` take no snapshot). A read that finds
> no usable snapshot writes a new `<runId>-in.oml` and deletes the previous one. That
> happens on the first read after `openModule` or `endOmlEditSession`, and after the
> user edits the module. Reads fired in parallel at that moment delete each
> other's files, and all but one fail with `OML not found: …\ServiceStudio.MCPServer\<runId>-in.oml`
> or `Could not find file '…-in.oml'`. Verified 2026-11-19: three of four parallel
> reads right after `openModule` failed, and each passed when run on its own. The
> error says nothing about your call: run the failed read again, alone. Inside an
> edit session, reads reuse the working copy and don't delete anything, so parallel
> reads are safe there.

> **A compound key a tool already gave you is the cheapest way back to that object.**
> Compound keys are object addresses, such as
> `/NRWebFlows.15JknNSso0m4DVQpt5JV6w/NodesShownInESpaceTree.p6XvuJYzsUGg8zneWK7lbg/Widgets.fNPE_tNqcUiapRRopGTB3g`
> (a widget). `getReferrers` returns one for nearly every referrer, addressing the nearest
> element that contains the reference. By the referrer's `kind`: a screen, block, role, or
> server, client or service action, read it with its own tool, using `name` (a Traditional
> screen or block: `getScreenTraditional` / `getWebBlockTraditional`); a screen action, which
> has no tool, or anything nested (a widget, variable, aggregate or node), pass the key to
> `getObjectByCompoundKey` (Model API code, not JSON); no `compoundKey`, use `name` and
> `location`. Inside an edit session the key comes from the live module but
> `getObjectByCompoundKey` reads the working copy, so an object you changed or deleted in the
> session, or one the user added after it started, may come back edited or not be found.

> **`includeJson` is a required argument on the code-returning read tools**
> (`getDataModel`, `getStructures`, the `get<Element>` by-name reads, etc. —
> anything whose input is `GetModelObjectCodeInput` / `GetModelObjectByNameCodeInput`).
> Its declared values are `"Never"`, `"Always"`, `"IfReferenced"`, but **the
> host overrides whatever you send and forces `"Never"`** before calling the
> sidecar — so the value is effectively ignored, yet the field must still be
> present or the MCP call fails to deserialize. **Always pass `"Never"`.** The
> name-list tools (`getScreenNames`, `getRoleNames`, …), `listOpenModules`,
> `searchApps`, `runQuery`, `getValidationMessages`, `getReferrers`, `getDataExposure`
> and `getObjectByCompoundKey` take no `includeJson`. By-name reads
> (`getServerAction`, `getScreen`, …) name the element with `objectName`.

> **Read-back code is not replayable verbatim.** `getDataModel` and friends emit
> referenced elements as `eSpace.AddDependency(Services.ModelServices.ParseGlobalKey(…))`
> lines, but `AddDependency` throws inside `applyModelApiCode` even for an
> already-resident element (§ 8). Copy the *shape* of the calls, and resolve
> referenced elements through `eSpace.References.Named("…")`.
>
> **Read-back is creation code, so never replay it to edit.** `getServerAction`
> returns an existing action as `eSpace.CreateServerAction("X")` plus a `Folder =`
> line. Running that adds a second action. To change an existing element, look it up
> and mutate it in place: `eSpace.ServerActions.Named("X")`, which also finds actions
> inside folders. Verified 2026-10-17: `CreateServerAction("DoLogout")` on a module
> that already had `DoLogout` in a folder silently produced `DoLogout2` with
> `Folder == null`, and TrueChange did not flag the duplicate. See
> [`reference/patterns-by-element.md`](reference/patterns-by-element.md) § "Editing an
> existing element".

## 2.1 The edit session: start it before the first write

**`applyModelApiCode` only runs inside an edit session.** Without one it fails with
`No OML edit session is started. Call startOmlEditSession before making edits.` A
mutating task goes:

1. **`startOmlEditSession`**: `{ "input": { "eSpaceName": … }, "sessionToken": … }`
   → `{ "started": true }`. It checks out a **working copy** of the module. Call it
   once per module, after the reads that tell you what to change and before the first
   `applyModelApiCode`.
2. **`applyModelApiCode`**, as many times as the task needs (§ 3). Each clean call
   builds on the working copy and returns a new `mutatedOmlPath`.
3. **`omlMerge`** the latest `mutatedOmlPath` (§ 3.1). **A merge doesn't end the
   session.** After `merged: true` the working copy is still checked out: the next
   apply builds on it and returns a new path to merge.
4. **`endOmlEditSession`**: `{ "input": { "eSpaceName": … }, "sessionToken": … }`
   → `{ "ended": true, "discardedChanges": false }`, once the last merge returned
   `merged: true`. It deletes the working copy, so reads see the live module again.
   `discardedChanges: true` means edits applied after the last merge were thrown away,
   and they can't be recovered (verified 2026-11-19: `false` after a session whose
   edits were all merged).

**While the session is open, reads show the working copy**: the module as it was at
step 1, plus your applies. They never show the user's later edits in Service Studio.
Reading again doesn't refresh it, and neither does a merge. Only ending the session
and starting a new one does.
`getReferrers` and `getDataExposure` are the exception: they read the live module, so they
miss your unmerged applies. Run them before editing, or after `omlMerge`.

**One session per module, shared by every caller.** The session lives in Service
Studio, not in your conversation or your token. When one is open, `startOmlEditSession`
fails with `An OML edit session is already started for this module. Call
endOmlEditSession before starting a new one.` It may have been left by an earlier
conversation or another agent, and its working copy may hold unmerged edits that
`endOmlEditSession` would discard. If you didn't start it in this conversation, ask
the user before ending it, and don't apply on top of it.

**End the session before closing the module.** `closeModule` refuses a module with an
open session (§ 0.1).

**Discarding can't be undone.** `endOmlEditSession` and `omlReset` both throw away
unmerged edits for good (§ 3.1). If the user might want the work back, merge it first.

## 3. The `applyModelApiCode` invocation shape

Start an edit session on the module first (§ 2.1).

```jsonc
// agent → MCP server (call tool applyModelApiCode)
{
  "input": {
    "eSpaceName": "MyModule",
    "code":    "eSpace => { /* statements that mutate eSpace */ }",
    "imports": ["OutSystems.Model.Data"]   // required field; may be []; OutSystems.Model.* only (§ 1.1)
  },
  "sessionToken": "<token from createSessionToken>"
}
```

What the host does behind that call:

1. Takes the edit session's working copy (§ 2.1) as input: the module as of
   `startOmlEditSession`, plus your earlier clean applies.
2. Allocates `<runId>-out.oml` as the save destination.
3. Rewrites your lambda — strips the trailing `}`, appends
   `eSpace.Save("<runId>-out.oml")`, re-closes — and forwards it (plus merged
   `imports` and the input path) to the sidecar's `applyModelApiCode` verb over
   stdio JSON-RPC.
4. If the out file was written and no exception was reported, makes the out
   file the new working copy (the session pointer), so the next read and the
   next apply see your change.

Response (returned directly as the tool result):

```jsonc
{
  "exceptionMessage":   "",  // string — runtime error text; non-empty means the code compiled and ran but threw, so nothing was saved
  "stdoutOutput":       "",  // string — captured stdout (your code cannot write to it: Console is sandboxed out, § 1.1)
  "stderrOutput":       "",  // string — captured stderr (host log lines, e.g. "Action Flow auto arrange completed")
  "validationMessages": [],  // ValidationMessage[] — TrueChange errors/warnings against the resulting model; non-empty does NOT mean the save failed
  "mutatedOmlPath":     ""   // string — path to the saved OML on a clean run; "" when nothing was saved. Hand it to omlMerge (§ 3.1).
}
```

Each `validationMessages` entry is an object, not a line of text:

```jsonc
{
  "id":        "",  // string — identifier of the validation rule
  "type":      "",  // string — "Info" | "Warning" | "Error" (capitalised) ← branch on this, case-insensitively
  "message":   "",  // string — short description
  "detail":    "",  // string — long form
  "ownerKey":  "",  // string — key of the element the message is about
  "ownerPath": "",  // string — readable path to that element
  "ownerType": ""   // string — that element's kind
}
```

> **`mutatedOmlPath` is populated only on a clean save** (no exception and the
> out file was written); it is `""` otherwise. It is your success signal and the
> path you hand to `omlMerge` (§ 3.1). There is still no `hasValidationErrors` /
> `validationErrorCount` field, but you no longer scan text for it — filter
> `validationMessages` on `type` equal to `"Error"` (case-insensitive). Runtime failures surface through
> `exceptionMessage` (or, if the sidecar returns a JSON-RPC error envelope, as
> an MCP tool error such as `OML_TOOL_VERB_FAILURE` / `OML_TOOL_PROTOCOL_ERROR`).
> **There is no `compilationErrors` field.** Code that does not compile never
> ran, so it comes back as an **MCP tool error** (`OML_TOOL_CODE_REJECTED`)
> rather than as a result — the compiler diagnostics are in that error's
> message, one per line, each prefixed `compilationErrors:` (or
> `restrictionErrors:` in the restricted sandbox):
>
> ```
> [-32602] Script compilation failed
> compilationErrors: (2,20): error CS1061: 'IESpace' does not contain a definition for 'NoSuchModelApiMember'
> ```
>
> Long diagnostic sets are truncated at 4000 characters with a trailing note
> giving the total count. Saved-but-invalid models surface as a clean result
> whose `validationMessages` contains a `type: "Error"` entry.

> **`OML_TOOL_HOST_FAILURE` (`[Error -32099] Oml Tool cannot be used outside
> OutSystems Service Studio.`) is NOT a code problem — do not retry or rewrite
> the lambda.** It only runs under an official (signed) Service Studio; surface
> it as an environment/deployment issue, not a flaw in your Model API code.

**Outcome table:**

| Outcome | Channel | `exceptionMessage` | `validationMessages` | `mutatedOmlPath` | Session pointer |
|---|---|---|---|---|---|
| Clean run | result | empty | `[]` (or warnings only) | path | advances |
| Runtime exception failure | result (or an MCP tool error) | populated | — | `""` | unchanged |
| **Compile error failure** (malformed C#) | **MCP tool error** — no result at all | — | — | — | unchanged |
| **Sandbox rejection** (`Console`, `System.…`, reflection, or a non-`OutSystems.Model` import — § 1.1) | **MCP tool error** — no result at all | — | — | — | unchanged |
| **Throw-probe** (deliberate `throw new Exception("PROBE:…")`, § 1.1) | result | your probe text | in-memory model's messages | `""` | unchanged |
| **Silent no-op** (lambda compiles + saves but never touches `eSpace` — e.g. `eSpace => { var n = eSpace.Name; }`) | result | empty | `[]` | path | advances — but to an **unmodified** OML |
| **Saved but invalid** (clean compile + save, but the model has a TrueChange error) | result | empty | has a `type: "Error"` entry | path | advances — but to an **invalid** OML |
| **Runner process-crash** (an unsupported API member kills the sidecar mid-run) | result | **empty** | `[]` | `""` | unchanged |

> **⚠️ The process-crash row wastes the most time.** An unsupported API member
> kills the sidecar mid-run, giving **empty everything**, so a throw-probe at
> the end never reports. Some clients surface it instead as a process-exit
> error ("exited with code 2", no stdout); treat that the same way. Unlike a runtime
> failure (which populates `exceptionMessage`) or a compile failure (which
> never reaches the result channel at all), a crash is silent on
> every channel; it is **not** "no module open." Recovery: bisect, don't
> re-read your code — `eSpace => { throw new Exception("PROBE:ok"); }` coming
> back with `PROBE:ok` proves the session is
> healthy, then re-issue with one risky member per call until it dies. Full
> treatment + known crash members: [`reference/lambda-contract.md`](reference/lambda-contract.md).

The **silent no-op** is the only outcome where the response looks "successful"
but the OML wasn't actually mutated. Defend against it by always actually
mutating `eSpace` in the lambda body and by reading the result back via
`getDataModel` (or the matching `get*`) after mutating — if your change isn't
there, the lambda never touched `eSpace`.

**Saved-but-invalid is the second deceptive outcome.** A lambda can compile,
mutate `eSpace`, and save — so `exceptionMessage` is empty and the pointer
advances — while the saved model still contains a TrueChange **error**.
**Always check `validationMessages` for a `type: "Error"` entry even when the
run looked clean** — a non-empty array alone isn't enough, since
warnings-and-info-only messages are normal. A frequent trigger: hard-coding an
aggregate name the host silently auto-renamed after a navigation-style filter
was added to a default-named aggregate. Recovery recipes:
[`reference/patterns-by-element.md`](reference/patterns-by-element.md) §§
"Recovering from a saved-but-invalid action" and "Aggregate in a server
action (auto-rename trap)".

Use the response as your recovery signal: a `CS1061` in the tool error's
diagnostics means a wrong method/property name; a `type: "Error"` entry in
`validationMessages` means the validator caught something. Traditional-Web widget errors (`CS0104`, `CS0311`) have
targeted fixes in [`reference/traditional-ui-creation.md`](reference/traditional-ui-creation.md);
pointer mechanics in [`reference/mcp-session-pointer.md`](reference/mcp-session-pointer.md).

**Don't silently substitute when creation fails.** If the widget or element the user
asked for won't create, for example a Traditional `ITableRecordsWidget`, fix the error
against the docs and the verified recipes. Swapping in something else (a ListRecords
instead of a table) without saying so is not an acceptable fallback. If you can't fix
it, stop and report the failure along with the alternative you propose. The
Traditional table recipe is in
[`reference/traditional-ui-creation.md`](reference/traditional-ui-creation.md) § "Recipe 5b".

## 3.1 Finalising — auto-merge after the last mutation

**Once the final `applyModelApiCode` call that satisfies the user's request
returns a non-empty `mutatedOmlPath` — and every touched flow has cleared the
layout completion gate below — call `omlMerge` with that path.** This is the
default closing step of any task that mutates the OML — do it without being
asked, but not before the gate passes (see "Flow layout is a completion gate"
below; merging a visually tangled flow is not "done"). Without it the
host-allocated out OML stays on disk and the user never sees the diff in
Service Studio.

```jsonc
// call tool omlMerge — last action of any mutating task
{ "input": { "eSpaceName": "<the module you mutated>", "mutatedOmlPath": "<the most recent non-empty mutatedOmlPath>" }, "sessionToken": "<token>" }
// → { "merged": true, "message": "..." }
```

> **`merged` is the definitive, final success signal — not just "a window opened."**
> Whether the merge opens Service Studio's Compare-and-Merge window for the user
> or is accepted with no dialog is the **user's setting**, not something you pass
> or can influence. Either way the call returns only once the merge has resolved,
> and `merged: true` means it is **done** — the change is in the module. Always
> check that field rather than inferring success from the call returning. Do not
> re-call `omlMerge` with the same `mutatedOmlPath` "to be sure". Trust `merged` on
> the first response and stop.

> **`eSpaceName` is required**, same as `omlReset` — it decides which open module the
> mutated OML is compared against. Omitting it fails the call.
>
> **Envelope note.** Like every tool except `listOpenModules`, `omlMerge` takes its
> arguments inside `input` plus the top-level `sessionToken` (§ 0):
> `{ "input": { "eSpaceName": ..., "mutatedOmlPath": ... }, "sessionToken": ... }`.

`omlMerge` merges the supplied OML into the named module and blocks until that
resolves. Depending on the user's setting, it either opens the Compare-and-Merge
window for them to review — which may take minutes — or accepts the changes with
no dialog and returns right away. For a review, Studio brings the module's tab to the
front so the window shows, so tell the user a merge is waiting for them. A merged module
has unsaved changes in Studio: closing it (§ 0.1) makes Studio ask the developer to save.

**A merge doesn't end the edit session or reset its working copy** (§ 2.1). After
`merged: true` you can keep applying, and each new `mutatedOmlPath` is merged the
same way. That makes an intermediate merge a safe checkpoint on a long task. Once the
last merge returns `merged: true`, call `endOmlEditSession`.

**`merged: true` doesn't mean the user kept everything.** They can leave some of your
changes out in the Compare-and-Merge window. The working copy keeps those changes, so
your next merge proposes them again. If the user says they left something out, end the
session and start a new one before you continue.

Nothing is lost when a merge doesn't succeed: the working copy still holds your
edits. Merge the same path again only after a passing refusal, such as Studio being
busy. If the user cancelled the merge, ask them how to proceed. If you fix the cause
with another apply, merge the new `mutatedOmlPath`. See
[`reference/mcp-session-pointer.md`](reference/mcp-session-pointer.md) for each
`message`, and the failed-merge recovery below.

> **After an automatic merge, an open flow canvas does not redraw** (verified
> 2026-10-17). The model is updated — the properties panel and expression editor show
> the new values — but the canvas keeps drawing old labels until the user navigates
> away and back. Mention this when the user has the changed flow open.

> **`merged: false` with "The merge failed. See the log for details."** The real
> reason appears only in a Service Studio dialog. No log file is written that you
> can read. Do not retry with the same file.
>
> 1. Ask the user what the dialog says.
> 2. `endOmlEditSession`, then `startOmlEditSession` again for a fresh copy of the live module.
> 3. Re-apply the changes, without whatever caused the failure.
> 4. Merge the new `mutatedOmlPath`.
>
> **Known cause (verified 2026-10-01):** setting `IMobileTheme.IconLibrary`. Contract 1
> builds ([`reference/contracts.md`](reference/contracts.md)) can reject the whole merge with *"Update Service Studio to merge
> the module. The feature Theme Icon Library is not supported in this version."*
> The trap: editing `Theme.StyleSheet` makes the sidecar report an `InvalidIconLibrary`
> error ("Allowed libraries are: FontAwesome4.0, Phosphor2.0"), and setting
> `IconLibrary` to clear it is what breaks the merge.
>
> **What works (verified 2026-10-03, 3 of 3 edits):** edit `Theme.StyleSheet`, leave
> `IconLibrary` null, and **ignore that one sidecar error**. The error comes from the
> sidecar's newer validator. Service Studio's own validation of the merged module is
> clean, `omlMerge` returns `merged:true`, and every theme stylesheet edit published:
> the served `css/<App>.<Theme>.css` changed hash each time. That includes repeated
> edits of a non-empty theme stylesheet, which block stylesheets did not handle reliably
> (§ 8). **The theme is the preferred place for app-wide CSS.** Treat
> `InvalidIconLibrary` as expected when the only change is the theme stylesheet. Any
> other Error still blocks the merge.
>
> **Two traps when appending to the theme stylesheet (verified 2026-10-03):**
> 1. **The first 2 characters after the Theme Editor block are dropped.** That block
>    ends with the `:root { … }` written by Theme Editor. Whatever you append right after
>    it loses 2 characters, probably from a line-ending normalisation. A leading `/*` is
>    lost, which leaves a stray `… */`, which then silently kills the next rule; in our
>    case that was the whole `:root` token block. Start your section with a throwaway
>    guard rule, e.g. `.ro-theme-start { }`, and avoid `/* =====` banners, which Theme
>    Editor uses for its own markers.
> 2. **The theme loads on every screen, including Login and other blank-layout pages.**
>    CSS moved from a layout block (loaded only on screens using that layout) or from a
>    single screen now applies everywhere. Scope page-specific rules, e.g.
>    `body:has(.login-screen) …`, and check the blank-layout pages after moving CSS.
>    OSUI's blank layout uses the classes `.layout.blank`, not `.layout-blank`.

### Flow layout is a completion gate — do it before you merge

**Every action (server or client) that gained new or spliced nodes must be laid out**
before the task counts as complete. How depends on who drew the flow:

- **A flow you created in this task** gets the **full layout pass**:
  - a branch-aware walk from the Start node that places each If, Switch and For Each
    branch in its own column and puts merge points below their deepest branch;
  - `Connected*` helpers preferred over setting `Target` by hand;
  - a splice-link read-back;
  - a final check that no two nodes share a grid cell and no forward edge points upward.
- **An existing flow you edited keeps the developer's layout. Don't re-run the full
  pass on it**, because that would rearrange their branches. Insert locally: shift every
  node at or below the insertion row down by one row of the flow's own spacing, put the
  new node in the freed slot, wire it, and check that no two nodes share a cell
  (verified 2026-10-17). Recipe: [`reference/model-api-tips.md`](reference/model-api-tips.md)
  § "Inserting into an existing flow".

A flow that is logically correct but visually tangled
is not done; treat this as a hard precondition of the auto-merge above, not
an optional polish step. The host's own "Action Flow auto arrange" (logged on
stderr) does **not** position hand-wired nodes. Full mechanics: [`reference/model-api-tips.md`](reference/model-api-tips.md)
§ "Manipulating Nodes in Logic Flows"; a ready typed layout lambda:
[`examples/LayoutActionFlow.cs`](examples/LayoutActionFlow.cs).

**Skip the auto-merge only when:**

- The task was read-only — no `applyModelApiCode` fired, so there is no
  `mutatedOmlPath`.
- The user asked you to discard the changes. Call `endOmlEditSession` instead.
- Every `applyModelApiCode` call returned `mutatedOmlPath: ""` (compile error,
  runtime exception, nothing saved) — there is nothing to merge.

In every case, end the session with `endOmlEditSession` when you are done with the
module. Failed `applyModelApiCode` calls don't need anything: the working copy stays
where it was.

**Discarding can't be undone.** `endOmlEditSession` deletes the working copy, along
with any edits that weren't merged. `omlReset` also ends the session and throws those
edits away. It leaves the file on disk, but `omlMerge` refuses it, because it only
accepts the working copy the module currently tracks
([`reference/mcp-session-pointer.md`](reference/mcp-session-pointer.md)). If the user
might want the work back, merge it before you discard. `omlReset` only acts when there
are unmerged edits: `discardedChanges: false` means it did nothing, and the session is
still open.

## 3.2 Refreshing references and publishing

Two host tools act on the **live** module in Service Studio, not on the pointer chain.
Their schemas don't declare `sessionToken`; send it anyway (§ 0):

- **`omlRefreshReferences`** — `{ "input": { "eSpaceName": … }, "sessionToken": … }` → `{ message, hasErrors, hasWarnings }`.
  Refreshes every reference to its latest version (Manage Dependencies → *Refresh All*).
  It does **not** add a new dependency. **Refresh outside an edit session.** If a session
  has unmerged edits, the refresh ends it the way `omlReset` does, and those edits are
  lost. If it has none, the session stays open on
  a working copy taken before the refresh, which lacks the refreshed references. So refresh
  before `startOmlEditSession`, or merge, `endOmlEditSession`, refresh, and start a new one.
- **`omlPublish`** — `{ "input": { "eSpaceName": … }, "sessionToken": … }`. 1-Click Publishes the open module
  and waits for the result. It needs a write permission the user grants in the MCP Server
  dialog; while that is withheld it returns status `blocked`. **Only call it when the user
  explicitly asks to publish** — never as an automatic closing step.
  Verified 2026-10-03: it publishes the **live** module (merge first; an unmerged chain is not
  published), it requires the session token, and it fails at once if the module isn't open
  (`MODULE_NOT_LOADED`; early contract 1 builds say "Module 'X' is not open in Service Studio. Open it
  before calling omlPublish."). A clean
  publish of a small module took 16 s and returned
  `{ "published": true, "status": "success", "reason": "", "messages": ["Uploading", "Compiling", "Deploying", "Done"] }`.
  Check `published` / `status`; `reason` explains a failure. When the user has not allowed
  **automatic merge and publish** in the MCP Server dialog it returns immediately, publishes
  nothing, and answers
  `{ "published": false, "status": "blocked", "reason": "Publishing requires a write permission the user has not granted. Ask the user to publish from Service Studio, or to allow automatic merge and publish in the MCP Server dialog.", "messages": [] }`
  (verified 2026-10-03). Then tell the user, and let them publish from Service Studio or change
  the setting. Don't retry.

## 4. Default imports

**Host-added defaults** (3, prepended automatically — don't list them in
`imports`): `OutSystems.Model.UI` (`IScreen`, `IBlock`, `IUIFlowNode`),
`OutSystems.Model.UI.Web` (Traditional Web: `IWebScreen`, `IWebBlock`,
`IWebFlow`), `OutSystems.Model.UI.Mobile` (Reactive/Mobile: `IMobileScreen`,
`IMobileBlock`).

The bundled sidecar additionally pre-imports `System`, `System.Linq`,
`OutSystems.Model`, `.Enumerations`, `.Expressions`, `.Factory`, `.Types` —
so `eSpace.WebFlows.SelectMany(f => f.Nodes).OfType<IWebScreen>()` and
`eSpace.MobileFlows.SelectMany(...).OfType<IMobileScreen>()` both compile
without any agent-supplied `imports`. Other **`OutSystems.Model.*`** namespaces
(e.g. `OutSystems.Model.Data`, `OutSystems.Model.Logic.Nodes`) may be passed via
`imports` — the host dedup-appends them after the defaults. **Nothing else is
accepted** (§ 1.1): never pass `System`, `System.Linq` (already pre-imported) or
`ServiceStudio.Plugin.*` — fully qualify those types in the code instead.
(`imports` is required on the wire; `[]` is fine.)

## 4.1 Module style support

OutSystems 11 modules come in three UI flavours — **Reactive Web**,
**Mobile**, and **Traditional Web** — plus Service / Library variants. The
in-process MCP Server surfaces the module's style on every `listOpenModules` row
(`listApps` on early contract 1 builds) and every `searchApps` module
via a `moduleType` field (values such as `Reactive`, `Mobile`,
`Traditional`, `ReactiveLibrary`, `MobileLibrary`, `TraditionalLibrary`,
`Service`, `Unknown` — `Reactive` verified live 2026-09-30).

Most `get*` verbs work uniformly across styles; a handful of UI-shaped reads
are **Mobile-bound** and return empty on Traditional modules — use the
`*Traditional` variant instead (`getScreenNamesTraditional`,
`getScreenTraditional`, …) whenever `moduleType` is `"Traditional"` /
`"TraditionalLibrary"`. `applyModelApiCode` itself is **fully style-agnostic**
— write Traditional mutations the same way you write Mobile ones, using the
`IWebScreen` / `IWebBlock` / `IWebFlow` family (host-default-imported, § 4)
in place of `IMobileScreen` / `IMobileBlock` / `IMobileFlow`.

Full style-detection payload shape, the complete `*Traditional` verb table,
and the Reactive-vs-Traditional interface/concept mapping (flow collection,
screen/block signatures, session vs. client variables, …):
[`reference/module-style-support.md`](reference/module-style-support.md).

## 5. Common patterns (pointers)

The lambda sketches for each element type — server entity, attribute,
client/server action, screen + widget, node positioning in flows — live in
[`reference/patterns-by-element.md`](reference/patterns-by-element.md).
Read that first; pattern-match against the snippet that fits your task,
then verify with `getDataModel` after applying.

For building a **Reactive Web** screen from scratch — layout scaffold, KPI tiles
from the `Card` block, data-bound `List` rows, dynamic inline styles / CSS-bar
charts, and the real-chart-vs-fallback decision — see
[`reference/reactive-ui-creation.md`](reference/reactive-ui-creation.md) (Traditional Web UI creation is
the separate [`reference/traditional-ui-creation.md`](reference/traditional-ui-creation.md)).

Full worked C# examples: [`examples/`](examples/). Each file is **already** a
full `eSpace => { ... }` lambda with no `eSpace.Save` — exactly the shape the
`code` arg wants. Use the lambda verbatim and lift the file's `using`
directives (all `OutSystems.Model.*`) into `imports`. The
[`examples/odc-workflows-unsupported-on-o11/`](examples/odc-workflows-unsupported-on-o11/)
subfolder holds ODC Workflows examples that are **not** usable on O11 — for
O11 BPT use [`examples/AddProcessWithHumanActivity.cs`](examples/AddProcessWithHumanActivity.cs) (§ 8).

## 6. Where to dig deeper

| Topic | File |
|---|---|
| Full-lambda contract, host wrap mechanics, CS0103 / silent-no-op trap | [`reference/lambda-contract.md`](reference/lambda-contract.md) |
| Naming gotchas (eSpace vs Module, IMobile* vs UI, Signature types) | [`reference/model-api-tips.md`](reference/model-api-tips.md) |
| Model API namespace catalogue | [`reference/model-api-summary.md`](reference/model-api-summary.md) |
| MCP tool surface (`applyModelApiCode`, the `get*` read tools, `runQuery`, `listOpenModules`, `getValidationMessages`, host-only `omlReset` + `omlMerge`) | [`reference/verb-reference.md`](reference/verb-reference.md) |
| Choosing `eSpaceName` (`tabId` / `key` / `name`, `MODULE_AMBIGUOUS`), `listOpenModules`, `searchApps`, `openModule` / `closeModule` statuses, waits and refusals, early contract 1 builds' `listApps` | [`reference/module-discovery.md`](reference/module-discovery.md) |
| MCP contract numbers, and what differs on a server older than this skill's contract | [`reference/contracts.md`](reference/contracts.md) |
| Session pointer mechanics, `omlReset`, `omlMerge`, `mutatedOmlPath` | [`reference/mcp-session-pointer.md`](reference/mcp-session-pointer.md) |
| Module style detection payload, full `*Traditional` verb table, Reactive-vs-Traditional interface mapping | [`reference/module-style-support.md`](reference/module-style-support.md) |
| Lambda sketches per element type (entity, attribute, action, screen, node positioning); **grouped-aggregate reference-by-alias trap**; **silent renames**, default nodes per action kind, screen access (Anonymous role, role gating) | [`reference/patterns-by-element.md`](reference/patterns-by-element.md) |
| **Logic beyond basic flows** — SQL (advanced query) nodes, For Each, exception handlers, exposed REST APIs, email sending, timers, site properties, locales, **O11 BPT processes** (`CreateProcess`, human/automatic activities, decisions) — verified recipes + what TrueChange does and doesn't catch | [`reference/logic-and-integrations.md`](reference/logic-and-integrations.md) |
| **Reactive Web** UI *creation* (screen scaffold, block/placeholder instancing, KPI tiles from `Card`, `List` rows, data-bound inline styles via `CreateExtendedProperty`, CSS-bar chart vs `OutSystemsCharts` dependency) | [`reference/reactive-ui-creation.md`](reference/reactive-ui-creation.md) |
| **Reactive Web** verified widget-creation API (`IList`, `IDropdown`, `IIfWidget`, block instances, screen scaffolding, joins, M2M toggle, role checks) **plus the runner-crash traps** — read before writing widget code | [`reference/reactive-widget-api.md`](reference/reactive-widget-api.md) |
| **Reactive Web** OutSystemsUI verified block catalog (~45 blocks: `Gallery`, `CardSectioned`, `Counter`, `MasterDetail`, `Tabs`, charts …), per-archetype composition recipes, and the full design-token system with exact values | [`reference/osui-verified-blocks.md`](reference/osui-verified-blocks.md) |
| **Reactive Web** design-intent UX patterns (50+ layout / form / data / motion / mobile / accessibility patterns — pseudo-code for *what good UI looks like*, not literal API) | [`reference/styleguide-ui-patterns.md`](reference/styleguide-ui-patterns.md) |
| **Traditional Web** descent recipes (`eSpace.WebFlows`, `IWebScreen` / `IWebBlock`, `screen.ScreenActions`, session variables), per-style verb selection | [`reference/traditional-patterns.md`](reference/traditional-patterns.md) |
| **Traditional→Reactive migration cleanup** (what a migrated module looks like, the *data-actions-have-no-input-params* fact, the minimal-rebind repurpose-`OnStart`+`Refresh Data` conversion recipe, `GetUser`/dead-node/null-arg error fixes, and the migration-specific runner-crash traps) — read before touching a migrated module | [`reference/traditional-to-reactive-migration-cleanup.md`](reference/traditional-to-reactive-migration-cleanup.md) |
| **Traditional Web** UI *creation* (screen, block, widget tree, Preparation + Aggregate, ListRecords binding, `JavaScript` hook; CS0104 / CS0311 prophylaxis) + the Web interface catalogue | [`reference/traditional-ui-creation.md`](reference/traditional-ui-creation.md), [`docs/OutSystems.Model.UI.Web.Generated.cs`](docs/OutSystems.Model.UI.Web.Generated.cs), [`docs/OutSystems.Model.UI.Web.Widgets.Generated.cs`](docs/OutSystems.Model.UI.Web.Widgets.Generated.cs) |
| Worked C# examples (already full `eSpace => { ... }` lambdas, no `eSpace.Save` — usable verbatim as `code`; their `using` directives map to `imports`) | [`examples/`](examples/) |
| Namespace doc files (interface/method signatures) plus `BuiltinFunctions.Generated.json` (the OutSystems expression-function catalogue — `Abs`, `Mod`, etc., used in aggregate filters and computed attributes, **not** C# methods callable from `applyModelApiCode`) | [`docs/`](docs/) |
| MCP host design choices & caveats — temp OML location & cleanup-on-restart, per-module tracking, per-connection approval, security scope, timeouts/port, on-demand server startup | [`reference/mcp-design-choices.md`](reference/mcp-design-choices.md) |

## 7. Integration walkthroughs

The supported Claude-Code-agent path is the Service Studio in-process MCP
Server. Start with [`integration-examples/01-add-entity-via-mcp.md`](integration-examples/01-add-entity-via-mcp.md)
— that's the canonical single-mutation walkthrough. The other transcripts cover recovery and pointer scenarios.

| Scenario | File |
|---|---|
| **Single-mutation MCP call (canonical)** | [`integration-examples/01-add-entity-via-mcp.md`](integration-examples/01-add-entity-via-mcp.md) |
| Compile-error / silent-no-op recovery loop | [`integration-examples/02-recovery-from-compile-error.md`](integration-examples/02-recovery-from-compile-error.md) |
| Multi-step edit (auto-chain via session pointer) | [`integration-examples/03-multi-step-edit.md`](integration-examples/03-multi-step-edit.md) |
| `omlReset` drop-and-restart walkthrough | [`integration-examples/04-oml-reset.md`](integration-examples/04-oml-reset.md) |
| **Traditional Web** read + mutate (style detection, local `*Traditional` verbs, Model-API-code output, single-lambda multi-mutation) | [`integration-examples/05-traditional-mutation.md`](integration-examples/05-traditional-mutation.md) |
| **FK to a System / referenced entity** (`User`) — resolve via `References.Named("(System)")` → `IServerEntitySignature` → `DataType = IdentifierType`, no `RefreshDependency` | [`integration-examples/06-fk-to-system-entity.md`](integration-examples/06-fk-to-system-entity.md) |

## 8. Known gaps

The MCP host wraps the bundled sidecar's verbs and adds the
host-only `createSessionToken`, `listOpenModules`, `searchApps`, `openModule`,
`closeModule`, `omlReset`, `omlMerge`, `omlRefreshReferences` and `omlPublish` tools.
Current gaps:

- **The generated [`docs/`](docs/) miss the O11 process (BPT) API.** It exists
  and works — `eSpace.CreateProcess` / `eSpace.Processes`
  (`OutSystems.Model.Processes.IProcess`) and the node types in
  `OutSystems.Model.Processes.Nodes` — but only a hand-verified summary is
  available: [`reference/logic-and-integrations.md`](reference/logic-and-integrations.md)
  § "BPT processes". Don't use `eSpace.CreateBusinessProcess`: that is the ODC
  Workflows API and fails on an O11 module (`Process objects can't be children
  of Module objects`); its old examples are parked in
  [`examples/odc-workflows-unsupported-on-o11/`](examples/odc-workflows-unsupported-on-o11/).
- **Translations can't be written.** `eSpace.GetOrCreateLocale(Culture.X)`
  creates a locale and `eSpace.ApplyToTextResources(...)` walks the text
  resources (read-only), but there is no typed API to set a translated value.

- **No `getModelApiDoc` / `getModelApiExamples` analogue.** The static
  [`docs/`](docs/) and [`examples/`](examples/) folders are your reference.
- **No `searchModel` equivalent.** The cross-element substring search tool was
  removed from the MCP host. Find elements by name via the matching `get*Names`
  list tool (or `getDataModel`/`getStructures`) and filter client-side, or
  write a targeted `runQuery` query instead.
- **No "rewind by N saves" verb.** The pointer only advances on success;
  `omlReset` drops the chain and re-snapshots the live module. There is no
  general undo, and a reset can't be undone either: `omlMerge` refuses the
  discarded copy.
- **Adding a new external / cross-module dependency is not supported.** A
  snippet referencing a not-yet-resident element (e.g.
  `eSpace.AddDependency(globalKey)` / `eSpace.RefreshDependency(globalKey)` for
  a Forge / system / external element) fails in the sidecar with `The event
  IModelServices.ResolveModuleSignature must be set first` — **even for an
  element that is already referenced**. Add the dependency in Service Studio
  (Manage Dependencies) first, then re-run. Referencing an *already-resident*
  dependency works (e.g. System `User` via `eSpace.References.Named("(System)")`,
  no `RefreshDependency` needed). `omlRefreshReferences` (§ 3.2) only refreshes
  existing references to their latest version.
- **The output of a `Record List To Excel` node can't be referenced in an
  expression.** `IRecordListToExcelNode` can be created, but every reference to
  its output gives `ExpressionUnknownObject`. This was tried with 20+ names,
  including `ExcelFile`, and with a default-named node (verified 2026-10-01).
  Generate CSV text in a server action and download it from the client instead.
  Excel opens it directly.
- **Theme Icon Library** cannot be set on contract 1 builds, because
  the merge can be rejected (§ 3.1, [`reference/contracts.md`](reference/contracts.md)). You don't need to set it: theme stylesheet edits
  merge and publish fine with `IconLibrary` left null.
- **Edits to a non-empty block or screen stylesheet are not reliably published.**
  This does not apply to the theme stylesheet: theme edits published 3 times out of 3.
  Prefer the theme for CSS (§ 3.1). Verified 2026-10-01 by downloading the served CSS
  with curl.
  - What happens: the merge reports `merged:true` and the live module holds the new text,
    but `omlPublish` still deploys the old CSS. Its version hash in
    `/<App>/moduleservices/moduleinfo` doesn't change.
  - What does publish: setting a stylesheet that was **empty**.
  - **No reliable workaround.** Clearing the stylesheet in one merge and writing it in a
    second worked once, then failed on the next try. Screen and widget changes in the same
    publish *did* deploy, which you can confirm in the compiled `scripts/<App>.<Flow>.<Screen>.mvc.js`.
    Always confirm the CSS with `curl https://<host>/<App>/css/<App>.<Flow>.<Block>.css`;
    a screenshot alone can't tell you whether it deployed. If it is stale, hand the CSS to
    the user as a file to paste into the stylesheet editor in Service Studio and publish
    from there.
- **Don't rely on `IRestService.CrossSiteRequests = Restrict` for CORS.** It has no
  runtime effect (verified 2026-10-17): the property can be set, TrueChange is silent,
  it survives merge and publish, yet the published API still answers a foreign `Origin`
  with `Access-Control-Allow-Origin: *`, on the request and on the preflight. Its API doc
  comment is "TBD", and Service Studio's UI doesn't expose it. Don't set it to restrict
  cross-origin access. If the user needs CORS restricted, tell them it has to be enforced
  another way, and that the setting is under review.
- **The open-module list doesn't say which environment a module came from** (verified
  2026-10-17 on `listApps`). With modules from two infrastructures open, they come back in
  one list with no server or environment field. `omlPublish` publishes each module to the
  server it was opened from. Same-named modules in different tabs no longer collide: a name
  that matches several tabs fails with `MODULE_AMBIGUOUS`, so pass the `tabId` (§ 0.1).
  `searchApps` names its `environment` and marks only the tabs connected to it. On older
  builds, which address modules by name only, confirm with the user which module and
  environment they mean whenever two open modules could share a name.
- **Widget sequences can be reordered.** `IContainer.Widgets`, `ILink.Widgets` and
  `IPlaceholderContentWidget.Widgets` are `OutSystems.Model.ISequence<IMobileWidget>`,
  with `MoveToStart`, `MoveToEnd`, `MoveBeforeSibling`, `MoveAfterSibling` and
  `SetOrderTo`. Cast and move existing widgets instead of deleting and recreating them.

## Common Mistakes

Full taxonomy with response-shape diagnostics: [`reference/lambda-contract.md`](reference/lambda-contract.md).
Quick checklist (each already covered in detail above):

- Body-only statements with no `eSpace => { ... }` wrapper (§ 1, rule 1).
- `code` ending in anything other than `}` — trailing newline/space/`;` (§ 1, rule 3).
- Calling `eSpace.Save(...)` yourself (§ 1, rule 4).
- Renaming the lambda parameter away from `eSpace` (§ 1, rule 2).
- Skipping `getDataModel` (or the matching `get*`) before writing (§ 2).
- Looking up a System / referenced entity via `eSpace.Entities` instead of
  `eSpace.References.Named("(System)")` — see [`reference/patterns-by-element.md`](reference/patterns-by-element.md)
  § "FK to a System / referenced entity".
- Iterating `eSpace.Entities` and mutating whatever comes back — it also
  yields static/client entities, so a server-entity setter throws
  `InvalidOperationException`. Filter with
  `.OfType<OutSystems.Model.Data.IServerEntity>()` first (not a default import).
- Omitting `includeJson` on code-returning read tools — always pass `"Never"` (§ 2), except on
  `getObjectByCompoundKey`, which takes none.
- Skipping the auto-merge after the final successful mutation (§ 3.1).
- Calling `applyModelApiCode` before `startOmlEditSession`, which fails with `No OML
  edit session is started`. Finishing without `endOmlEditSession`, which leaves the
  module checked out for the next caller and blocks `closeModule` (§ 2.1).
- Firing sidecar reads on one module in parallel outside an edit session (`getReferrers`
  and `getDataExposure` are safe in parallel). All but one can fail
  with `OML not found: …-in.oml`, which is not a problem with the call: run the failed
  read again on its own (§ 2).
- Sending flat arguments, or forgetting `sessionToken` — every tool except
  `listOpenModules` wants `{ "input": {…}, "sessionToken": … }` (§ 0). Requesting a
  new token on every reconnect instead of reusing the first one (§ 0).
- Calling `listApps` on a build that advertises `listOpenModules` (it fails as an unknown
  tool), or guessing between tabs after `MODULE_AMBIGUOUS` instead of passing the `tabId`
  of the one the user means (§ 0.1).
- Opening a module the user didn't name, opening one of several matches without asking,
  or passing a module name as `openModule`'s `moduleKey`. Closing a module the user opened,
  or closing a merged module without first telling the user Studio will ask them to save
  (§ 0.1).
- Using `Console.WriteLine`, `System.…`-qualified names or reflection, or
  passing a non-`OutSystems.Model` namespace in `imports` — rejected before
  compile; throw a `PROBE:` exception to see values (§ 1.1).
- Assuming the name you asked for is the name you got — a taken name
  (including an entity-action name like `GetOrder` once entity `Order` has an
  identifier) is silently suffixed (`GetOrder2`), and attribute names are cut
  to 28 characters. Read `.Name` back ([`reference/patterns-by-element.md`](reference/patterns-by-element.md) § "Silent renames").
- Saying a property doesn't exist because the name the user gave isn't in the
  read output — users use Service Studio's display labels, the tools return
  internal names (e.g. a REST API's "API Consumer" is `Interoperability`).
  See [`reference/model-api-tips.md`](reference/model-api-tips.md) § "Service Studio property labels vs. model property names".
- Making a Reactive screen public with `screen.AnonymousAccess = true` — `omlMerge` drops it.
  Add `eSpace.AnonymousRole` to `screen.Roles` instead, and check access on the **live** module after
  the merge ([`reference/patterns-by-element.md`](reference/patterns-by-element.md) § "Screen access").
- Calling `omlRefreshReferences` inside an edit session. It ends a session with unmerged
  edits, or leaves the working copy without the refreshed references (§ 3.2).
  Calling `omlPublish` without being asked to publish (§ 3.2).
- Building O11 BPT processes with `CreateBusinessProcess` (the ODC Workflows
  API) instead of `eSpace.CreateProcess`, or wiring process nodes with
  `ConnectedBelow` instead of `node.Targets.Add(next)` (§ 8).
- **⚠️ TEMPORARY — blaming your own code when *every* tool call fails
  identically.** If each call returns `An error occurred invoking '<toolName>'`
  and your client is auto-populating argument fields you never sent (names
  like `inputXXXNameValPairs`), your harness's tool wrapper is corrupting the
  argument envelope — fall back to posting directly to the endpoint: [`reference/verb-reference.md`](reference/verb-reference.md)
  § "HTTP transport". Observed on the Antigravity CLI, 2026-08-03.
- Looking for a compile error in the result — it never arrives there; a
  snippet that doesn't compile comes back as an MCP tool error carrying the
  diagnostics (§ 3).
- Treating a clean response as proof of mutation — verify with a follow-up
  `get*` (the silent-no-op trap, § 3).
- Ignoring `validationMessages` — a `type: "Error"` entry means
  saved-but-invalid even though the run looked clean. It's a structured array;
  don't substring-match it for `(Error)` (§ 3).
- Retrying `omlMerge` after `merged:false` without asking what Service Studio's
  dialog said, or setting `Theme.IconLibrary`, which can make contract 1
  builds reject the merge (§ 3.1).
- Using an ambiguous short name. `IStartNode`, `IEndNode`, `IScreenAction`,
  `IScreenAggregate` and `IDataAction` each exist in more than one imported
  namespace. Write them in full:
  - `OutSystems.Model.Logic.Nodes.IStartNode`
  - `OutSystems.Model.Logic.Nodes.IEndNode`
  - `OutSystems.Model.UI.Mobile.IScreenAction`
  - `OutSystems.Model.UI.Mobile.IScreenAggregate`
  - `OutSystems.Model.UI.Mobile.IDataAction`
- Using `.Name` on a static-entity record. Use `.Identifier` instead, for example
  `((IStaticEntitySignature)e).Records.Select(r => r.Identifier)`. The
  expression form is `Entities.<Entity>.<Identifier>`.
- Writing timestamps in build or tracking files from memory. They drift by hours
  over a long session. Run `date`, or take the times from the session transcript.
- Placeholder tokens in your own C# helper code (for example `$` meaning "current
  row prefix") that collide with literals inside OutSystems expressions. The
  observed result was `FormatCurrency(x, "GetList.List.Current.", …)`. Use a token
  that can never appear in an expression, such as `@@ROW@@`.
- Replaying `get*` read-back to edit an element. Read-back is creation code, so it
  adds a silently renamed duplicate (`X2`, outside its folder). Look the element up
  with `eSpace.ServerActions.Named("X")` (or the matching collection) and mutate it
  in place (§ 2).
- **CS1503 `cannot convert from 'IForm' to 'IContainer'`.** Reactive widget parents
  share no common interface. `IForm`, `IContainer`, `IPlaceholderContentWidget`,
  `IList` and the rest each declare their own `CreateWidget<T>`, and an `IForm` is
  not an `IContainer`. To reuse an `IContainer` helper for form fields, create a
  container inside the form first (`form.CreateWidget<ServiceStudio.Plugin.NRWidgets.IContainer>()`)
  and pass that.
- **CS1593 / CS7036 on your own `Action<A, B>` helper.** The lambda's parameter count,
  and every call to it, must match the type arguments exactly, because `Action<…>` has
  no optional parameters. For helpers, prefer a typed local function
  (`void AddField(ServiceStudio.Plugin.NRWidgets.IContainer c, string label) { … }`).
  Local functions pass the sandbox (verified 2026-10-17), give clearer errors, and
  support optional parameters.
- Setting `Description` on an `IUserException`. It has only `Name` plus the audit
  fields (`CreatedBy`, `LastModifiedBy`, `LastModifiedDate`, `LastMergedBy`,
  `LastMergedDate`), so this fails with CS1061 (verified 2026-10-17). Service Studio's
  properties panel shows only a Name for user exceptions too, so a description can't be
  stored anywhere. Tell the user that, and don't suggest typing it in Service Studio. If they
  want the text documented, offer a comment on the flows that raise the exception. Not every
  element has a `Description`; check [`docs/`](docs/) before setting one.
- Building UI or logic for many screens in one lambda without a dry run. Run the
  lambda once with `throw new Exception("PROBE:" + summary)` as its last
  statement. This returns the TrueChange messages for the change without saving
  anything (§ 1.1). Then run it again without the throw.

## 9. Security caveat

`applyModelApiCode` runs caller-authored C#. Code executes out of process and
is terminated if it exceeds the timeout (300 s for `applyModelApiCode`).

Because the snippet is arbitrary C# that runs with the host's privileges, treat
`applyModelApiCode` as privileged: **use it only against modules you own**, and
be cautious with code derived from untrusted module content.

Files in this skill

  • SKILL.md50.1 KB
  • docs/BuiltinFunctions.Generated.json57 KB
  • docs/Loader.Generated.cs240 B
  • docs/OutSystems.Model.Applications.Generated.cs1.1 KB
  • docs/OutSystems.Model.BusinessProcesses.Generated.cs1.7 KB
  • docs/OutSystems.Model.BusinessProcesses.Nodes.Generated.cs8.8 KB
  • docs/OutSystems.Model.Data.ChunkingMethods.Generated.cs992 B
  • docs/OutSystems.Model.Data.Generated.cs15.9 KB
  • docs/OutSystems.Model.Data.Nodes.Generated.cs382 B
  • docs/OutSystems.Model.Enumerations.Generated.cs16.4 KB
  • docs/OutSystems.Model.Enumerations.ModelPlugins.Generated.cs1.1 KB
  • docs/OutSystems.Model.Expressions.Generated.cs30.4 KB
  • docs/OutSystems.Model.Expressions.Nodes.Generated.cs4.3 KB
  • docs/OutSystems.Model.Factory.ChangeSet.Generated.cs834 B
  • docs/OutSystems.Model.Factory.Generated.cs5.8 KB
  • docs/OutSystems.Model.Logic.Aggregates.Database.Generated.cs4.4 KB
  • docs/OutSystems.Model.Logic.Aggregates.Full.Generated.cs4.3 KB
  • docs/OutSystems.Model.Logic.Aggregates.Generated.cs2.8 KB
  • docs/OutSystems.Model.Logic.Generated.cs11.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.