@renanlido/tia-openness-mcp 1.7.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -20
- package/dist/index.js +390 -8
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -92,6 +92,27 @@ and returns the **plan by name WITHOUT mutating** (`status:"plan_ok"`). **Gd6**
|
|
|
92
92
|
`tia_source_put`, graphical (LAD/FBD/GRAPH) via `tia_import_xml`; UDTs before blocks. **Gd2** (advisory) — idempotency
|
|
93
93
|
by name (check existence with the M1 read-only tools before creating; Openness has no rollback).
|
|
94
94
|
|
|
95
|
+
### Libraries, HMI, CAx and PLC security (class R reads, class M-off changes)
|
|
96
|
+
Thin wrappers of `serve` routes that already existed. Every change takes `dryRun` (Gd11), is offline (it reaches
|
|
97
|
+
the CPU only through a later compile + human-gated download) and needs the `author` license scope; every file path
|
|
98
|
+
is a path **on the serve host**.
|
|
99
|
+
|
|
100
|
+
| Tool | Endpoint | Class / notes |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `tia_library_mastercopies` / `tia_library_types` | `GET /library/mastercopies` · `GET /library/types` | R — project-library master copies; library types with their versions. |
|
|
103
|
+
| `tia_library_mastercopy_create` | `POST /library/mastercopies` | M-off, job — master copy of a **device** (a block cannot be a source). |
|
|
104
|
+
| `tia_block_from_mastercopy` | `POST /plcs/{plc}/blocks/frommastercopy` | M-off — needs a master copy holding PLC blocks; a device copy is refused (`409 mastercopy_not_blocks` after app 1.6.3; up to 1.6.3 a 500). |
|
|
105
|
+
| `tia_global_libraries` | `GET /globallibraries` | R — global libraries open in the TIA Portal session. |
|
|
106
|
+
| `tia_global_library_create` / `_open` / `_save` / `_close` | `POST /globallibraries` (+ `/open` `/save` `/close`) | M-off (create/open/save run as jobs). Save/close take the name from `tia_global_libraries` (exact name first, then ignoring case); a name that picks no single open user library is refused, nothing saved or closed — `404 not_found` (`details.userLibraries` lists the names that work), or `409 conflict` for a system/corporate library or an ambiguous name — after app 1.6.3 (up to 1.6.3 a success even for an unknown name). |
|
|
107
|
+
| `tia_hmis` / `tia_hmi_screens` | `GET /hmi` · `GET /hmi/{hmi}/screens` | R — HMIs (`classic`/`unified`) and their screens. |
|
|
108
|
+
| `tia_hmi_screen_export` / `tia_hmi_screens_import` | `POST /hmi/{hmi}/screens/{screen}/export` · `…/screens/import` | M-off, job — WinCC **Classic** only; the import overwrites same-named screens. |
|
|
109
|
+
| `tia_cax_export` / `tia_cax_import` | `POST /cax/export` · `POST /cax/import` | M-off, job — AutomationML of one device or the whole project; import `option` `RetainTiaDevice` (default) / `OverwriteTiaDevice` / `MoveToParkingLot`. Returns the transfer `state`/counts/`messages`; a failed transfer is `500 cax_transfer_failed` after app 1.6.3 (up to 1.6.3 only an opaque `result` string, even on failure). |
|
|
110
|
+
| `tia_certificates` / `tia_certificate_template` | `GET /plcs/{plc}/certificates` (+ `/template?usage=`) | R — the CPU's local certificate store (409 on a CPU without the manager). |
|
|
111
|
+
| `tia_certificate_import` / `_export` / `_delete` | `POST …/certificates/import` · `POST …/{id}/export` · `DELETE …/{id}` | M-off — the import's file password is **GATE G6** (from a human; `[redacted]` in dryRun plans). |
|
|
112
|
+
| `tia_password_policy` / `tia_password_policy_set` | `GET`/`POST /plcs/{plc}/passwordpolicy` | R / M-off + **GATE G6** — the policy values are a human decision; on a modern-only CPU just `enabled` applies and the dropped fields come back in `ignoredFields`. |
|
|
113
|
+
| `tia_block_protect` | `POST /plcs/{plc}/blocks/{block}/protect` | M-off + **GATE G6** — know-how protection on/off; the password comes from a human, never retried with a guess. |
|
|
114
|
+
| `tia_local_sessions` | `GET /multiuser/localsessions` | R — local multiuser sessions (empty in a single-user project). |
|
|
115
|
+
|
|
95
116
|
### M4 — verification + GATED deploy (hardware)
|
|
96
117
|
| Tool | Endpoint | Gate/class |
|
|
97
118
|
|---|---|---|
|
|
@@ -129,17 +150,20 @@ Accepts the structured **project-spec** (`docs/TIA-BEST-PRACTICES.md` §13.2; JS
|
|
|
129
150
|
- **`tia_spec_plan`** (no serve needed): turns a valid spec into the ordered operation sequence (subnets→devices→modules→network→tags→blocks→compile).
|
|
130
151
|
- **`tia_spec_apply`**: orchestrates the OFFLINE build on an open project (validate → G5 → execute serially → compile), **stops at the 1st error** and **never downloads** (download is GATE G3, always human). `dryRun:true` returns the plan.
|
|
131
152
|
|
|
132
|
-
> **MCP M0–M5 COMPLETE** (
|
|
133
|
-
> ships
|
|
153
|
+
> **MCP M0–M5 COMPLETE** (105 tools in this branch — the published npm `@renanlido/tia-openness-mcp` 1.7.0 still
|
|
154
|
+
> ships 81 until the next release), **runtime-validated** against a real TIA Portal V21 (including a
|
|
134
155
|
> **hardware deploy** to an S7-1200) and **published to npm**. Roadmap and milestones in `docs/ROADMAP.md` §3.
|
|
135
156
|
|
|
136
157
|
### Long operations run as jobs (ADR 0009)
|
|
137
158
|
|
|
138
159
|
Opening a project takes 40–80 s in the field, and a compile/download of a large project can take just
|
|
139
|
-
as long — well past the ~30 s ceiling most MCP clients enforce per call. **
|
|
160
|
+
as long — well past the ~30 s ceiling most MCP clients enforce per call. **24 tools** run through a
|
|
140
161
|
soft-deadline job runner instead of blocking the call: `tia_connect`, `tia_start`, `tia_show_ui`,
|
|
141
|
-
`tia_project_create`, `tia_project_save`, `
|
|
142
|
-
`tia_download` (plan and real), `tia_upload`, `tia_export_xml`, `tia_spec_apply`,
|
|
162
|
+
`tia_project_create`, `tia_project_save`, `tia_project_saveas`, `tia_project_close`, `tia_project_archive`,
|
|
163
|
+
`tia_compile`, `tia_source_put`, `tia_download` (plan and real), `tia_upload`, `tia_export_xml`, `tia_spec_apply`,
|
|
164
|
+
`tia_export_block`, `tia_block_compare`, `tia_cax_export`, `tia_cax_import`, `tia_hmi_screen_export`,
|
|
165
|
+
`tia_hmi_screens_import`, `tia_global_library_create`, `tia_global_library_open`, `tia_global_library_save` and
|
|
166
|
+
`tia_library_mastercopy_create`.
|
|
143
167
|
|
|
144
168
|
- If the operation finishes before `TIA_SOFT_DEADLINE_MS` (default 20 s, capped at 25 s), the call
|
|
145
169
|
returns the normal result — nothing changes for the fast case.
|
|
@@ -232,21 +256,17 @@ npm install -g . # prepack builds and installs the
|
|
|
232
256
|
`mcp/` changes** (and `semantic-release-monorepo` filters the commits by that path), builds and publishes to
|
|
233
257
|
**public npm** (`registry.npmjs.org`, `publishConfig.access: public`).
|
|
234
258
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
4. From then on, **conventional commits** on `main` trigger the release automatically.
|
|
247
|
-
|
|
248
|
-
> Config validated locally: versions deduped at `semantic-release@24`; the dry-run loaded config/plugins
|
|
249
|
-
> and only stopped because the remote repo did not exist yet.
|
|
259
|
+
**Authentication is npm trusted publishing (OIDC)** — there is no `NPM_TOKEN`. The package has a trusted
|
|
260
|
+
publisher on npmjs.com pointing at `renanlido/TIAOpenness` + `release-mcp.yml`; the workflow needs
|
|
261
|
+
`id-token: write`, and the publish gets provenance automatically. The native Actions `GITHUB_TOKEN` pushes the
|
|
262
|
+
release **tag** and creates the **GitHub release**.
|
|
263
|
+
|
|
264
|
+
**Nothing is committed back to `main`.** `main` is protected by a ruleset that requires the CI checks on every
|
|
265
|
+
push, so a release commit is rejected (GH013). The released version lives in the tag
|
|
266
|
+
(`@renanlido/tia-openness-mcp-vX.Y.Z`), on npm and in the GitHub release (which carries the release notes);
|
|
267
|
+
`@semantic-release/npm` bumps `package.json` only in the runner's workspace, and `prepack` rebuilds `dist/` so the
|
|
268
|
+
handshake reports that version. The checked-in `version` is a dev fallback — don't hand-edit it, and don't expect it
|
|
269
|
+
to match npm. [`CHANGELOG.md`](CHANGELOG.md) is frozen at 1.7.0; later notes are on the GitHub releases.
|
|
250
270
|
|
|
251
271
|
## Registering in Claude Code
|
|
252
272
|
|
package/dist/index.js
CHANGED
|
@@ -31678,7 +31678,7 @@ function hintFor(err) {
|
|
|
31678
31678
|
case "busy":
|
|
31679
31679
|
return "A long operation is still running \u2014 call tia_job_status with details.jobId, then retry. Do not poll tia_status meanwhile.";
|
|
31680
31680
|
case "not_found":
|
|
31681
|
-
return "Resource not found \u2014 rediscover
|
|
31681
|
+
return "Resource not found \u2014 rediscover a name via a listing tool; for a file path, check it exists on the serve host.";
|
|
31682
31682
|
case "plan_stale":
|
|
31683
31683
|
return "The project changed after the plan was approved \u2014 NOTHING was downloaded. Run tia_download with dryRun:true again and get a NEW human approval for the new plan.";
|
|
31684
31684
|
case "upgrade_target_device_required":
|
|
@@ -32086,7 +32086,7 @@ function registerJobTools(server2) {
|
|
|
32086
32086
|
"tia_job_status",
|
|
32087
32087
|
{
|
|
32088
32088
|
title: "TIA \u2014 long-operation status",
|
|
32089
|
-
description: 'Waits (up to waitSeconds, default 20, max 25) for a background job started by a long tool that answered status:"running" (tia_connect, tia_start, tia_show_ui, tia_project_create/save/saveas/close/archive, tia_compile, tia_source_put, tia_download, tia_upload, tia_export_xml, tia_export_block, tia_block_compare, tia_spec_apply) and returns its FINAL result with job:{id,tool,state,durationMs} \u2014 including a gate handoff if the operation ended in one. While a job runs, every other serve-bound tool answers kind:"busy" (with details.jobId): call this instead of polling tia_status, and never repeat the original call. If a tia_connect/tia_start/tia_show_ui job stays running for minutes, a trust dialog (GATE G1) may be waiting on the serve host \u2014 ask a human to look. Does not call serve. Class R.',
|
|
32089
|
+
description: 'Waits (up to waitSeconds, default 20, max 25) for a background job started by a long tool that answered status:"running" (tia_connect, tia_start, tia_show_ui, tia_project_create/save/saveas/close/archive, tia_compile, tia_source_put, tia_download, tia_upload, tia_export_xml, tia_export_block, tia_block_compare, tia_spec_apply, tia_cax_export/import, tia_hmi_screen_export, tia_hmi_screens_import, tia_global_library_create/open/save, tia_library_mastercopy_create) and returns its FINAL result with job:{id,tool,state,durationMs} \u2014 including a gate handoff if the operation ended in one. While a job runs, every other serve-bound tool answers kind:"busy" (with details.jobId): call this instead of polling tia_status, and never repeat the original call. If a tia_connect/tia_start/tia_show_ui job stays running for minutes, a trust dialog (GATE G1) may be waiting on the serve host \u2014 ask a human to look. Does not call serve. Class R.',
|
|
32090
32090
|
inputSchema: {
|
|
32091
32091
|
jobId: external_exports.string().describe("jobId returned by the long tool (or by a busy error's details.jobId)"),
|
|
32092
32092
|
waitSeconds: external_exports.number().int().min(0).max(25).optional().describe("how long this call may wait (default 20, max 25)")
|
|
@@ -32531,6 +32531,13 @@ function guardError(guard, message, context) {
|
|
|
32531
32531
|
true
|
|
32532
32532
|
);
|
|
32533
32533
|
}
|
|
32534
|
+
var REDACTED = "[redacted]";
|
|
32535
|
+
function redactBody(body, secretFields = []) {
|
|
32536
|
+
if (body === void 0) return null;
|
|
32537
|
+
const out = { ...body };
|
|
32538
|
+
for (const f of secretFields) if (f in out) out[f] = REDACTED;
|
|
32539
|
+
return out;
|
|
32540
|
+
}
|
|
32534
32541
|
async function mutate(method, path, body, opts) {
|
|
32535
32542
|
if (opts.dryRun) {
|
|
32536
32543
|
return textResult(
|
|
@@ -32539,7 +32546,7 @@ async function mutate(method, path, body, opts) {
|
|
|
32539
32546
|
status: "plan_ok",
|
|
32540
32547
|
action: `${method} ${path}`,
|
|
32541
32548
|
summary: opts.summary,
|
|
32542
|
-
body: body
|
|
32549
|
+
body: redactBody(body, opts.secretFields),
|
|
32543
32550
|
note: "Plan validated (guards OK). NOTHING was changed. Run again with dryRun:false to apply."
|
|
32544
32551
|
},
|
|
32545
32552
|
false
|
|
@@ -33107,6 +33114,379 @@ function registerAsCodeTools(server2) {
|
|
|
33107
33114
|
);
|
|
33108
33115
|
}
|
|
33109
33116
|
|
|
33117
|
+
// src/tools/assets.ts
|
|
33118
|
+
var CAX_IMPORT_OPTIONS = ["RetainTiaDevice", "OverwriteTiaDevice", "MoveToParkingLot"];
|
|
33119
|
+
function longMutate(tool, method, path, body, opts) {
|
|
33120
|
+
if (opts.dryRun) return mutate(method, path, body, opts);
|
|
33121
|
+
return jobs.run(tool, { method, path, body }, () => mutate(method, path, body, { summary: opts.summary }));
|
|
33122
|
+
}
|
|
33123
|
+
var CAX_RESULT_NOTE = "Returns the transfer state, errors, warnings and messages (capped; messagesTruncated); a transfer whose state is Error or that counts any error is an error (500 cax_transfer_failed, those fields in details), and `unreadable` flags an outcome that could not be fully read. Serves up to app 1.6.3 return only an opaque `result` string even when the transfer failed \u2014 check the outcome with tia_devices.";
|
|
33124
|
+
function registerAssetTools(server2) {
|
|
33125
|
+
server2.registerTool(
|
|
33126
|
+
"tia_library_mastercopies",
|
|
33127
|
+
{
|
|
33128
|
+
title: "TIA \u2014 project library master copies",
|
|
33129
|
+
description: "Lists the master copies in the open project's library (names, from every folder). Maps to GET /library/mastercopies. Read-only (class R).",
|
|
33130
|
+
inputSchema: {}
|
|
33131
|
+
},
|
|
33132
|
+
async () => getResult("/library/mastercopies")
|
|
33133
|
+
);
|
|
33134
|
+
server2.registerTool(
|
|
33135
|
+
"tia_library_mastercopy_create",
|
|
33136
|
+
{
|
|
33137
|
+
title: "TIA \u2014 master copy from a device",
|
|
33138
|
+
description: `Creates a master copy of a DEVICE (station) in the open project's library and returns its name. Only a device is accepted as the source \u2014 a PLC block cannot become a master copy through this route. Maps to POST /library/mastercopies {device}. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
33139
|
+
inputSchema: {
|
|
33140
|
+
device: external_exports.string().describe("device (station) name, as listed by tia_devices"),
|
|
33141
|
+
...dryRunField
|
|
33142
|
+
}
|
|
33143
|
+
},
|
|
33144
|
+
async ({ device, dryRun }) => longMutate("tia_library_mastercopy_create", "POST", "/library/mastercopies", jsonBody({ device }), {
|
|
33145
|
+
dryRun,
|
|
33146
|
+
summary: `create a master copy of device ${device} in the project library`
|
|
33147
|
+
})
|
|
33148
|
+
);
|
|
33149
|
+
server2.registerTool(
|
|
33150
|
+
"tia_library_types",
|
|
33151
|
+
{
|
|
33152
|
+
title: "TIA \u2014 project library types",
|
|
33153
|
+
description: "Lists the types in the open project's library with their versions as {name, ns, guid, status, versions:[{version, state, isDefault, author, modified, guid}]}. Maps to GET /library/types. Read-only (class R).",
|
|
33154
|
+
inputSchema: {}
|
|
33155
|
+
},
|
|
33156
|
+
async () => getResult("/library/types")
|
|
33157
|
+
);
|
|
33158
|
+
server2.registerTool(
|
|
33159
|
+
"tia_block_from_mastercopy",
|
|
33160
|
+
{
|
|
33161
|
+
title: "TIA \u2014 instantiate block from master copy",
|
|
33162
|
+
description: `Creates a PLC block from a master copy of the open project's library (name from tia_library_mastercopies) and returns the new block's name. The master copy must hold PLC blocks: one that holds hardware and no block \u2014 e.g. a device master copy, the only kind tia_library_mastercopy_create makes \u2014 is refused with 409 kind:"mastercopy_not_blocks" by serves after app 1.6.3 (up to 1.6.3: 500 "Copying from the library failed"); other non-block content (a UDT or tag-table copy) still fails inside Openness. Maps to POST /plcs/{plc}/blocks/frommastercopy {masterCopy}. Class M-off.`,
|
|
33163
|
+
inputSchema: {
|
|
33164
|
+
plc: external_exports.string().describe("PLC name"),
|
|
33165
|
+
masterCopy: external_exports.string().describe("master copy name (from tia_library_mastercopies)"),
|
|
33166
|
+
...dryRunField
|
|
33167
|
+
}
|
|
33168
|
+
},
|
|
33169
|
+
async ({ plc, masterCopy, dryRun }) => mutate("POST", `/plcs/${seg(plc)}/blocks/frommastercopy`, jsonBody({ masterCopy }), {
|
|
33170
|
+
dryRun,
|
|
33171
|
+
summary: `instantiate master copy ${masterCopy} as a block on ${plc}`
|
|
33172
|
+
})
|
|
33173
|
+
);
|
|
33174
|
+
server2.registerTool(
|
|
33175
|
+
"tia_global_libraries",
|
|
33176
|
+
{
|
|
33177
|
+
title: "TIA \u2014 open global libraries",
|
|
33178
|
+
description: "Lists the names of the global libraries open in the TIA Portal session (system libraries included). Maps to GET /globallibraries. Read-only (class R).",
|
|
33179
|
+
inputSchema: {}
|
|
33180
|
+
},
|
|
33181
|
+
async () => getResult("/globallibraries")
|
|
33182
|
+
);
|
|
33183
|
+
server2.registerTool(
|
|
33184
|
+
"tia_global_library_create",
|
|
33185
|
+
{
|
|
33186
|
+
title: "TIA \u2014 create global library",
|
|
33187
|
+
description: `Creates a new global library on disk (directory on the serve host) and opens it in the TIA Portal session; returns its name. Maps to POST /globallibraries {directory, name}. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
33188
|
+
inputSchema: {
|
|
33189
|
+
directory: external_exports.string().describe("parent directory on the serve host"),
|
|
33190
|
+
name: external_exports.string().describe("library name"),
|
|
33191
|
+
...dryRunField
|
|
33192
|
+
}
|
|
33193
|
+
},
|
|
33194
|
+
async ({ directory, name, dryRun }) => longMutate("tia_global_library_create", "POST", "/globallibraries", jsonBody({ directory, name }), {
|
|
33195
|
+
dryRun,
|
|
33196
|
+
summary: `create global library ${name} in ${directory}`
|
|
33197
|
+
})
|
|
33198
|
+
);
|
|
33199
|
+
server2.registerTool(
|
|
33200
|
+
"tia_global_library_open",
|
|
33201
|
+
{
|
|
33202
|
+
title: "TIA \u2014 open global library",
|
|
33203
|
+
description: `Opens a global library file (.alNN on the serve host, e.g. MyLib.al21 \u2014 the file inside the library folder) in the TIA Portal session and returns its name; readWrite defaults to true (pass false to open it read-only). Serves after app 1.6.3 refuse an unusable path before TIA, nothing opened: a missing file is 404 kind:"not_found"; a folder, a file that is not .alNN or a malformed path (e.g. with quotes) is 400 kind:"bad_request" (up to 1.6.3: 500 internal). Maps to POST /globallibraries/open {path, readWrite}. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
33204
|
+
inputSchema: {
|
|
33205
|
+
path: external_exports.string().describe("library file path on the serve host"),
|
|
33206
|
+
readWrite: external_exports.boolean().optional().describe("open read-write (default true) or read-only (false)"),
|
|
33207
|
+
...dryRunField
|
|
33208
|
+
}
|
|
33209
|
+
},
|
|
33210
|
+
async ({ path, readWrite, dryRun }) => longMutate("tia_global_library_open", "POST", "/globallibraries/open", jsonBody({ path, readWrite }), {
|
|
33211
|
+
dryRun,
|
|
33212
|
+
summary: `open global library ${path}${readWrite === false ? " read-only" : ""}`
|
|
33213
|
+
})
|
|
33214
|
+
);
|
|
33215
|
+
server2.registerTool(
|
|
33216
|
+
"tia_global_library_save",
|
|
33217
|
+
{
|
|
33218
|
+
title: "TIA \u2014 save global library",
|
|
33219
|
+
description: `Saves an open user global library by name (from tia_global_libraries; exact name first, then ignoring case) and returns its name as {saved}. Serves after app 1.6.3 refuse a name that picks no single open USER library, nothing saved: an unknown name is 404 kind:"not_found"; a system or corporate library (read-only), or a name several user libraries match only ignoring case, is 409 kind:"conflict"; details.userLibraries / systemLibraries / corporateLibraries list the open libraries (up to 1.6.3: 200 {saved:<name>} even when nothing was saved \u2014 confirm the name with tia_global_libraries first). Maps to POST /globallibraries/save {name}. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
33220
|
+
inputSchema: {
|
|
33221
|
+
name: external_exports.string().describe("library name (from tia_global_libraries)"),
|
|
33222
|
+
...dryRunField
|
|
33223
|
+
}
|
|
33224
|
+
},
|
|
33225
|
+
async ({ name, dryRun }) => longMutate("tia_global_library_save", "POST", "/globallibraries/save", jsonBody({ name }), {
|
|
33226
|
+
dryRun,
|
|
33227
|
+
summary: `save global library ${name}`
|
|
33228
|
+
})
|
|
33229
|
+
);
|
|
33230
|
+
server2.registerTool(
|
|
33231
|
+
"tia_global_library_close",
|
|
33232
|
+
{
|
|
33233
|
+
title: "TIA \u2014 close global library",
|
|
33234
|
+
description: 'Closes an open user global library by name (from tia_global_libraries; exact name first, then ignoring case; unsaved changes are not saved \u2014 call tia_global_library_save first) and returns its name as {closed}. Serves after app 1.6.3 refuse a name that picks no single open USER library, nothing closed: an unknown or already-closed name is 404 kind:"not_found"; a system or corporate library (read-only), or a name several user libraries match only ignoring case, is 409 kind:"conflict"; details.userLibraries / systemLibraries / corporateLibraries list the open libraries (up to 1.6.3: 200 {closed:<name>} even when nothing was closed \u2014 confirm the name with tia_global_libraries first). Maps to POST /globallibraries/close {name}. Class M-off.',
|
|
33235
|
+
inputSchema: {
|
|
33236
|
+
name: external_exports.string().describe("library name (from tia_global_libraries)"),
|
|
33237
|
+
...dryRunField
|
|
33238
|
+
}
|
|
33239
|
+
},
|
|
33240
|
+
async ({ name, dryRun }) => mutate("POST", "/globallibraries/close", jsonBody({ name }), { dryRun, summary: `close global library ${name}` })
|
|
33241
|
+
);
|
|
33242
|
+
server2.registerTool(
|
|
33243
|
+
"tia_hmis",
|
|
33244
|
+
{
|
|
33245
|
+
title: "TIA \u2014 HMI devices",
|
|
33246
|
+
description: 'Lists the HMIs in the open project as {kind, name}: kind "classic" (WinCC Classic HmiTarget) or "unified" (WinCC Unified). Maps to GET /hmi. Read-only (class R).',
|
|
33247
|
+
inputSchema: {}
|
|
33248
|
+
},
|
|
33249
|
+
async () => getResult("/hmi")
|
|
33250
|
+
);
|
|
33251
|
+
server2.registerTool(
|
|
33252
|
+
"tia_hmi_screens",
|
|
33253
|
+
{
|
|
33254
|
+
title: "TIA \u2014 HMI screens",
|
|
33255
|
+
description: "Lists the screen names of an HMI (Classic: every screen folder, recursively; Unified: flat). Maps to GET /hmi/{hmi}/screens. Read-only (class R).",
|
|
33256
|
+
inputSchema: { hmi: external_exports.string().describe("HMI name (from tia_hmis)") }
|
|
33257
|
+
},
|
|
33258
|
+
async ({ hmi }) => getResult(`/hmi/${seg(hmi)}/screens`)
|
|
33259
|
+
);
|
|
33260
|
+
server2.registerTool(
|
|
33261
|
+
"tia_hmi_screen_export",
|
|
33262
|
+
{
|
|
33263
|
+
title: "TIA \u2014 export HMI screen (Classic)",
|
|
33264
|
+
description: `Exports one screen of a CLASSIC WinCC HMI to an XML file on the serve host. WinCC Unified screens have no file export in the V21 API (the serve refuses them). Writes the file only \u2014 the project is not changed. Maps to POST /hmi/{hmi}/screens/{screen}/export {path}. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
33265
|
+
inputSchema: {
|
|
33266
|
+
hmi: external_exports.string().describe("Classic HMI name (from tia_hmis)"),
|
|
33267
|
+
screen: external_exports.string().describe("screen name (from tia_hmi_screens)"),
|
|
33268
|
+
path: external_exports.string().describe("target .xml file path on the serve host"),
|
|
33269
|
+
...dryRunField
|
|
33270
|
+
}
|
|
33271
|
+
},
|
|
33272
|
+
async ({ hmi, screen, path, dryRun }) => longMutate("tia_hmi_screen_export", "POST", `/hmi/${seg(hmi)}/screens/${seg(screen)}/export`, jsonBody({ path }), {
|
|
33273
|
+
dryRun,
|
|
33274
|
+
summary: `export screen ${screen} of HMI ${hmi} to ${path}`
|
|
33275
|
+
})
|
|
33276
|
+
);
|
|
33277
|
+
server2.registerTool(
|
|
33278
|
+
"tia_hmi_screens_import",
|
|
33279
|
+
{
|
|
33280
|
+
title: "TIA \u2014 import HMI screens (Classic)",
|
|
33281
|
+
description: "Imports the screens of an XML file on the serve host into the root screen folder of a CLASSIC WinCC HMI; a screen with the same name is OVERWRITTEN. WinCC Unified is refused (no file import in the V21 API). Returns the imported screen names. Maps to POST /hmi/{hmi}/screens/import {path}. Class M-off. " + LONG_OPERATION_NOTE,
|
|
33282
|
+
inputSchema: {
|
|
33283
|
+
hmi: external_exports.string().describe("Classic HMI name (from tia_hmis)"),
|
|
33284
|
+
path: external_exports.string().describe("screen .xml file path on the serve host"),
|
|
33285
|
+
...dryRunField
|
|
33286
|
+
}
|
|
33287
|
+
},
|
|
33288
|
+
async ({ hmi, path, dryRun }) => longMutate("tia_hmi_screens_import", "POST", `/hmi/${seg(hmi)}/screens/import`, jsonBody({ path }), {
|
|
33289
|
+
dryRun,
|
|
33290
|
+
summary: `import screens from ${path} into HMI ${hmi} (overwrites same-named screens)`
|
|
33291
|
+
})
|
|
33292
|
+
);
|
|
33293
|
+
server2.registerTool(
|
|
33294
|
+
"tia_cax_export",
|
|
33295
|
+
{
|
|
33296
|
+
title: "TIA \u2014 CAx export (AutomationML)",
|
|
33297
|
+
description: `Exports the hardware configuration as CAx / AutomationML (.aml) to a file on the serve host: one device when \`device\` is given, otherwise the whole project. Writes the file only \u2014 the project is not changed. ${CAX_RESULT_NOTE} Maps to POST /cax/export {device?, file}. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
33298
|
+
inputSchema: {
|
|
33299
|
+
file: external_exports.string().describe("target .aml file path on the serve host"),
|
|
33300
|
+
device: external_exports.string().optional().describe("device name to export (omit for the whole project)"),
|
|
33301
|
+
...dryRunField
|
|
33302
|
+
}
|
|
33303
|
+
},
|
|
33304
|
+
async ({ file: file2, device, dryRun }) => longMutate("tia_cax_export", "POST", "/cax/export", jsonBody({ device, file: file2 }), {
|
|
33305
|
+
dryRun,
|
|
33306
|
+
summary: device ? `CAx export of device ${device} to ${file2}` : `CAx export of the whole project to ${file2}`
|
|
33307
|
+
})
|
|
33308
|
+
);
|
|
33309
|
+
server2.registerTool(
|
|
33310
|
+
"tia_cax_import",
|
|
33311
|
+
{
|
|
33312
|
+
title: "TIA \u2014 CAx import (AutomationML)",
|
|
33313
|
+
description: `Imports a CAx / AutomationML (.aml) file on the serve host into the open project's hardware configuration. \`option\` decides what happens to a device that already exists: RetainTiaDevice (default \u2014 keep the project's device), OverwriteTiaDevice (replace it) or MoveToParkingLot. Archive the project first (tia_project_archive) before an overwrite: a failed import may have applied part of the file. ${CAX_RESULT_NOTE} Maps to POST /cax/import {file, option}. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
33314
|
+
inputSchema: {
|
|
33315
|
+
file: external_exports.string().describe(".aml file path on the serve host"),
|
|
33316
|
+
option: external_exports.enum(CAX_IMPORT_OPTIONS).optional().describe("existing-device handling (default RetainTiaDevice)"),
|
|
33317
|
+
...dryRunField
|
|
33318
|
+
}
|
|
33319
|
+
},
|
|
33320
|
+
async ({ file: file2, option, dryRun }) => longMutate("tia_cax_import", "POST", "/cax/import", jsonBody({ file: file2, option }), {
|
|
33321
|
+
dryRun,
|
|
33322
|
+
summary: `CAx import of ${file2} (${option ?? "RetainTiaDevice"})`
|
|
33323
|
+
})
|
|
33324
|
+
);
|
|
33325
|
+
server2.registerTool(
|
|
33326
|
+
"tia_local_sessions",
|
|
33327
|
+
{
|
|
33328
|
+
title: "TIA \u2014 local multiuser sessions",
|
|
33329
|
+
description: "Lists the local multiuser sessions of the TIA Portal session (their attributes); empty for a single-user project. Maps to GET /multiuser/localsessions. Read-only (class R).",
|
|
33330
|
+
inputSchema: {}
|
|
33331
|
+
},
|
|
33332
|
+
async () => getResult("/multiuser/localsessions")
|
|
33333
|
+
);
|
|
33334
|
+
}
|
|
33335
|
+
|
|
33336
|
+
// src/tools/security.ts
|
|
33337
|
+
var CERTIFICATE_USAGES = ["Tls", "WebServer", "OpcUaServer", "OpcUaClient", "OpcUaClientServer"];
|
|
33338
|
+
var SECRET_FIELDS = ["password"];
|
|
33339
|
+
var certificateId = external_exports.number().int().min(0).max(4294967295).describe("certificate id (from tia_certificates)");
|
|
33340
|
+
var policyCount = (what) => external_exports.number().int().min(0).max(32767).optional().describe(what);
|
|
33341
|
+
var humanPassword = (what) => external_exports.string().min(1).regex(/\S/, "a password cannot be blank").describe(`G6: ${what} provided by a HUMAN, never invented`);
|
|
33342
|
+
var PLAIN_HTTP_NOTE = "The password travels to the serve over plain HTTP \u2014 keep the serve on this host or a trusted network.";
|
|
33343
|
+
var LEGACY_POLICY_FIELDS = ["minLength", "minNumeric", "minSpecial", "requiresMixedCase"];
|
|
33344
|
+
function withIgnoredPolicyFields(result, sent) {
|
|
33345
|
+
if (result.isError) return result;
|
|
33346
|
+
let data;
|
|
33347
|
+
try {
|
|
33348
|
+
data = JSON.parse(result.content[0].text);
|
|
33349
|
+
} catch {
|
|
33350
|
+
return result;
|
|
33351
|
+
}
|
|
33352
|
+
if (!isObject2(data) || "legacy" in data) return result;
|
|
33353
|
+
const ignoredFields = LEGACY_POLICY_FIELDS.filter((f) => f in sent);
|
|
33354
|
+
if (ignoredFields.length === 0) return result;
|
|
33355
|
+
return textResult({
|
|
33356
|
+
...data,
|
|
33357
|
+
ignoredFields,
|
|
33358
|
+
warning: `This CPU exposes only the modern password-policy service: ${ignoredFields.join(", ")} were NOT applied (only \`enabled\` is). Tell the human; changing them needs a CPU with the legacy policy service.`
|
|
33359
|
+
});
|
|
33360
|
+
}
|
|
33361
|
+
async function passwordPolicySetFlow(args) {
|
|
33362
|
+
const { plc, dryRun, ...fields } = args;
|
|
33363
|
+
const body = jsonBody(fields);
|
|
33364
|
+
if (Object.keys(body).length === 0) {
|
|
33365
|
+
return guardError(
|
|
33366
|
+
"Gd13",
|
|
33367
|
+
"Nothing to change: pass at least one of enabled, minLength, minNumeric, minSpecial, requiresMixedCase (values decided by a HUMAN \u2014 G6). To read the current policy use tia_password_policy.",
|
|
33368
|
+
{ plc }
|
|
33369
|
+
);
|
|
33370
|
+
}
|
|
33371
|
+
const result = await mutate("POST", `/plcs/${seg(plc)}/passwordpolicy`, body, {
|
|
33372
|
+
dryRun,
|
|
33373
|
+
summary: `change the password policy of ${plc} (${Object.keys(body).join(", ")})`
|
|
33374
|
+
});
|
|
33375
|
+
return dryRun ? result : withIgnoredPolicyFields(result, body);
|
|
33376
|
+
}
|
|
33377
|
+
function registerSecurityTools(server2) {
|
|
33378
|
+
server2.registerTool(
|
|
33379
|
+
"tia_certificates",
|
|
33380
|
+
{
|
|
33381
|
+
title: "TIA \u2014 CPU certificates",
|
|
33382
|
+
description: "Lists the certificates in the CPU's local certificate store as {id, subject, validUntil, hasPrivateKey}. A CPU or firmware without a local certificate manager is refused (409). Maps to GET /plcs/{plc}/certificates. Read-only (class R).",
|
|
33383
|
+
inputSchema: { plc: external_exports.string().describe("PLC name") }
|
|
33384
|
+
},
|
|
33385
|
+
async ({ plc }) => getResult(`/plcs/${seg(plc)}/certificates`)
|
|
33386
|
+
);
|
|
33387
|
+
server2.registerTool(
|
|
33388
|
+
"tia_certificate_template",
|
|
33389
|
+
{
|
|
33390
|
+
title: "TIA \u2014 certificate template",
|
|
33391
|
+
description: "Reads the CPU's certificate template for a usage (default Tls): subject, usage, signature, validFrom, validUntil. A CPU without a local certificate manager is refused (409). Maps to GET /plcs/{plc}/certificates/template?usage=<usage>. Read-only (class R).",
|
|
33392
|
+
inputSchema: {
|
|
33393
|
+
plc: external_exports.string().describe("PLC name"),
|
|
33394
|
+
usage: external_exports.enum(CERTIFICATE_USAGES).optional().describe("certificate usage (default Tls)")
|
|
33395
|
+
}
|
|
33396
|
+
},
|
|
33397
|
+
async ({ plc, usage }) => getResult(`/plcs/${seg(plc)}/certificates/template${usage ? `?usage=${encodeURIComponent(usage)}` : ""}`)
|
|
33398
|
+
);
|
|
33399
|
+
server2.registerTool(
|
|
33400
|
+
"tia_certificate_import",
|
|
33401
|
+
{
|
|
33402
|
+
title: "TIA \u2014 import certificate (GATE G6 password)",
|
|
33403
|
+
description: `Imports a certificate file on the serve host into the CPU's local certificate store and returns {id, subject}. A password-protected file (PKCS#12 with its private key) needs \`password\`: GATE G6 \u2014 it comes from a HUMAN, never invented or guessed; the dryRun plan shows it as [redacted]. ${PLAIN_HTTP_NOTE} Offline change: it reaches the CPU only with a later compile + download. Maps to POST /plcs/{plc}/certificates/import {path, password?}. Class M-off.`,
|
|
33404
|
+
inputSchema: {
|
|
33405
|
+
plc: external_exports.string().describe("PLC name"),
|
|
33406
|
+
path: external_exports.string().describe("certificate file path on the serve host"),
|
|
33407
|
+
password: humanPassword("the file's password").optional(),
|
|
33408
|
+
...dryRunField
|
|
33409
|
+
}
|
|
33410
|
+
},
|
|
33411
|
+
async ({ plc, path, password, dryRun }) => mutate("POST", `/plcs/${seg(plc)}/certificates/import`, jsonBody({ path, password }), {
|
|
33412
|
+
dryRun,
|
|
33413
|
+
summary: `import certificate ${path} into the local store of ${plc}`,
|
|
33414
|
+
secretFields: SECRET_FIELDS
|
|
33415
|
+
})
|
|
33416
|
+
);
|
|
33417
|
+
server2.registerTool(
|
|
33418
|
+
"tia_certificate_export",
|
|
33419
|
+
{
|
|
33420
|
+
title: "TIA \u2014 export certificate",
|
|
33421
|
+
description: "Exports one certificate of the CPU's local store (id from tia_certificates) to a file on the serve host. Writes the file only \u2014 the project is not changed. Maps to POST /plcs/{plc}/certificates/{id}/export {path}. Class M-off.",
|
|
33422
|
+
inputSchema: {
|
|
33423
|
+
plc: external_exports.string().describe("PLC name"),
|
|
33424
|
+
id: certificateId,
|
|
33425
|
+
path: external_exports.string().describe("target file path on the serve host"),
|
|
33426
|
+
...dryRunField
|
|
33427
|
+
}
|
|
33428
|
+
},
|
|
33429
|
+
async ({ plc, id, path, dryRun }) => mutate("POST", `/plcs/${seg(plc)}/certificates/${id}/export`, jsonBody({ path }), {
|
|
33430
|
+
dryRun,
|
|
33431
|
+
summary: `export certificate ${id} of ${plc} to ${path}`
|
|
33432
|
+
})
|
|
33433
|
+
);
|
|
33434
|
+
server2.registerTool(
|
|
33435
|
+
"tia_certificate_delete",
|
|
33436
|
+
{
|
|
33437
|
+
title: "TIA \u2014 delete certificate",
|
|
33438
|
+
description: "Deletes one certificate (id from tia_certificates) from the CPU's local store in the project. Offline change: the CPU keeps its certificate until a later compile + download. Maps to DELETE /plcs/{plc}/certificates/{id}. Class M-off.",
|
|
33439
|
+
inputSchema: { plc: external_exports.string().describe("PLC name"), id: certificateId, ...dryRunField }
|
|
33440
|
+
},
|
|
33441
|
+
async ({ plc, id, dryRun }) => mutate("DELETE", `/plcs/${seg(plc)}/certificates/${id}`, void 0, { dryRun, summary: `delete certificate ${id} of ${plc}` })
|
|
33442
|
+
);
|
|
33443
|
+
server2.registerTool(
|
|
33444
|
+
"tia_password_policy",
|
|
33445
|
+
{
|
|
33446
|
+
title: "TIA \u2014 CPU password policy",
|
|
33447
|
+
description: "Reads the CPU's password policy: `modern` {enabled} and `legacy` {enabled, minLength, minNumeric, minSpecial, requiresMixedCase} \u2014 each null when the CPU does not expose that service. Maps to GET /plcs/{plc}/passwordpolicy. Read-only (class R).",
|
|
33448
|
+
inputSchema: { plc: external_exports.string().describe("PLC name") }
|
|
33449
|
+
},
|
|
33450
|
+
async ({ plc }) => getResult(`/plcs/${seg(plc)}/passwordpolicy`)
|
|
33451
|
+
);
|
|
33452
|
+
server2.registerTool(
|
|
33453
|
+
"tia_password_policy_set",
|
|
33454
|
+
{
|
|
33455
|
+
title: "TIA \u2014 set CPU password policy (GATE G6)",
|
|
33456
|
+
description: "Changes the CPU's password policy in the project. GATE G6: the values are the site's security decision \u2014 take them from a HUMAN, never choose them yourself. Only the fields you pass change; pass at least one. The length and complexity fields live in the legacy policy service: on a CPU that exposes only the modern service just `enabled` applies \u2014 the result then lists the dropped fields in `ignoredFields`. A CPU with neither service is refused (409). Offline change: it reaches the CPU only with a later compile + download. Maps to POST /plcs/{plc}/passwordpolicy. Class M-off.",
|
|
33457
|
+
inputSchema: {
|
|
33458
|
+
plc: external_exports.string().describe("PLC name"),
|
|
33459
|
+
enabled: external_exports.boolean().optional().describe("G6 (human decision): enforce the password policy"),
|
|
33460
|
+
minLength: policyCount("G6 (human decision): minimum password length"),
|
|
33461
|
+
minNumeric: policyCount("G6 (human decision): minimum number of digits"),
|
|
33462
|
+
minSpecial: policyCount("G6 (human decision): minimum number of special characters"),
|
|
33463
|
+
requiresMixedCase: external_exports.boolean().optional().describe("G6 (human decision): require lower- and upper-case letters"),
|
|
33464
|
+
...dryRunField
|
|
33465
|
+
}
|
|
33466
|
+
},
|
|
33467
|
+
async (args) => passwordPolicySetFlow(args)
|
|
33468
|
+
);
|
|
33469
|
+
server2.registerTool(
|
|
33470
|
+
"tia_block_protect",
|
|
33471
|
+
{
|
|
33472
|
+
title: "TIA \u2014 protect/unprotect block (GATE G6)",
|
|
33473
|
+
description: `Sets know-how protection on a PLC block with a password (protect:true, the default) or removes it (protect:false, with the same password). GATE G6: the password comes from a HUMAN \u2014 never invented, guessed or reused; a password nobody knows locks the block for good. Never retry a rejected password with a guess: after one rejected unprotect, TIA has refused even the correct password for the rest of the session. The dryRun plan shows the password as [redacted]. ${PLAIN_HTTP_NOTE} Maps to POST /plcs/{plc}/blocks/{block}/protect {password, protect}. Class M-off.`,
|
|
33474
|
+
inputSchema: {
|
|
33475
|
+
plc: external_exports.string().describe("PLC name"),
|
|
33476
|
+
block: external_exports.string().describe("block name"),
|
|
33477
|
+
password: humanPassword("the know-how password"),
|
|
33478
|
+
protect: external_exports.boolean().optional().describe("true = protect (default), false = remove the protection"),
|
|
33479
|
+
...dryRunField
|
|
33480
|
+
}
|
|
33481
|
+
},
|
|
33482
|
+
async ({ plc, block, password, protect, dryRun }) => mutate("POST", `/plcs/${seg(plc)}/blocks/${seg(block)}/protect`, jsonBody({ password, protect }), {
|
|
33483
|
+
dryRun,
|
|
33484
|
+
summary: `${protect === false ? "remove know-how protection from" : "set know-how protection on"} block ${block} of ${plc}`,
|
|
33485
|
+
secretFields: SECRET_FIELDS
|
|
33486
|
+
})
|
|
33487
|
+
);
|
|
33488
|
+
}
|
|
33489
|
+
|
|
33110
33490
|
// src/planStore.ts
|
|
33111
33491
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
33112
33492
|
var PLAN_TTL_MS = parsePositiveInt(process.env.TIA_PLAN_TTL_MS, 9e5);
|
|
@@ -34156,11 +34536,11 @@ function registerSpecTools(server2) {
|
|
|
34156
34536
|
}
|
|
34157
34537
|
|
|
34158
34538
|
// src/content.gen.ts
|
|
34159
|
-
var BRIEF = '# TIA Openness MCP \u2014 operating brief\n\nYou are driving Siemens TIA Portal V21 through the `tia_*` tools (an MCP over the TIA\nOpenness HTTP `serve`). This brief is ALWAYS in effect. For depth, call the `tia_guide`\ntool (topics: `gates-guards`, `gui-gates`, `gotchas`, `pipeline`, `recipes`,\n`spec-format`) \u2014 read the relevant topic BEFORE authoring blocks, changing hardware,\nor preparing a deploy. You are an assistant up to the gate, never an autonomous\ncommissioner.\n\n## Vocabulary (used across all tool descriptions)\n\n- **Class R** \u2014 read-only; safe anytime.\n- **Class M-off** \u2014 offline mutation (edits the project; never touches the physical PLC).\n- **Class GATE** \u2014 touches the physical world or a human-only decision; needs a human.\n- **G1..G7** \u2014 the GATES: G1 trust dialog, G2 S7-connection precondition (tool-enforced:\n both CPUs must compile clean), G3 download / CPU-STOP, G4 go-online (incl. station upload),\n G5 safety / F-logic (NEVER autonomous), G6 master
|
|
34160
|
-
var GATES_GUARDS = '# Gates vs guards\n\n## GATES vs GUARDS\n\n- **GATES (human-only \u2014 never auto-bypass):** trust dialog (**G1**), download / CPU-STOP\n (**G3**), go-online (**G4**, which includes a **station upload** (`tia_upload`): it goes\n online to read the CPU), network scan / accessible-devices (**G7**), master-secret/UMAC\n (**G6**, which includes a CPU **read-access password** for an upload), **safety / F-logic\n (G5) \u2014 never autonomous**.\n- **GUARDS (tool-enforced preconditions):** compile-clean before deploy, consistency,\n dry-run\u2192approve, idempotency by name, `OrderNumber:<MLFB>/V<fw>` format, serial-only.\n- Back up a physical CPU with the **`tia.backup`** skill (dedicated empty project; the upload\n token is bound to the project shown in the handoff).\n- **Picking the G3 download path (no gate, no scan):** `tia_pg_interfaces` lists the connection\n modes/PG-PC interfaces TIA already sees for the CPU (plus the OS status of each adapter) \u2014\n use it to fill `connectionMode`/`pcInterfaceName`/`targetInterfaceName` for `tia_download`\n instead of reaching for `tia_accessible_devices` (a real network scan, GATE G7).\n- **GUI-ONLY settings (NOT exposed via Openness \u2014 surface as a human gate, do not script):**\n "Permit access with PUT/GET communication", OPC UA **runtime license** / server-interface\n creation. (OPC UA server **activation** is the exception \u2014 settable via Openness with\n `tia_obj_set_attributes {OpcUaServer:true}` on the "OPC UA" device-item.)\n\n**Deploy-time approval gates** (download / online / network-scan / secret / safety = **G3/G4/G7/G6/G5**)\nare a *different* class \u2014 see the **`tia.handoff`** skill. Those are "a human **approves an action**",\nnot "a human **clicks a GUI setting**". Both are human interaction points; surface them as\n`requires_human_action` with concrete guidance, never as a tool failure.\n';
|
|
34539
|
+
var BRIEF = '# TIA Openness MCP \u2014 operating brief\n\nYou are driving Siemens TIA Portal V21 through the `tia_*` tools (an MCP over the TIA\nOpenness HTTP `serve`). This brief is ALWAYS in effect. For depth, call the `tia_guide`\ntool (topics: `gates-guards`, `gui-gates`, `gotchas`, `pipeline`, `recipes`,\n`spec-format`) \u2014 read the relevant topic BEFORE authoring blocks, changing hardware,\nor preparing a deploy. You are an assistant up to the gate, never an autonomous\ncommissioner.\n\n## Vocabulary (used across all tool descriptions)\n\n- **Class R** \u2014 read-only; safe anytime.\n- **Class M-off** \u2014 offline mutation (edits the project; never touches the physical PLC).\n- **Class GATE** \u2014 touches the physical world or a human-only decision; needs a human.\n- **G1..G7** \u2014 the GATES: G1 trust dialog, G2 S7-connection precondition (tool-enforced:\n both CPUs must compile clean), G3 download / CPU-STOP, G4 go-online (incl. station upload),\n G5 safety / F-logic (NEVER autonomous), G6 credentials \u2014 master secret, UMAC, upload /\n block / certificate passwords, password policy (from a human \u2014 never invented), G7 network\n scan. All except G2 are human-only \u2014 never crossed autonomously.\n- **Gd\\*** \u2014 tool-enforced GUARDS (preconditions the tools check), e.g. Gd5\n `OrderNumber:<MLFB>/V<fw>` format (slash before V, never `:V`), Gd8 only ERRORs block\n a compile (warnings don\'t), Gd9 clean compile before deploy, Gd11 dryRun-then-approve.\n\n## Non-negotiable rules\n\n1. **Serial only.** The serve owns ONE TIA Portal on ONE serial worker. Never fire\n concurrent `tia_*` calls; one hung Openness call can stall the whole serve.\n2. **Never cross a GATE autonomously.** A `requires_human_action` response is a HANDOFF,\n not an error: relay its `youMustDo`/`nextSteps` to the human verbatim, wait for their\n explicit yes, then resume exactly as instructed. Never self-approve a download; never\n invent a secret (G6); never author, modify or deploy safety/F logic (G5).\n3. **Compile before deploy.** `tia_compile` aggregates hardware + software and is the\n offline verifier: `errors:0` is the Gd9 precondition for download (G3) and for S7\n connections.\n4. **Follow the build pipeline order** (details: `tia_guide {"topic":"pipeline"}`):\n validate the spec (`tia_spec_validate`) \u2192 plan (`tia_spec_plan`) \u2192 scaffold\n (`tia_spec_apply` or the M-off tools) \u2192 verify (`tia_compile`) \u2192 human-gated deploy\n (`tia_download` with dryRun \u2192 human approval \u2192 `approved:true` + the same `planHash`).\n5. **Some CPU settings are GUI-only** (PUT/GET permission, OPC UA runtime license,\n OPC UA server interface). Hitting one is EXPECTED, not a bug: relay the exact GUI\n steps from `tia_guide {"topic":"gui-gates"}` and resume after the human confirms.\n6. **Prerequisites:** the serve must be running (default `http://localhost:5000` \u2014\n check with `tia_ping`); the FIRST connect per serve process hits the G1 trust dialog\n on the serve host.\n7. **Long operations are jobs.** A tool whose description says "Long operation" (connect,\n compile, download, upload, project create/save/archive, exports, CAx\u2026) may answer `status:"running"` with a\n `jobId` \u2014 the operation is STILL running on serve. Call `tia_job_status {jobId}`\n until it returns the final result; never repeat the original call. While a job runs,\n any OTHER ordinary serve-bound tool answers `kind:"busy"` (with `details.jobId`) \u2014 that is\n expected, not a failure: go back to `tia_job_status`. Offline tools (`tia_guide`,\n `tia_spec_validate`, `tia_spec_plan`, `tia_job_status` itself) never answer busy.\n `tia_ping` is the diagnostic exception: it probes `/health`, which bypasses the busy guard,\n and returns a reachability report (`reachable:true`, `activated:null` while a job runs) with\n no top-level `kind` and no `details.jobId` \u2014 use it to check reachability, never to obtain the job ID.\n\nSession start: `tia_ping` \u2192 `tia_status` \u2192 (if needed) `tia_start` / `tia_connect`.\nBefore the first build on a project: read `tia_guide {"topic":"pipeline"}` and\n`tia_guide {"topic":"gotchas"}`.\n';
|
|
34540
|
+
var GATES_GUARDS = '# Gates vs guards\n\n## GATES vs GUARDS\n\n- **GATES (human-only \u2014 never auto-bypass):** trust dialog (**G1**), download / CPU-STOP\n (**G3**), go-online (**G4**, which includes a **station upload** (`tia_upload`): it goes\n online to read the CPU), network scan / accessible-devices (**G7**), master-secret/UMAC\n (**G6**, which includes a CPU **read-access password** for an upload, a block **know-how\n password** (`tia_block_protect`), a certificate file\'s password (`tia_certificate_import`)\n and the **password-policy** values (`tia_password_policy_set`)), **safety / F-logic\n (G5) \u2014 never autonomous**.\n- **GUARDS (tool-enforced preconditions):** compile-clean before deploy, consistency,\n dry-run\u2192approve, idempotency by name, `OrderNumber:<MLFB>/V<fw>` format, serial-only.\n- Back up a physical CPU with the **`tia.backup`** skill (dedicated empty project; the upload\n token is bound to the project shown in the handoff).\n- **Picking the G3 download path (no gate, no scan):** `tia_pg_interfaces` lists the connection\n modes/PG-PC interfaces TIA already sees for the CPU (plus the OS status of each adapter) \u2014\n use it to fill `connectionMode`/`pcInterfaceName`/`targetInterfaceName` for `tia_download`\n instead of reaching for `tia_accessible_devices` (a real network scan, GATE G7).\n- **GUI-ONLY settings (NOT exposed via Openness \u2014 surface as a human gate, do not script):**\n "Permit access with PUT/GET communication", OPC UA **runtime license** / server-interface\n creation. (OPC UA server **activation** is the exception \u2014 settable via Openness with\n `tia_obj_set_attributes {OpcUaServer:true}` on the "OPC UA" device-item.)\n\n**Deploy-time approval gates** (download / online / network-scan / secret / safety = **G3/G4/G7/G6/G5**)\nare a *different* class \u2014 see the **`tia.handoff`** skill. Those are "a human **approves an action**",\nnot "a human **clicks a GUI setting**". Both are human interaction points; surface them as\n`requires_human_action` with concrete guidance, never as a tool failure.\n';
|
|
34161
34541
|
var GUI_GATES = '# GUI gates \u2014 expected human interaction points\n\n## Human interaction points (GUI gates) \u2014 EXPECTED, not an error\n\nSome TIA settings are **not reachable via Openness** on the S7-1200/1500. The harness will hit a\nsignal that *looks* like an error but is actually a point where a **human must act in the TIA GUI**.\nWhen you see one of these, **do not treat it as a failure and do not retry blindly** \u2014 recognize it,\ntell the human the **exact GUI steps**, and resume after they confirm. A GUI gate is a *handoff*, not a *bug*.\n\n| # | Signal you\'ll see | Why it\'s expected | Tell the human (exact GUI steps) |\n|---|---|---|---|\n| **G1 trust** | `tia_connect` \u2192 `requires_human_action` (`trust_dialog`), or the **1st** TIA-starting call per `serve` process goes **~180 s** (`TIA_CONNECT_TIMEOUT_MS`) without an answer \u2014 `tia_connect`, `tia_start`, `tia_show_ui` and `tia_project_create` all share that wait, and a client timeout with `/health` alive yields the same `trust_dialog` handoff. A `running` answer from any of them can still mean a trust dialog is waiting on the serve host | TIA shows a one-time security prompt the first time an Openness app attaches, **per process** | On the **serve host**, in TIA Portal, click **"Yes to all"** in the access dialog. *Caveat:* it can false-positive on a client timeout with **no** real dialog \u2014 check `tia_status` (**`hasProject:true`**, not `attached:true`) and\u2026 If the handoff state is `TRUST_DIALOG_DENIED_OR_EXPIRED`, the dialog was denied or left to expire: the serve lists what it closed (`closedPids`), what is still running (`stillRunningPids`) and what it could not confirm (`unknownPids`) \u2014 close any still-running TIA (no project inside) before re-calling, and for an unconfirmed pid first verify in Task Manager that it is a TIA Portal started by this serve with no open project, with a human ready to click **"Yes to all"**. |\n| **OPC UA license** | `tia_compile` **ERROR**: *"The selected OPC UA license is not sufficient\u2026"* | License selection is GUI-only (no Openness service); a fresh project **or a firmware change** leaves it unset | CPU \u2192 **Properties \u2192 General \u2192 Runtime licenses \u2192 OPC UA** \u2192 *Type of required license* \u2192 select **"SIMATIC OPC UA S7-1200 Basic"** (the 1214C option). Recompile. |\n| **OPC UA interface** | OPC UA client connects but the DB nodes aren\'t there (`ns=4` empty / no `ServerInterfaces`) | The **S7-1200 does NOT auto-expose DBs** (unlike the S7-1500) \u2014 a server interface must be created by hand | CPU \u2192 **OPC UA \u2192 Server interfaces \u2192 Add new server interface** \u2192 add/drag the DB (e.g. `ModbusData`) into it. Recompile; data appears under `ns=4`. |\n| **PUT/GET** | S7 client (`nodes7`/`snap7`) connects on port 102 but reads return access-denied (`ROSCTR=2` / "BAD") | *"Permit access with PUT/GET"* is a GUI-only protection setting | CPU \u2192 **Properties \u2192 Protection & Security \u2192 Connection mechanisms** \u2192 check **"Permit access with PUT/GET communication from remote partner"**. Compile + download (`hardware:true`). |\n| **FW-change reset** | After `tia_device_change_version`: OPC UA server off, the license error on compile, blocks `isConsistent:false` | `DeviceItem.ChangeType` **resets GUI-gated comm settings** (server activation + license); the interface & PUT/GET survive | `tia_project_archive` **before** the FW change. After: re-set `OpcUaServer:true` via `tia_obj_set_attributes` (scriptable), re-select the license (row above), recompile. |\n\n**Not a gate (now scriptable):** *activating* the OPC UA server \u2014 `tia_obj_set_attributes {OpcUaServer:true}`\non the "OPC UA" device-item (it auto-generates the server certificate). Only the **license** and the\n**server interface** stay GUI-only.\n';
|
|
34162
|
-
var GOTCHAS = '# Hard-won gotchas (runtime-validated)\n\n## Hard-won gotchas\n\n1. **Always compile before deploy.** `tia_compile` aggregates **hardware + software**; a\n **clean** compile (`errors:0`) is the precondition for download and for S7 connections.\n2. **The serve is a SINGLE serial worker** \u2014 one Openness op at a time. Do **not** fire\n concurrent `tia_*` calls; a hung Openness op can stall the serve (may need a restart).\n3. **Changing an FB\'s interface (e.g. regenerating it via `tia_source_put`) leaves its\n instance DB inconsistent.** Recompile FIRST: a software-scope `tia_compile` regenerates\n the instance DB in most cases \u2014 read the compile result\'s **`blockChanges`** (`tia_compile`\n and `tia_source_put {compile:true}` both return it): a `"change":"modified"` entry on the\n instance DB is your confirmation it was regenerated \u2014 **export and commit it**\n (`tia_export_block`/`tia_block_compare`) so what\'s versioned matches the project. Only if\n the DB still reports inconsistent after a compile, delete it (`tia_block_delete`),\n recreate it (`tia_instancedb_create`) and recompile.\n4. **Firmware rule: project FW \u2264 device FW.** Bump the project FW **in-place** with\n `tia_device_change_version` (`DeviceItem.ChangeType`), which preserves the **program** \u2014 never\n set the project higher than the physical CPU. **\u26A0\uFE0F It RESETS GUI-gated comm settings** (the\n **OPC UA server activation** + **runtime-license**; the server interface and PUT/GET survive):\n **archive first** (`tia_project_archive`) on a CPU with hand-configured OPC UA, recompile after\n (it marks blocks inconsistent), and re-verify. Same-version `ChangeType` is rejected.\n5. **Use a NON-optimized DB** for Modbus (`MB_HOLD_REG`) and S7 (absolute addressing); OPC UA\n works with optimized or not.\n6. **Order numbers use `/V<fw>`, not `:V<fw>`** (guard Gd5).\n7. **A station upload (`tia_upload`) ADDS a new station to the open project \u2014 back up into a\n dedicated EMPTY project.** Observed on hardware (S7-1200 1214C, 2026-09-26): the upload read\n the CPU into an empty project (0 \u2192 1 device, twice) in ~75 s (76.7 s and 74.2 s); the CPU\n stayed in RUN the whole time (owner watching its LEDs during the second upload). Protect the\n working project FIRST: `tia_project_create` CLOSES the current project without saving, so\n `tia_project_save` + `tia_project_archive` before creating the backup project \u2014 and pass the\n archive `name` WITH the `.zap21` extension (`name` absent or extension-less fails; with\n `.zap21` it archived 1.6 MB).\n\n## Prerequisites (environment)\n\n- The **`tia` serve must be running** (default `http://localhost:5000`, e.g.\n `TIAOpenness.exe serve 5000`). The MCP is a pure HTTP client; point it at the serve host via\n `TIA_API_BASE` if it runs elsewhere.\n- The Windows user must belong to the **"Siemens TIA Openness"** local group.\n- The **FIRST connection per serve process shows a trust dialog** that a **human must confirm**\n ("Yes to all") on the serve host \u2014 this **cannot be automated** (gate G1).\n';
|
|
34163
|
-
var PIPELINE = '# The build pipeline (spec \u2192 verified project)\n\nStages in order \u2014 the class tells you what each stage may do:\n\n| # | Stage | Tool(s) | Class | What it does |\n|---|---|---|---|---|\n| 0 | Validate the spec | `tia_spec_validate` | R (pure) | JSON-Schema + cross-field engineering rules (unique names, same-subnet IPs, Gd5 order-number format, per-CPU module limits, language-by-family, the G5 safety rule). Needs no serve. |\n| 1 | Plan | `tia_spec_plan` | R (pure) | Turns a VALID spec into the ordered list of M-off operations. Nothing mutates. |\n| 2 | Scaffold | `tia_spec_apply` (or the M-off tools manually) | M-off | Creates the project content in dependency order (see below). Stops at every gate. |\n| 3 | Verify | `tia_compile` | M-off | THE offline verifier: aggregates hardware + software. Gd8: only ERRORs block. `errors:0` is the Gd9 precondition for any deploy. |\n| 4 | Handoff / deploy | `tia_download` | GATE G3 | `dryRun:true` asks serve for a VERIFIED plan (clean compile, resolved connection, software fingerprint) \u2192 plan + `planHash` \u2192 a HUMAN approves \u2192 re-call with `approved:true` + the SAME `planHash` (serve re-checks the fingerprint and refuses `plan_stale` if the software changed). The approval covers the connection/options and the covered software content \u2014 NOT the hardware configuration (a hardware change after approval passes the token check). Re-plan (new dryRun) + fresh human approval only when the hardware configuration changed AFTER the dryRun that produced the token \u2014 the fingerprint cannot detect that change, so the human must confirm nothing hardware-side moved; never reuse the old token for changed hardware. Fingerprint limits: user program blocks, UDTs and tag tables only \u2014 no hardware configuration, system block groups, S7-1500 software units or technology objects; per-object fallback to modification dates (`source:"dates"`, warned in the plan \u2014 dates can false-positive `plan_stale`). Never self-approve. Pick the connection with `tia_pg_interfaces` (no scan). |\n\nScaffold order (dependency-correct): subnets \u2192 devices (CPUs first) \u2192 modules \u2192\nnetwork/IP/IO-system \u2192 protection recipe (`tia_guide {"topic":"recipes"}`) \u2192 tag\ntables \u2192 tags \u2192 constants \u2192 UDTs BEFORE dependent blocks \u2192 FB shells + instance DBs \u2192\nlogic (SCL/STL via `tia_source_put`; LAD/FBD/GRAPH via `tia_import_xml` \u2014 Gd6 format\nrouting) \u2192 `tia_compile`.\n\n## The approval envelope (what a gate handoff looks like)\n\nGated tools return `status:"requires_human_action"` with:\n\n- `gate` \u2014 which gate (e.g. `download_approval`, `station_upload`, `go_online`, `trust_dialog`);\n- `youMustDo` \u2014 what the human must confirm, in plain words;\n- `plan` + `planHash` \u2014 exactly what would be executed (the hash binds the approval to\n this exact plan; a changed plan needs a new approval); the download\'s plan also carries\n `fingerprint` (the software content the plan was verified against \u2014 show it too);\n- `nextSteps` \u2014 how to resume after the human\'s yes.\n\nRelay the envelope to the human, wait for an explicit yes, resume exactly as\ninstructed. The AI never approves, never invents a secret, never deploys F-logic.\n\n## After scaffolding\n\n- Re-run `tia_compile` after ANY authoring change.\n- `tia_project_save` regularly; `tia_project_archive` BEFORE risky operations\n (firmware change \u2014 see `tia_guide {"topic":"gotchas"}`).\n- Auditing an existing project is class R: read blocks/types/tags via `tia_plc_*` and\n check the engineering baseline (optimized access, 100% symbolic, UDT-typed\n interfaces, FB + instance-DB, uniform naming).\n- **The project matches what\'s versioned \u2014 prove it, don\'t assume it.** A raw hash of an\n export is NOT proof (two exports of the same block differ in `<Created>`/UIds). Use\n `tia_export_block` to pull a block inline and `tia_block_compare` to diff it against the\n committed XML (normalized \u2014 ignores formatting/BOM/`<Created>`/UIds); `verdict:"equal"` is\n the actual round-trip proof. After `tia_compile`/`tia_source_put`, read `blockChanges` and\n export/commit any regenerated instance DBs before calling the project verified.\n';
|
|
34542
|
+
var GOTCHAS = '# Hard-won gotchas (runtime-validated)\n\n## Hard-won gotchas\n\n1. **Always compile before deploy.** `tia_compile` aggregates **hardware + software**; a\n **clean** compile (`errors:0`) is the precondition for download and for S7 connections.\n2. **The serve is a SINGLE serial worker** \u2014 one Openness op at a time. Do **not** fire\n concurrent `tia_*` calls; a hung Openness op can stall the serve (may need a restart).\n3. **Changing an FB\'s interface (e.g. regenerating it via `tia_source_put`) leaves its\n instance DB inconsistent.** Recompile FIRST: a software-scope `tia_compile` regenerates\n the instance DB in most cases \u2014 read the compile result\'s **`blockChanges`** (`tia_compile`\n and `tia_source_put {compile:true}` both return it): a `"change":"modified"` entry on the\n instance DB is your confirmation it was regenerated \u2014 **export and commit it**\n (`tia_export_block`/`tia_block_compare`) so what\'s versioned matches the project. Only if\n the DB still reports inconsistent after a compile, delete it (`tia_block_delete`),\n recreate it (`tia_instancedb_create`) and recompile.\n4. **Firmware rule: project FW \u2264 device FW.** Bump the project FW **in-place** with\n `tia_device_change_version` (`DeviceItem.ChangeType`), which preserves the **program** \u2014 never\n set the project higher than the physical CPU. **\u26A0\uFE0F It RESETS GUI-gated comm settings** (the\n **OPC UA server activation** + **runtime-license**; the server interface and PUT/GET survive):\n **archive first** (`tia_project_archive`) on a CPU with hand-configured OPC UA, recompile after\n (it marks blocks inconsistent), and re-verify. Same-version `ChangeType` is rejected.\n5. **Use a NON-optimized DB** for Modbus (`MB_HOLD_REG`) and S7 (absolute addressing); OPC UA\n works with optimized or not.\n6. **Order numbers use `/V<fw>`, not `:V<fw>`** (guard Gd5).\n7. **A station upload (`tia_upload`) ADDS a new station to the open project \u2014 back up into a\n dedicated EMPTY project.** Observed on hardware (S7-1200 1214C, 2026-09-26): the upload read\n the CPU into an empty project (0 \u2192 1 device, twice) in ~75 s (76.7 s and 74.2 s); the CPU\n stayed in RUN the whole time (owner watching its LEDs during the second upload). Protect the\n working project FIRST: `tia_project_create` CLOSES the current project without saving, so\n `tia_project_save` + `tia_project_archive` before creating the backup project \u2014 and pass the\n archive `name` WITH the `.zap21` extension (`name` absent or extension-less fails; with\n `.zap21` it archived 1.6 MB).\n8. **One wrong know-how password can lock a block for the session.** Observed on the bench\n (2026-10-12): after one rejected unprotect (`tia_block_protect {protect:false}`), TIA refused\n the CORRECT password of that block for the rest of the session (cause not confirmed \u2014 possibly\n brute-force protection). Never retry with a guess \u2014 ask the human for the password (G6); if a\n password the human confirms is refused, stop and hand off instead of retrying.\n\n## Prerequisites (environment)\n\n- The **`tia` serve must be running** (default `http://localhost:5000`, e.g.\n `TIAOpenness.exe serve 5000`). The MCP is a pure HTTP client; point it at the serve host via\n `TIA_API_BASE` if it runs elsewhere.\n- The Windows user must belong to the **"Siemens TIA Openness"** local group.\n- The **FIRST connection per serve process shows a trust dialog** that a **human must confirm**\n ("Yes to all") on the serve host \u2014 this **cannot be automated** (gate G1).\n';
|
|
34543
|
+
var PIPELINE = '# The build pipeline (spec \u2192 verified project)\n\nStages in order \u2014 the class tells you what each stage may do:\n\n| # | Stage | Tool(s) | Class | What it does |\n|---|---|---|---|---|\n| 0 | Validate the spec | `tia_spec_validate` | R (pure) | JSON-Schema + cross-field engineering rules (unique names, same-subnet IPs, Gd5 order-number format, per-CPU module limits, language-by-family, the G5 safety rule). Needs no serve. |\n| 1 | Plan | `tia_spec_plan` | R (pure) | Turns a VALID spec into the ordered list of M-off operations. Nothing mutates. |\n| 2 | Scaffold | `tia_spec_apply` (or the M-off tools manually) | M-off | Creates the project content in dependency order (see below). Stops at every gate. |\n| 3 | Verify | `tia_compile` | M-off | THE offline verifier: aggregates hardware + software. Gd8: only ERRORs block. `errors:0` is the Gd9 precondition for any deploy. |\n| 4 | Handoff / deploy | `tia_download` | GATE G3 | `dryRun:true` asks serve for a VERIFIED plan (clean compile, resolved connection, software fingerprint) \u2192 plan + `planHash` \u2192 a HUMAN approves \u2192 re-call with `approved:true` + the SAME `planHash` (serve re-checks the fingerprint and refuses `plan_stale` if the software changed). The approval covers the connection/options and the covered software content \u2014 NOT the hardware configuration (a hardware change after approval passes the token check). Re-plan (new dryRun) + fresh human approval only when the hardware configuration changed AFTER the dryRun that produced the token \u2014 the fingerprint cannot detect that change, so the human must confirm nothing hardware-side moved; never reuse the old token for changed hardware. Fingerprint limits: user program blocks, UDTs and tag tables only \u2014 no hardware configuration, system block groups, S7-1500 software units or technology objects; per-object fallback to modification dates (`source:"dates"`, warned in the plan \u2014 dates can false-positive `plan_stale`). Never self-approve. Pick the connection with `tia_pg_interfaces` (no scan). |\n\nScaffold order (dependency-correct): subnets \u2192 devices (CPUs first) \u2192 modules \u2192\nnetwork/IP/IO-system \u2192 protection recipe (`tia_guide {"topic":"recipes"}`) \u2192 tag\ntables \u2192 tags \u2192 constants \u2192 UDTs BEFORE dependent blocks \u2192 FB shells + instance DBs \u2192\nlogic (SCL/STL via `tia_source_put`; LAD/FBD/GRAPH via `tia_import_xml` \u2014 Gd6 format\nrouting) \u2192 `tia_compile`.\n\n## The approval envelope (what a gate handoff looks like)\n\nGated tools return `status:"requires_human_action"` with:\n\n- `gate` \u2014 which gate (e.g. `download_approval`, `station_upload`, `go_online`, `trust_dialog`);\n- `youMustDo` \u2014 what the human must confirm, in plain words;\n- `plan` + `planHash` \u2014 exactly what would be executed (the hash binds the approval to\n this exact plan; a changed plan needs a new approval); the download\'s plan also carries\n `fingerprint` (the software content the plan was verified against \u2014 show it too);\n- `nextSteps` \u2014 how to resume after the human\'s yes.\n\nRelay the envelope to the human, wait for an explicit yes, resume exactly as\ninstructed. The AI never approves, never invents a secret, never deploys F-logic.\n\n## After scaffolding\n\n- Re-run `tia_compile` after ANY authoring change.\n- `tia_project_save` regularly; `tia_project_archive` BEFORE risky operations\n (firmware change \u2014 see `tia_guide {"topic":"gotchas"}`).\n- Auditing an existing project is class R: read blocks/types/tags via `tia_plc_*` and\n check the engineering baseline (optimized access, 100% symbolic, UDT-typed\n interfaces, FB + instance-DB, uniform naming).\n- **The project matches what\'s versioned \u2014 prove it, don\'t assume it.** A raw hash of an\n export is NOT proof (two exports of the same block differ in `<Created>`/UIds). Use\n `tia_export_block` to pull a block inline and `tia_block_compare` to diff it against the\n committed XML (normalized \u2014 ignores formatting/BOM/`<Created>`/UIds); `verdict:"equal"` is\n the actual round-trip proof. After `tia_compile`/`tia_source_put`, read `blockChanges` and\n export/commit any regenerated instance DBs before calling the project verified.\n\n## Libraries, HMI, CAx and PLC security\n\nReads are class R; every change is class M-off (offline, with `dryRun`) and reaches the CPU\nonly through a later `tia_compile` + human-gated `tia_download` (G3). Every file path is a\npath ON THE SERVE HOST.\n\n- **Project library:** `tia_library_mastercopies` / `tia_library_types` read it;\n `tia_library_mastercopy_create` turns a DEVICE into a master copy (a block cannot be a source).\n `tia_block_from_mastercopy` needs a master copy that holds PLC blocks \u2014 a device copy is\n refused (`409 mastercopy_not_blocks` after app 1.6.3; up to 1.6.3 a 500).\n- **Global libraries** live in the TIA Portal session, not the project: `tia_global_libraries`,\n `tia_global_library_create` / `_open` / `_save` / `_close`. Save/close take the name from\n `tia_global_libraries` (exact name first, then ignoring case). After app 1.6.3 a name that\n picks no single open USER library is refused, nothing saved or closed: `404 not_found`\n (`details.userLibraries` lists the names that work), or `409 conflict` for a read-only\n system/corporate library or a name several user libraries match only ignoring case; up to\n 1.6.3 the serve reports success even for an unknown name.\n- **HMI:** `tia_hmis` and `tia_hmi_screens` read any HMI; screen files\n (`tia_hmi_screen_export`, `tia_hmi_screens_import`) work for WinCC **Classic** only, and the\n import OVERWRITES same-named screens.\n- **CAx (AutomationML):** `tia_cax_export` (one device or the whole project) and\n `tia_cax_import` (`option`: `RetainTiaDevice` default / `OverwriteTiaDevice` /\n `MoveToParkingLot`). Archive the project before an overwrite. A failed transfer is an error\n (`500 cax_transfer_failed`) after app 1.6.3; up to 1.6.3 the serve returns an opaque\n `result` even on failure \u2014 check the devices with `tia_devices`.\n- **PLC security:** `tia_certificates` / `tia_certificate_template` / `tia_password_policy`\n read; `tia_certificate_import` / `_export` / `_delete`, `tia_password_policy_set` and\n `tia_block_protect` change the project. **G6:** a block or certificate password and the\n password-policy values come from a HUMAN \u2014 never invent, guess or reuse one; dryRun plans\n show a password as `[redacted]`. A CPU without the certificate manager or a policy service\n answers 409.\n- **Multiuser:** `tia_local_sessions` lists the local sessions (empty in a single-user project).\n';
|
|
34164
34544
|
var RECIPES = '# Recipes (runtime-verified) & scaffold order\n\n## Pipeline order (dependency-correct)\n\n`tia_spec_apply` already encodes this; use it manually only when the spec maps imperfectly.\n\n1. **Subnets** (`tia_subnet_create`) \u2014 before connecting devices to them.\n2. **Devices** (`tia_device_create`, `OrderNumber:<MLFB>/V<fw>`) \u2014 CPUs first.\n3. **Modules** (`tia_device_plug`) \u2014 into existing devices, by slot.\n4. **Network** (`tia_network_connect`, IP, `createIoSystem`) \u2014 CPU + its IO-devices on the\n **same** subnet; exactly one `createIoSystem` per IO-system.\n5. **Protection recipe** (below) \u2014 so the CPU can compile clean.\n6. **Tag tables** (`tia_tagtable_create`) \u2192 **tags** (`tia_tag_create`) \u2192 **constants**.\n7. **UDTs first** (`tia_types_import`), **then** blocks that use them.\n8. **Blocks** \u2014 FB shells (`tia_fb_create`) + instance DBs (`tia_instancedb_create`);\n logic via `tia_source_put` (SCL) or `tia_import_xml` (LAD/FBD/GRAPH). Gd6 format routing.\n9. **Compile** (`tia_compile`) \u2014 the verifier; only `Error` blocks. It compiles the **software**\n scope (not just the CPU device item), so it makes freshly-generated blocks consistent and, in\n most cases, **regenerates** any instance DB left inconsistent by an FB interface change.\n **Recompile first**; only if the DB still reports inconsistent after a compile, delete it\n (`tia_block_delete`), recreate it (`tia_instancedb_create`) and recompile.\n\n## Recipe \u2014 unlock a freshly-created CPU so it compiles clean (VERIFIED V21, firmware-dependent)\n\nA bare CPU added via Openness may fail `compile` with **protection** errors: the\n*confidential-PLC-configuration-data* password is unset, the *communication certificate*\ncan\'t be generated without it, and (on newer firmware) the *access control* defaults to a\nprotected level needing a password. **The recipe differs by CPU family/firmware \u2014 there is\nno single universal form.** Fix, in order:\n\n**(1) Confidential-data password \u2192 also auto-generates the certificate** (common to both\nfamilies):\n\n```\n# find the CPU device-item handle:\ntia_obj_roots -> the device handle (role:"device")\ntia_obj_items { handle:<device>, composition:"DeviceItems" } -> the CPU item handle\n# acquire the service ON THE CPU MODULE (not the rack) and invoke Protect:\ntia_obj_service { handle:<cpu>, type:"Siemens.Engineering.HW.Features.PlcMasterSecretConfigurator" } -> <svc>\ntia_obj_invoke { handle:<svc>, name:"Protect", args:["<password>"] }\n```\n\n**(2) Clear the access-control error \u2014 pick the variant for the CPU\'s family/firmware:**\n\n- **S7-1500 V2.9** (verified 2026 on real hardware \u2014 a 1516-3 V2.9, 3 errors \u2192 0): set\n `PlcProtectionAccessLevel = "FullAccess"` **on the CPU device item**:\n\n ```\n tia_obj_set_attributes { handle:<cpu>, attributes:{ "PlcProtectionAccessLevel":"FullAccess" } }\n ```\n\n- **S7-1200 V4.7** (new security model, FW \u2273 V4.5; per `docs/HARNESS-KNOWLEDGE.md` \xA72,\n runtime-observed): set `PlcAccessControlConfiguration = "Disabled"` on the\n **`PlcAccessControlConfigurationProvider`** SERVICE \u2014 not a direct attribute on the CPU\n item:\n\n ```\n tia_obj_service { handle:<cpu>, type:"Siemens.Engineering.HW.Features.PlcAccessControlConfigurationProvider" } -> <svc2>\n tia_obj_set_attributes { handle:<svc2>, attributes:{ "PlcAccessControlConfiguration":"Disabled" } }\n ```\n\n \u26A0\uFE0F **The two variants are mutually exclusive \u2014 the wrong one returns HTTP 500 on the\n other family:** `PlcAccessControlConfiguration` isn\'t on a 1500\'s CPU item, and\n `PlcProtectionAccessLevel` isn\'t the right model on a 1200 V4.7 item. Detect the\n family/FW \u2014 or the compile-error signature \u2014 before picking a variant.\n\n- **S7-1200 V4.0** (old security model): nothing to do here \u2014 the same bare-CPU condition\n is only a **WARNING**, not an error; a plain `tia_compile` already returns `errors: 0`.\n\nThen `tia_compile` \u2192 `state: Warning, errors: 0` (any remaining warnings \u2014 e.g. CPU-display\npassword \u2014 are benign and do **not** block; Gd8).\n\n> **Requires the `tia_obj_service` tool** (acquire `GetService<T>` \u2192 handle) for step 1 and\n> for the S7-1200 V4.7 variant of step 2. Without it the MCP cannot run either.\n\n### Open policy \u2014 who supplies the confidential password\n\n`Protect()` sets an **offline project** password (it is not the online master secret / G6).\nThe repo docs treat it as offline authoring ("no human needed"), but it protects confidential\nconfig data \u2014 so this is a **harness policy decision**: either (a) the human/spec supplies it\n(`spec.security.confidentialPassword`), or (b) the harness uses a documented project default.\nDefault to asking the human if the spec doesn\'t carry it; never invent a *secret the user\nmust later know* silently. The online master secret (`tia_mastersecret_set`, G6) is **always**\nhuman-supplied.\n\n## S7 connection precondition (G2)\n\n`tia_connection_create` needs **\u2265 2 CONSISTENT CPUs** (both compile clean). Two *bare* CPUs\nnever form a valid S7 connection \u2014 apply the protection recipe + `tia_compile` to make each\nconsistent first, then create the connection. Use `tia_connections_diagnose` on failure.\n\n## Recipe \u2014 bump the project firmware **in-place** (keeps the program) (VERIFIED, V21 / S7-1200 1214C)\n\nBumped a project **V4.0 \u2192 V4.4** on a real S7-1200 1214C **without losing blocks or tags**\n(verified 2026-06-07). Use this for **auto-FW-match**: align the project to the firmware\nactually read from the CPU. `DeviceItem.ChangeType(typeIdentifier)` changes the item type\nin place and **preserves the software** \u2014 it does **not** require delete/recreate.\n\n```\n# find the CPU device-item handle:\ntia_obj_roots -> the device handle (role:"device")\ntia_obj_items { handle:<device>, composition:"DeviceItems" } -> the CPU item handle (not the rack)\n# change the CPU\'s type to the SAME MLFB with the target /V<fw> suffix:\ntia_obj_invoke { handle:<cpu>, name:"ChangeType",\n args:["OrderNumber:6ES7 214-1HG40-0XB0/V4.4"] }\n# then recompile \u2014 a regenerated FB may need a fresh compile before download:\ntia_compile { ... }\n```\n\n- **Rule: `project FW \u2264 device FW`** \u2014 never set the project firmware **higher** than the physical\n device\'s (download would be rejected). Bumping the project *up to* the device FW is the safe move.\n- Keep the **same MLFB**, swap only the `/V<fw>` suffix. The program (blocks/tags) survives.\n- After `ChangeType` the CPU/blocks can be inconsistent; **always recompile** before any handoff.\n- **\u26A0\uFE0F `ChangeType` RESETS GUI-gated comm settings** (runtime-validated on the 1214C): it **disabled\n the OPC UA server** (`OpcUaServer`\u2192`false`) and **cleared the OPC UA runtime-license** selection\n (the custom server interface and PUT/GET *survived*). So **`tia_project_archive` first** on a CPU\n with hand-configured OPC UA/PUT-GET, and **re-verify after**. Recovery: `tia_obj_set_attributes\n {OpcUaServer:true}` on the "OPC UA" device-item (it **is** writable; re-select the license in the\n GUI). `ChangeType` to the **same** version is rejected ("Cannot change the type of the device item").\n\n## Recipe \u2014 enable a **Modbus TCP server** (`MB_SERVER`) on the S7-1200 (VERIFIED, FW V4.0)\n\nLets an external client (e.g. a Node backend) read/write the CPU over **Modbus TCP, port 502**\n(verified 2026-06-07; full backend/app detail in `docs/COMM-SCENARIOS.md`).\n\n1. **Non-optimized DB with an `Array of Word`** for the holding-register block (`MB_HOLD_REG`).\n Modbus needs a byte-addressable (non-optimized) DB \u2014 optimized access won\'t map.\n2. **On FW V4.0 use `MB_SERVER` V1.x**, which takes **`CONNECT_ID` + `IP_PORT`** parameters\n (**not** `CONNECT`/`TCON`, which the newer instruction versions use). Pin the instruction\n version when generating the FB.\n3. Instantiate `MB_SERVER` as a **multi-instance inside an FB** (its instance lives in the FB\'s\n instance DB), call it cyclically.\n4. **Map a holding register \u2192 a command tag** (e.g. `MB_HOLD_REG[0]` \u2192 `LedCmd`), so writing the\n register drives the output.\n\n> **Instance-DB gotcha (the big one):** when you regenerate the FB via `tia_source_put`, the\n> existing **instance DB** can go inconsistent (its interface no longer matches the FB).\n> **Recompile first** \u2014 a software-scope `tia_compile` regenerates the instance DB in most cases.\n> Only if it still reports inconsistent after a compile (typical when the interface was edited via\n> source), delete + recreate it, then recompile:\n>\n> ```\n> tia_compile { ... } # try first\n> tia_block_delete { ... the stale instance DB ... } # only if still inconsistent\n> tia_instancedb_create { ... fresh instance DB for the FB ... }\n> tia_compile { ... }\n> ```\n>\n> (Matches the \xA7Pipeline note: recompile first, delete+recreate only as the fallback.)\n\n## Recipe \u2014 enable **S7 / PUT-GET** on the S7-1200 (port 102)\n\nLets an external S7 client (e.g. `nodes7`) read/write the CPU over **S7comm, port 102**.\n\n1. **GATE (human, GUI only):** enable PUT/GET \u2014 *Properties \u2192 Protection & Security \u2192\n Connection mechanisms \u2192 "Permit access with PUT/GET communication"*. **Not exposed by\n Openness** on this CPU/FW (we tried `PlcAccessLevelProvider` \u2014 no toggle). Mark it as a\n **human gate** and surface it in `tia.handoff`; do **not** attempt to script it.\n2. **Non-optimized DB** for the data the client touches (PUT/GET addresses absolute offsets, so\n the DB must be byte-addressable / non-optimized).\n3. Compile + download as usual; the client then reads/writes the DB by area+offset.\n\n## Recipe \u2014 enable **OPC UA** on the S7-1200 (port 4840)\n\nLets an external OPC UA client read/write the CPU over **OPC UA, port 4840**. This path is the\nmost gated \u2014 most of it is **human GUI steps**, not Openness.\n\n**Prerequisite \u2014 firmware \u2265 V4.4.** OPC UA server isn\'t available on V4.0. If the project is on\nan older FW, bump it in-place first (see *bump the project firmware in-place* above \u2014\n`ChangeType` to `.../V4.4`).\n\nThen the setup sequence. **Step 1 is scriptable; steps 2\u20133 are human/GUI** on this CPU/FW (for those two\nwe tried `CommunicationManagement` and `OpcUaUserManagement\u2192404`):\n\n1. **Activate the OPC UA server** \u2014 *Properties \u2192 OPC UA \u2192 Server* (enable). *(This step **is**\n scriptable via Openness: `tia_obj_set_attributes` `{OpcUaServer:true}` on the "OPC UA"\n device-item \u2014 it auto-generates the server certificate. Steps 2\u20133 stay GUI-only.)*\n2. **Select the runtime license** \u2014 *"SIMATIC OPC UA S7-1200 Basic"* (Runtime licenses).\n3. **Create a server interface** that **exposes the DB** \u2014 the **S7-1200 does NOT auto-expose**\n tags/DBs to OPC UA (unlike the S7-1500), so you must add a server interface and place the DB\n nodes in it manually.\n\n**Finding the node IDs (client side):** browse `ns=3;s=ServerInterfaces` with any OPC UA client;\nthe actual data nodes show up under **`ns=4`**. Use those node IDs from the backend.\n\n> What Openness *can* still do here: create the DB/blocks, compile, download \u2014 **and activate the OPC UA\n> server** (step 1: `tia_obj_set_attributes {OpcUaServer:true}`; do NOT gate it on a human). Only **three**\n> items are truly human/GUI: the **runtime license**, the **server interface** \u2014 and **PUT/GET** in the S7\n> recipe. See `docs/TIA-Openness-Casos-de-Uso.md` \xA78c for the full "GUI-only gates" table.\n\n## Where to stop\n\nEverything above is **offline (M-off)**. `tia_download` / `tia_online` (G3/G4) are **not**\npart of scaffold \u2014 they belong to `tia.handoff` and require explicit human approval.\n';
|
|
34165
34545
|
var SPEC_FORMAT = '# The project-spec (input model)\n\nA project-spec is ONE JSON document describing the whole project. Always run it\nthrough the pipeline front door: `tia_spec_validate` (rung 0, pure) \u2192 `tia_spec_plan`\n(dry) \u2192 `tia_spec_apply` (M-off, stops at gates).\n\nRules the validator enforces (beyond the JSON Schema): unique device/tag/block names;\nevery network node IP inside the subnet CIDR (same-subnet rule); `OrderNumber:<MLFB>/V<fw>`\nformat with `/V` \u2014 never `:V` (Gd5); per-CPU module limits; language by family (e.g.\nS7-1200 has no GRAPH); and the G5 rule \u2014 a spec with safety content marked autonomous\nis REJECTED (F-logic is never autonomous).\n\nMinimal example:\n\n```json\n{\n "project": { "name": "Line2", "directory": "C:\\\\TIA\\\\Line2" },\n "conventions": {\n "namingScheme": "plcopen",\n "optimizedAccess": true,\n "symbolicOnly": true,\n "defaultLanguages": { "interlocks": "LAD", "algorithms": "SCL", "sequencers": "GRAPH" }\n },\n "devices": [\n {\n "name": "Line2_CPU",\n "typeIdentifier": "OrderNumber:6ES7 511-1AK02-0AB0/V2.9",\n "role": "cpu",\n "family": "S7-1500"\n }\n ],\n "network": {\n "subnet": { "type": "System:Subnet.Ethernet", "name": "PN_Line2", "cidr": "192.168.0.0/24" },\n "nodes": [{ "device": "Line2_CPU", "ip": "192.168.0.1", "createIoSystem": true }]\n },\n "dataTypes": [\n {\n "name": "UDT_Motor",\n "members": [\n { "name": "xStart", "dataType": "Bool", "comment": "Start command" },\n { "name": "rSpeed", "dataType": "Real", "comment": "Speed [%]" }\n ]\n }\n ],\n "tagTables": [{ "name": "IO", "purpose": "IO" }],\n "tags": [{ "table": "IO", "name": "Conv01_Run", "dataType": "Bool", "address": "%Q0.0" }]\n}\n```\n\nResolve every concrete MLFB + firmware via `tia_catalog` before building \u2014 never guess\nan order number. Project firmware must be \u2264 the physical device\'s firmware.\n';
|
|
34166
34546
|
var FULL_GUIDE = [BRIEF, GATES_GUARDS, GUI_GATES, GOTCHAS, PIPELINE, RECIPES, SPEC_FORMAT].join("\n---\n\n");
|
|
@@ -34206,7 +34586,7 @@ function registerGuideTool(server2) {
|
|
|
34206
34586
|
|
|
34207
34587
|
// src/index.ts
|
|
34208
34588
|
var server = new McpServer(
|
|
34209
|
-
{ name: "tia-openness", version: "1.
|
|
34589
|
+
{ name: "tia-openness", version: "1.8.1" },
|
|
34210
34590
|
// Camada 1 (ambiente): o brief operacional viaja no handshake MCP — qualquer cliente
|
|
34211
34591
|
// que honre `instructions` recebe gates/serial-only/pipeline sem instalar nada.
|
|
34212
34592
|
{ instructions: BRIEF }
|
|
@@ -34218,6 +34598,8 @@ registerReadOnlyTools(server);
|
|
|
34218
34598
|
registerLifecycleTools(server);
|
|
34219
34599
|
registerAuthoringTools(server);
|
|
34220
34600
|
registerAsCodeTools(server);
|
|
34601
|
+
registerAssetTools(server);
|
|
34602
|
+
registerSecurityTools(server);
|
|
34221
34603
|
registerCompileTools(server);
|
|
34222
34604
|
registerDownloadTools(server);
|
|
34223
34605
|
registerUploadTools(server);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renanlido/tia-openness-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "MCP server (stdio) — thin HTTP client over the TIA Openness `serve` API. Zero Openness/net48 references.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,8 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
39
|
-
"@semantic-release/changelog": "^6.0.3",
|
|
40
|
-
"@semantic-release/git": "^10.0.1",
|
|
41
39
|
"@stryker-mutator/core": "9.6.1",
|
|
42
40
|
"@stryker-mutator/vitest-runner": "9.6.1",
|
|
43
41
|
"@types/node": "^25.9.2",
|