@diviops/mcp-server 1.5.33 → 1.5.34

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.
Files changed (3) hide show
  1. package/README.md +13 -1
  2. package/dist/index.js +191 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -83,7 +83,7 @@ The skill enforces the Divi block format, the design system, and the response co
83
83
 
84
84
  ## Tools at a glance
85
85
 
86
- The server exposes **85 always-on tools** across the categories below. Each category links to representative tools; the full table lives in [server-reference.md](../docs/server-reference.md).
86
+ The server exposes **90 always-on tools** across the categories below. Each category links to representative tools; the full table lives in [server-reference.md](../docs/server-reference.md).
87
87
 
88
88
  | Category | Use case | Tool prefixes |
89
89
  |----------|----------|---------------|
@@ -286,6 +286,18 @@ Every write tool accepts `dry_run: boolean` (default `false`). When `true`, the
286
286
 
287
287
  `meta_wp_cli` and `scf_import` do not accept `dry_run` (raw passthrough / upstream gap respectively). `scf_sync` passes `dry_run` through to upstream `wp scf json sync --dry-run`, so its preview is the upstream plain-text summary rather than a plugin-built `data.plan`. For bulk preview-then-commit flows (preset reassign, preset cleanup), see [safety-patterns.md](../docs/safety-patterns.md).
288
288
 
289
+ Selected guarded post-content write tools also accept `backup: true`. In apply
290
+ mode the Free plugin stores an option-backed rollback snapshot before writing
291
+ and returns `data.backup` evidence with the snapshot id and status. With
292
+ `dry_run: true`, `backup: true` only reports the planned snapshot; it never
293
+ creates an option record.
294
+
295
+ `diviops_rollback_snapshot_restore` restores those snapshots only to their
296
+ captured post/page or Theme Builder layout target. It requires row-level edit
297
+ permission, refuses content or supported Divi post-meta drift before mutation,
298
+ uses the same full-content integrity/readback guard, and has no force override
299
+ or second pre-restore snapshot in this MVP.
300
+
289
301
  ### `_meta.idempotent` markers
290
302
 
291
303
  Every tool's `_meta.idempotent` field documents how it behaves under repeat calls with identical inputs. Some tools are silent-success idempotent (e.g. `page_trash` on an already-trashed post returns `ok: true` with `data.already_trashed = true`); others are side-effect-equivalent (re-running produces the same final state via different intermediate effects). See [idempotency-audit.md](../docs/idempotency-audit.md) for the per-tool record.
package/dist/index.js CHANGED
@@ -279,6 +279,24 @@ function requireCapability(key) {
279
279
  throw new MissingCapabilityError(key, handshakeState.pluginVersion);
280
280
  }
281
281
  }
282
+ function backupCapabilityError(toolName, backup) {
283
+ if (!backup)
284
+ return null;
285
+ const key = toolName.replace(/^diviops_/, "") + "_backup";
286
+ try {
287
+ requireCapability(key);
288
+ }
289
+ catch (e) {
290
+ if (e instanceof MissingCapabilityError) {
291
+ return {
292
+ content: [{ type: "text", text: e.message }],
293
+ isError: true,
294
+ };
295
+ }
296
+ throw e;
297
+ }
298
+ return null;
299
+ }
282
300
  // `any` here is deliberate, not laziness. McpServer.registerTool is a
283
301
  // multi-overload generic whose `cb`/`InputArgs` machinery doesn't compose
284
302
  // with `Parameters<typeof server.registerTool>` (overload collapse to
@@ -399,6 +417,11 @@ const DRY_RUN_FIELD = z
399
417
  .optional()
400
418
  .default(false)
401
419
  .describe("When true, return the change plan { summary, changes[, warnings] } without mutating state.");
420
+ const BACKUP_FIELD = z
421
+ .boolean()
422
+ .optional()
423
+ .default(false)
424
+ .describe("When true on supported content writes, capture a rollback snapshot before applying. dry_run + backup only reports the planned snapshot and does not create one.");
402
425
  // ── Read Tools ───────────────────────────────────────────────────────
403
426
  registerPluginTool("diviops_page_list", {
404
427
  description: "List pages/posts in the WordPress site. Returns title, ID, URL, status, and whether each page uses Divi builder. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
@@ -742,7 +765,7 @@ registerPluginTool("diviops_schema_get_module", {
742
765
  };
743
766
  });
744
767
  registerPluginTool("diviops_schema_get_settings", {
745
- description: "Get Divi site settings including theme options, site info, and builder version. Useful for understanding the site context before generating content. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
768
+ description: "Get Divi site settings including site info, builder version, and a narrow public allowlist of non-sensitive Divi theme options (fonts, colors, sizes). Useful for understanding the site context before generating content. Does not expose the raw `et_divi` option bag. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
746
769
  annotations: { idempotentHint: true },
747
770
  _meta: { idempotent: "true" },
748
771
  }, async () => {
@@ -1105,16 +1128,22 @@ registerPluginTool("diviops_page_update_content", {
1105
1128
  .string()
1106
1129
  .describe("Full page content in WordPress block markup format (<!-- wp:divi/section -->...<!-- /wp:divi/section -->)"),
1107
1130
  dry_run: DRY_RUN_FIELD,
1131
+ backup: BACKUP_FIELD,
1108
1132
  },
1109
1133
  annotations: { idempotentHint: false },
1110
1134
  _meta: { idempotent: "conditional" },
1111
- }, async ({ page_id, content, dry_run }) => {
1135
+ }, async ({ page_id, content, dry_run, backup }) => {
1136
+ const backupGate = backupCapabilityError("diviops_page_update_content", backup);
1137
+ if (backupGate)
1138
+ return backupGate;
1112
1139
  const hits = findForeignVarRefs(content, "content");
1113
1140
  if (hits.length > 0)
1114
1141
  return isolationErrorResult("diviops_page_update_content", hits);
1115
1142
  const body = { content };
1116
1143
  if (dry_run)
1117
1144
  body.dry_run = true;
1145
+ if (backup)
1146
+ body.backup = true;
1118
1147
  const result = await wp.requestEnveloped(`/page/update-content/${page_id}`, {
1119
1148
  method: "POST",
1120
1149
  body,
@@ -1277,16 +1306,22 @@ registerPluginTool("diviops_section_append", {
1277
1306
  .default("end")
1278
1307
  .describe('Where to insert: "start" or "end" (default)'),
1279
1308
  dry_run: DRY_RUN_FIELD,
1309
+ backup: BACKUP_FIELD,
1280
1310
  },
1281
1311
  annotations: { idempotentHint: false },
1282
1312
  _meta: { idempotent: "false" },
1283
- }, async ({ page_id, content, position, dry_run }) => {
1313
+ }, async ({ page_id, content, position, dry_run, backup }) => {
1314
+ const backupGate = backupCapabilityError("diviops_section_append", backup);
1315
+ if (backupGate)
1316
+ return backupGate;
1284
1317
  const hits = findForeignVarRefs(content, "content");
1285
1318
  if (hits.length > 0)
1286
1319
  return isolationErrorResult("diviops_section_append", hits);
1287
1320
  const body = { content, position: position ?? "end" };
1288
1321
  if (dry_run)
1289
1322
  body.dry_run = true;
1323
+ if (backup)
1324
+ body.backup = true;
1290
1325
  const result = await wp.requestEnveloped(`/section/append/${page_id}`, {
1291
1326
  method: "POST",
1292
1327
  body,
@@ -1321,10 +1356,14 @@ registerPluginTool("diviops_section_replace", {
1321
1356
  .default(1)
1322
1357
  .describe("Which match to target (1-based, default: 1)"),
1323
1358
  dry_run: DRY_RUN_FIELD,
1359
+ backup: BACKUP_FIELD,
1324
1360
  },
1325
1361
  annotations: { idempotentHint: false },
1326
1362
  _meta: { idempotent: "conditional" },
1327
- }, async ({ page_id, label, match_text, content, occurrence, dry_run }) => {
1363
+ }, async ({ page_id, label, match_text, content, occurrence, dry_run, backup }) => {
1364
+ const backupGate = backupCapabilityError("diviops_section_replace", backup);
1365
+ if (backupGate)
1366
+ return backupGate;
1328
1367
  const hits = findForeignVarRefs(content, "content");
1329
1368
  if (hits.length > 0)
1330
1369
  return isolationErrorResult("diviops_section_replace", hits);
@@ -1335,6 +1374,8 @@ registerPluginTool("diviops_section_replace", {
1335
1374
  body.match_text = match_text;
1336
1375
  if (dry_run)
1337
1376
  body.dry_run = true;
1377
+ if (backup)
1378
+ body.backup = true;
1338
1379
  const result = await wp.requestEnveloped(`/section/replace/${page_id}`, {
1339
1380
  method: "POST",
1340
1381
  body,
@@ -1366,10 +1407,14 @@ registerPluginTool("diviops_section_remove", {
1366
1407
  .default(1)
1367
1408
  .describe("Which match to target (1-based, default: 1)"),
1368
1409
  dry_run: DRY_RUN_FIELD,
1410
+ backup: BACKUP_FIELD,
1369
1411
  },
1370
1412
  annotations: { idempotentHint: true },
1371
1413
  _meta: { idempotent: "true" },
1372
- }, async ({ page_id, label, match_text, occurrence, dry_run }) => {
1414
+ }, async ({ page_id, label, match_text, occurrence, dry_run, backup }) => {
1415
+ const backupGate = backupCapabilityError("diviops_section_remove", backup);
1416
+ if (backupGate)
1417
+ return backupGate;
1373
1418
  const body = { occurrence };
1374
1419
  if (label)
1375
1420
  body.label = label;
@@ -1377,6 +1422,8 @@ registerPluginTool("diviops_section_remove", {
1377
1422
  body.match_text = match_text;
1378
1423
  if (dry_run)
1379
1424
  body.dry_run = true;
1425
+ if (backup)
1426
+ body.backup = true;
1380
1427
  const result = await wp.requestEnveloped(`/section/remove/${page_id}`, {
1381
1428
  method: "POST",
1382
1429
  body,
@@ -1451,10 +1498,14 @@ registerPluginTool("diviops_module_update", {
1451
1498
  .record(z.string(), z.any())
1452
1499
  .describe("Attribute paths (dot notation) and their new values"),
1453
1500
  dry_run: DRY_RUN_FIELD,
1501
+ backup: BACKUP_FIELD,
1454
1502
  },
1455
1503
  annotations: { idempotentHint: false },
1456
1504
  _meta: { idempotent: "conditional" },
1457
- }, async ({ page_id, label, match_text, auto_index, occurrence, attrs, dry_run }) => {
1505
+ }, async ({ page_id, label, match_text, auto_index, occurrence, attrs, dry_run, backup }) => {
1506
+ const backupGate = backupCapabilityError("diviops_module_update", backup);
1507
+ if (backupGate)
1508
+ return backupGate;
1458
1509
  const hits = scanAttrsForForeignVarRefs(attrs);
1459
1510
  if (hits.length > 0)
1460
1511
  return isolationErrorResult("diviops_module_update", hits);
@@ -1469,6 +1520,8 @@ registerPluginTool("diviops_module_update", {
1469
1520
  body.occurrence = occurrence;
1470
1521
  if (dry_run)
1471
1522
  body.dry_run = true;
1523
+ if (backup)
1524
+ body.backup = true;
1472
1525
  const result = await wp.requestEnveloped(`/module/update/${page_id}`, {
1473
1526
  method: "POST",
1474
1527
  body,
@@ -1526,10 +1579,14 @@ registerPluginTool("diviops_module_move", {
1526
1579
  .enum(["before", "after"])
1527
1580
  .describe("Place the source before or after the target"),
1528
1581
  dry_run: DRY_RUN_FIELD,
1582
+ backup: BACKUP_FIELD,
1529
1583
  },
1530
1584
  annotations: { idempotentHint: false },
1531
1585
  _meta: { idempotent: "conditional" },
1532
- }, async ({ page_id, source_label, source_match_text, source_auto_index, source_occurrence, target_label, target_match_text, target_auto_index, target_occurrence, position, dry_run, }) => {
1586
+ }, async ({ page_id, source_label, source_match_text, source_auto_index, source_occurrence, target_label, target_match_text, target_auto_index, target_occurrence, position, dry_run, backup, }) => {
1587
+ const backupGate = backupCapabilityError("diviops_module_move", backup);
1588
+ if (backupGate)
1589
+ return backupGate;
1533
1590
  const body = { position };
1534
1591
  if (source_label)
1535
1592
  body.source_label = source_label;
@@ -1549,6 +1606,8 @@ registerPluginTool("diviops_module_move", {
1549
1606
  body.target_occurrence = target_occurrence;
1550
1607
  if (dry_run)
1551
1608
  body.dry_run = true;
1609
+ if (backup)
1610
+ body.backup = true;
1552
1611
  const result = await wp.requestEnveloped(`/module/move/${page_id}`, {
1553
1612
  method: "POST",
1554
1613
  body,
@@ -1569,10 +1628,14 @@ registerPluginTool("diviops_module_lock", {
1569
1628
  auto_index: z.string().optional().describe('Auto-index in "type:N" format (e.g. "text:3")'),
1570
1629
  occurrence: z.number().int().min(1).optional().default(1).describe("Which occurrence when multiple modules share the same label (1-based)"),
1571
1630
  dry_run: DRY_RUN_FIELD,
1631
+ backup: BACKUP_FIELD,
1572
1632
  },
1573
1633
  annotations: { idempotentHint: false },
1574
1634
  _meta: { idempotent: "false" },
1575
- }, async ({ page_id, label, match_text, auto_index, occurrence, dry_run }) => {
1635
+ }, async ({ page_id, label, match_text, auto_index, occurrence, dry_run, backup }) => {
1636
+ const backupGate = backupCapabilityError("diviops_module_lock", backup);
1637
+ if (backupGate)
1638
+ return backupGate;
1576
1639
  const body = {};
1577
1640
  if (label)
1578
1641
  body.label = label;
@@ -1584,6 +1647,8 @@ registerPluginTool("diviops_module_lock", {
1584
1647
  body.occurrence = occurrence;
1585
1648
  if (dry_run)
1586
1649
  body.dry_run = true;
1650
+ if (backup)
1651
+ body.backup = true;
1587
1652
  const result = await wp.requestEnveloped(`/module/lock/${page_id}`, { method: "POST", body });
1588
1653
  return { content: [{ type: "text", text: serializeEnvelope(result, "diviops_module_lock") }] };
1589
1654
  });
@@ -1597,10 +1662,14 @@ registerPluginTool("diviops_module_unlock", {
1597
1662
  auto_index: z.string().optional().describe('Auto-index in "type:N" format'),
1598
1663
  occurrence: z.number().int().min(1).optional().default(1).describe("Which occurrence when multiple modules share the same label (1-based)"),
1599
1664
  dry_run: DRY_RUN_FIELD,
1665
+ backup: BACKUP_FIELD,
1600
1666
  },
1601
1667
  annotations: { idempotentHint: false },
1602
1668
  _meta: { idempotent: "false" },
1603
- }, async ({ page_id, label, match_text, auto_index, occurrence, dry_run }) => {
1669
+ }, async ({ page_id, label, match_text, auto_index, occurrence, dry_run, backup }) => {
1670
+ const backupGate = backupCapabilityError("diviops_module_unlock", backup);
1671
+ if (backupGate)
1672
+ return backupGate;
1604
1673
  const body = {};
1605
1674
  if (label)
1606
1675
  body.label = label;
@@ -1612,6 +1681,8 @@ registerPluginTool("diviops_module_unlock", {
1612
1681
  body.occurrence = occurrence;
1613
1682
  if (dry_run)
1614
1683
  body.dry_run = true;
1684
+ if (backup)
1685
+ body.backup = true;
1615
1686
  const result = await wp.requestEnveloped(`/module/unlock/${page_id}`, { method: "POST", body });
1616
1687
  return { content: [{ type: "text", text: serializeEnvelope(result, "diviops_module_unlock") }] };
1617
1688
  });
@@ -1626,10 +1697,14 @@ registerPluginTool("diviops_module_clone", {
1626
1697
  occurrence: z.number().int().min(1).optional().default(1).describe("Which occurrence when multiple modules share the same label (1-based)"),
1627
1698
  position: z.enum(["before", "after"]).optional().default("after").describe('Place the clone "before" or "after" the source module within its parent.'),
1628
1699
  dry_run: DRY_RUN_FIELD,
1700
+ backup: BACKUP_FIELD,
1629
1701
  },
1630
1702
  annotations: { idempotentHint: false },
1631
1703
  _meta: { idempotent: "false" },
1632
- }, async ({ page_id, label, match_text, auto_index, occurrence, position, dry_run }) => {
1704
+ }, async ({ page_id, label, match_text, auto_index, occurrence, position, dry_run, backup }) => {
1705
+ const backupGate = backupCapabilityError("diviops_module_clone", backup);
1706
+ if (backupGate)
1707
+ return backupGate;
1633
1708
  const body = {};
1634
1709
  if (label)
1635
1710
  body.label = label;
@@ -1643,6 +1718,8 @@ registerPluginTool("diviops_module_clone", {
1643
1718
  body.position = position;
1644
1719
  if (dry_run)
1645
1720
  body.dry_run = true;
1721
+ if (backup)
1722
+ body.backup = true;
1646
1723
  const result = await wp.requestEnveloped(`/module/clone/${page_id}`, { method: "POST", body });
1647
1724
  return { content: [{ type: "text", text: serializeEnvelope(result, "diviops_module_clone") }] };
1648
1725
  });
@@ -1776,6 +1853,96 @@ registerPluginTool("diviops_preset_audit_storage", {
1776
1853
  ],
1777
1854
  };
1778
1855
  });
1856
+ registerPluginTool("diviops_preset_inspect", {
1857
+ description: "Inspect one Divi 5 preset UUID without writing. Returns bucket/type/module/group coordinates, attrs/styleAttrs/renderAttrs, storage path and provenance, block plus preset-chain reference counts with sample consumers, geometry-scope warnings for layout/position/sizing/transform attrs, and a warning when the same UUID also exists in nested D5 or legacy _ng storage. This is intentionally narrower than diviops_preset_audit and has no repair mode. Missing UUID returns not_found.",
1858
+ inputSchema: {
1859
+ preset_id: z.string().min(1).describe("Preset UUID to inspect."),
1860
+ },
1861
+ annotations: { idempotentHint: true },
1862
+ _meta: { idempotent: "true" },
1863
+ }, async ({ preset_id }) => {
1864
+ const result = await wp.requestEnveloped(`/preset/inspect/${encodeURIComponent(preset_id)}`);
1865
+ return {
1866
+ content: [
1867
+ { type: "text", text: serializeEnvelope(result, "diviops_preset_inspect") },
1868
+ ],
1869
+ };
1870
+ });
1871
+ registerPluginTool("diviops_rollback_snapshot_list", {
1872
+ description: "List DiviOps rollback snapshots from the option-backed store. Free/core storage management read surface; returns metadata only, never stored before.value payloads. Supports target_kind, target_id, status, and limit filters. Results are target-permission filtered; missing-target snapshots are shown only to site admins or the snapshot creator and are payload-redacted. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
1873
+ inputSchema: {
1874
+ target_kind: z.string().optional().describe("Optional target kind filter, usually post."),
1875
+ target_id: z.number().int().positive().optional().describe("Optional target post/layout ID filter."),
1876
+ status: z.string().optional().describe("Optional snapshot status filter, such as created or write_applied."),
1877
+ limit: z.number().int().min(1).max(100).optional().default(20).describe("Maximum snapshots to return."),
1878
+ },
1879
+ annotations: { idempotentHint: true },
1880
+ _meta: { idempotent: "true" },
1881
+ }, async ({ target_kind, target_id, status, limit }) => {
1882
+ const params = {};
1883
+ if (target_kind)
1884
+ params.target_kind = target_kind;
1885
+ if (target_id)
1886
+ params.target_id = String(target_id);
1887
+ if (status)
1888
+ params.status = status;
1889
+ if (limit && limit !== 20)
1890
+ params.limit = String(limit);
1891
+ const qs = new URLSearchParams(params).toString();
1892
+ const result = await wp.requestEnveloped(`/rollback-snapshot/list${qs ? `?${qs}` : ""}`);
1893
+ return {
1894
+ content: [
1895
+ { type: "text", text: serializeEnvelope(result, "diviops_rollback_snapshot_list") },
1896
+ ],
1897
+ };
1898
+ });
1899
+ registerPluginTool("diviops_rollback_snapshot_get", {
1900
+ description: "Inspect one rollback snapshot. Free/core storage management read surface. include_value defaults false; true returns the stored before.value and captured side-effect payload only when the referenced target still exists and the caller passes the target-level permission gate. Missing-target snapshots are metadata-only for admins/creators. No restore path in this tool. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
1901
+ inputSchema: {
1902
+ snapshot_id: z.string().min(1).describe("Snapshot id returned by diviops_rollback_snapshot_list."),
1903
+ include_value: z.boolean().optional().default(false).describe("Include stored before.value and side-effect payload when target access allows it."),
1904
+ },
1905
+ annotations: { idempotentHint: true },
1906
+ _meta: { idempotent: "true" },
1907
+ }, async ({ snapshot_id, include_value }) => {
1908
+ const params = include_value ? "?include_value=true" : "";
1909
+ const result = await wp.requestEnveloped(`/rollback-snapshot/get/${encodeURIComponent(snapshot_id)}${params}`);
1910
+ return {
1911
+ content: [
1912
+ { type: "text", text: serializeEnvelope(result, "diviops_rollback_snapshot_get") },
1913
+ ],
1914
+ };
1915
+ });
1916
+ registerPluginTool("diviops_rollback_snapshot_delete", {
1917
+ description: "Hard-delete one rollback snapshot option after operator acceptance. Free/core cleanup surface; normally requires target-level permission, with a missing-target cleanup path for site admins or the snapshot creator. Does not expose before.value and does not restore content. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
1918
+ inputSchema: {
1919
+ snapshot_id: z.string().min(1).describe("Snapshot id to delete."),
1920
+ },
1921
+ annotations: { idempotentHint: true },
1922
+ _meta: { idempotent: "true" },
1923
+ }, async ({ snapshot_id }) => {
1924
+ const result = await wp.requestEnveloped(`/rollback-snapshot/delete/${encodeURIComponent(snapshot_id)}`, { method: "POST" });
1925
+ return {
1926
+ content: [
1927
+ { type: "text", text: serializeEnvelope(result, "diviops_rollback_snapshot_delete") },
1928
+ ],
1929
+ };
1930
+ });
1931
+ registerPluginTool("diviops_rollback_snapshot_restore", {
1932
+ description: "Restore one guarded rollback snapshot to its original post/page or Theme Builder layout target. Requires target edit permission, refuses content or captured Divi post-meta checksum drift with conflict before mutation, has no force override, writes through the shared full-content integrity/readback guard, restores captured supported post meta, invalidates Divi cache, and marks restore_applied only after verified readback. dry_run previews without writing. This MVP does not create a second pre-restore snapshot. Returns the standardized envelope.",
1933
+ inputSchema: {
1934
+ snapshot_id: z.string().min(1).describe("Snapshot id to restore."),
1935
+ dry_run: z.boolean().optional().default(false).describe("Preview the checksum-bound restore without mutation."),
1936
+ },
1937
+ _meta: { idempotent: "false" },
1938
+ }, async ({ snapshot_id, dry_run }) => {
1939
+ const result = await wp.requestEnveloped(`/rollback-snapshot/restore/${encodeURIComponent(snapshot_id)}`, { method: "POST", body: { dry_run } });
1940
+ return {
1941
+ content: [
1942
+ { type: "text", text: serializeEnvelope(result, "diviops_rollback_snapshot_restore") },
1943
+ ],
1944
+ };
1945
+ });
1779
1946
  registerPluginTool("diviops_preset_cleanup", {
1780
1947
  description: 'Clean up presets. Default: remove spam presets. Optional: dedup=true to also remove duplicates, action="rename_strip_prefix" with prefix to strip a name prefix, or action="remove_orphans" with scope="spam"|"all" to remove unreferenced presets. Use dry_run: true (default) to preview the standard `data.plan = { summary, changes[] }` without mutating; legacy removed/renamed/deduped summary arrays are preserved as sibling metadata. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.',
1781
1948
  inputSchema: {
@@ -2305,13 +2472,19 @@ registerPluginTool("diviops_tb_layout_update", {
2305
2472
  layout_id: z.number().describe("Layout post ID to update"),
2306
2473
  content: z.string().describe("New block markup content"),
2307
2474
  dry_run: DRY_RUN_FIELD,
2475
+ backup: BACKUP_FIELD,
2308
2476
  },
2309
2477
  annotations: { idempotentHint: false },
2310
2478
  _meta: { idempotent: "conditional" },
2311
- }, async ({ layout_id, content, dry_run }) => {
2479
+ }, async ({ layout_id, content, dry_run, backup }) => {
2480
+ const backupGate = backupCapabilityError("diviops_tb_layout_update", backup);
2481
+ if (backupGate)
2482
+ return backupGate;
2312
2483
  const body = { content };
2313
2484
  if (dry_run)
2314
2485
  body.dry_run = true;
2486
+ if (backup)
2487
+ body.backup = true;
2315
2488
  const result = await wp.requestEnveloped(`/theme-builder/layout/update/${layout_id}`, {
2316
2489
  method: "PUT",
2317
2490
  body,
@@ -2342,10 +2515,14 @@ registerPluginTool("diviops_tb_layout_block_insert", {
2342
2515
  .describe("Where to insert relative to the target block."),
2343
2516
  content: z.string().describe("One or more serialized Divi blocks to insert"),
2344
2517
  dry_run: DRY_RUN_FIELD,
2518
+ backup: BACKUP_FIELD,
2345
2519
  },
2346
2520
  annotations: { idempotentHint: false },
2347
2521
  _meta: { idempotent: "conditional" },
2348
- }, async ({ layout_id, parent_selector, parent_path, position, content, dry_run }) => {
2522
+ }, async ({ layout_id, parent_selector, parent_path, position, content, dry_run, backup }) => {
2523
+ const backupGate = backupCapabilityError("diviops_tb_layout_block_insert", backup);
2524
+ if (backupGate)
2525
+ return backupGate;
2349
2526
  const body = {
2350
2527
  content,
2351
2528
  position: position ?? "append",
@@ -2356,6 +2533,8 @@ registerPluginTool("diviops_tb_layout_block_insert", {
2356
2533
  body.parent_path = parent_path;
2357
2534
  if (dry_run)
2358
2535
  body.dry_run = true;
2536
+ if (backup)
2537
+ body.backup = true;
2359
2538
  const result = await wp.requestEnveloped(`/theme-builder/layout/block-insert/${layout_id}`, {
2360
2539
  method: "POST",
2361
2540
  body,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diviops/mcp-server",
3
- "version": "1.5.33",
3
+ "version": "1.5.34",
4
4
  "description": "MCP server exposing Divi 5 Visual Builder as tools for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",