@diviops/mcp-server 1.5.43 → 1.5.45
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/dist/index.js +207 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -326,6 +326,23 @@ function backupCapabilityError(toolName, backup) {
|
|
|
326
326
|
}
|
|
327
327
|
return null;
|
|
328
328
|
}
|
|
329
|
+
function conditionalCapabilityError(toolName, capability, required, alternative) {
|
|
330
|
+
if (!required)
|
|
331
|
+
return null;
|
|
332
|
+
try {
|
|
333
|
+
requireCapability(capability);
|
|
334
|
+
}
|
|
335
|
+
catch (e) {
|
|
336
|
+
if (e instanceof MissingCapabilityError) {
|
|
337
|
+
return missingCapabilityEnvelope(e, toolName, {
|
|
338
|
+
serverVersion: SERVER_VERSION,
|
|
339
|
+
hint: capabilityUpgradeHint(e.capability, e.pluginComponent, alternative),
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
throw e;
|
|
343
|
+
}
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
329
346
|
// `any` here is deliberate, not laziness. McpServer.registerTool is a
|
|
330
347
|
// multi-overload generic whose `cb`/`InputArgs` machinery doesn't compose
|
|
331
348
|
// with `Parameters<typeof server.registerTool>` (overload collapse to
|
|
@@ -385,12 +402,14 @@ function registerLocalTool(name, config, handler) {
|
|
|
385
402
|
* be passed explicitly.
|
|
386
403
|
*
|
|
387
404
|
* 2. **Conditional registration.** The tool is registered with the
|
|
388
|
-
* MCP server ONLY when
|
|
405
|
+
* MCP server ONLY when the common gates and any tool-specific required
|
|
406
|
+
* capabilities align at handshake time:
|
|
389
407
|
* - handshakeState.kind === "ok"
|
|
390
408
|
* - proActive === true
|
|
391
409
|
* - availableTargets[target].present === true
|
|
392
410
|
* - activeModules[target] === true
|
|
393
411
|
* - capabilities[capabilityKey] === true
|
|
412
|
+
* - every capabilities[requiredCapabilities[]] === true
|
|
394
413
|
*
|
|
395
414
|
* When any gate is false the call is a no-op — the tool simply
|
|
396
415
|
* doesn't exist on the MCP surface. Per ADR-007 "no error surface,
|
|
@@ -419,7 +438,11 @@ function registerProTool(name, config, handler, gates) {
|
|
|
419
438
|
});
|
|
420
439
|
if (handshakeState.kind !== "ok")
|
|
421
440
|
return;
|
|
422
|
-
|
|
441
|
+
const resolvedHandshake = handshakeState;
|
|
442
|
+
if (gates.requiredCapabilities?.some((capability) => resolvedHandshake.capabilities[capability] !== true)) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (!proToolGatesSatisfied(resolvedHandshake, gates))
|
|
423
446
|
return;
|
|
424
447
|
catalogEntry.registered = true;
|
|
425
448
|
recordIdempotent(name, config?._meta);
|
|
@@ -543,7 +566,7 @@ registerPluginTool("diviops_page_list", {
|
|
|
543
566
|
};
|
|
544
567
|
});
|
|
545
568
|
registerPluginTool("diviops_page_get", {
|
|
546
|
-
description: "Get detailed info about a specific page including its raw Divi block content. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing page_id returns ok:false with code 'not_found' and a hint pointing to diviops_page_list.",
|
|
569
|
+
description: "Get detailed info about a specific page including its raw Divi block content and content_checksum (`sha256:` over the exact post_content bytes) for stale-write protection. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing page_id returns ok:false with code 'not_found' and a hint pointing to diviops_page_list.",
|
|
547
570
|
inputSchema: {
|
|
548
571
|
page_id: z.number().describe("WordPress post/page ID"),
|
|
549
572
|
},
|
|
@@ -1234,26 +1257,36 @@ registerPluginTool("diviops_seo_metadata_update", {
|
|
|
1234
1257
|
};
|
|
1235
1258
|
});
|
|
1236
1259
|
registerPluginTool("diviops_page_update_content", {
|
|
1237
|
-
description: "Update the content of a page with Divi block markup. The content should be valid WordPress block markup using divi/* blocks. IMPORTANT: This overwrites the entire page content. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing page_id returns 'not_found', edit-permission failures return 'forbidden' (HTTP 403), non-string content returns 'invalid_input' with `error.data = { field, received_type }`." +
|
|
1260
|
+
description: "Update the content of a page with Divi block markup. The content should be valid WordPress block markup using divi/* blocks. IMPORTANT: This overwrites the entire page content. Pass expected_checksum from diviops_page_get to refuse stale writes; omission preserves the legacy unconditional-write contract. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing page_id returns 'not_found', edit-permission failures return 'forbidden' (HTTP 403), stale content returns 'page.content_drift' (HTTP 409), and non-string content returns 'invalid_input' with `error.data = { field, received_type }`." +
|
|
1238
1261
|
DRY_RUN_DESC_SUFFIX,
|
|
1239
1262
|
inputSchema: {
|
|
1240
1263
|
page_id: z.number().describe("WordPress post/page ID to update"),
|
|
1241
1264
|
content: z
|
|
1242
1265
|
.string()
|
|
1243
1266
|
.describe("Full page content in WordPress block markup format (<!-- wp:divi/section -->...<!-- /wp:divi/section -->)"),
|
|
1267
|
+
expected_checksum: z
|
|
1268
|
+
.string()
|
|
1269
|
+
.regex(/^sha256:[a-f0-9]{64}$/)
|
|
1270
|
+
.optional()
|
|
1271
|
+
.describe("Optional review binding from diviops_page_get.content_checksum. When supplied, drift refuses with no force path."),
|
|
1244
1272
|
dry_run: DRY_RUN_FIELD,
|
|
1245
1273
|
backup: BACKUP_FIELD,
|
|
1246
1274
|
},
|
|
1247
1275
|
annotations: { idempotentHint: false },
|
|
1248
1276
|
_meta: { idempotent: "conditional" },
|
|
1249
|
-
}, async ({ page_id, content, dry_run, backup }) => {
|
|
1277
|
+
}, async ({ page_id, content, expected_checksum, dry_run, backup }) => {
|
|
1250
1278
|
const backupGate = backupCapabilityError("diviops_page_update_content", backup);
|
|
1251
1279
|
if (backupGate)
|
|
1252
1280
|
return backupGate;
|
|
1281
|
+
const checksumGate = conditionalCapabilityError("diviops_page_update_content", "page_update_content_expected_checksum", expected_checksum !== undefined, "Alternatively, omit expected_checksum to use the legacy unconditional-write contract.");
|
|
1282
|
+
if (checksumGate)
|
|
1283
|
+
return checksumGate;
|
|
1253
1284
|
const isolationGate = writerIsolationErrorResult("diviops_page_update_content", { content });
|
|
1254
1285
|
if (isolationGate)
|
|
1255
1286
|
return isolationGate;
|
|
1256
1287
|
const body = { content };
|
|
1288
|
+
if (expected_checksum !== undefined)
|
|
1289
|
+
body.expected_checksum = expected_checksum;
|
|
1257
1290
|
if (dry_run)
|
|
1258
1291
|
body.dry_run = true;
|
|
1259
1292
|
if (backup)
|
|
@@ -4527,6 +4560,175 @@ function registerProTools() {
|
|
|
4527
4560
|
],
|
|
4528
4561
|
};
|
|
4529
4562
|
}, { target: "fluentcart", capabilityKey: "fluentcart_product_get" });
|
|
4563
|
+
registerProTool("diviops_fc_campaign_section_apply", {
|
|
4564
|
+
description: "Create or replace one receipt-owned FluentCart campaign section on an existing Divi page. The fixed product_card_buy_now_v1 profile uses only the official fluent-cart-divi/product-card and fluent-cart-divi/buy-now modules. Requires a published storefront-ready product, active supported FluentCart Divi Modules 1.0.0 schemas, an exact page checksum, and exactly one of position=start|end or the prior receipt. Dry-run returns exact generated block markup, validation/render evidence, the rollback plan, and a planned receipt. Apply always creates a rollback backup, refuses page drift, validates and renders before writing, verifies exact readback, and returns the receipt required for any replacement. It never mutates products, prices, variants, orders, customers, cart, taxes, or checkout behavior." +
|
|
4565
|
+
DRY_RUN_DESC_SUFFIX,
|
|
4566
|
+
inputSchema: {
|
|
4567
|
+
page_id: z.number().int().positive().describe("Existing WordPress page ID."),
|
|
4568
|
+
product_id: z.number().int().positive().describe("Published FluentCart product ID whose storefront_links.ready is true."),
|
|
4569
|
+
profile: z.literal("product_card_buy_now_v1").describe("The only supported fixed presentation profile."),
|
|
4570
|
+
expected_page_checksum: z
|
|
4571
|
+
.string()
|
|
4572
|
+
.regex(/^sha256:[a-f0-9]{64}$/)
|
|
4573
|
+
.describe("Exact diviops_page_get.content_checksum reviewed for this write."),
|
|
4574
|
+
position: z.enum(["start", "end"]).optional().describe("Create at the start or end of the page. Mutually exclusive with receipt."),
|
|
4575
|
+
receipt: z
|
|
4576
|
+
.object({
|
|
4577
|
+
schema: z.literal("diviops.fluentcart_campaign_section.receipt.v1"),
|
|
4578
|
+
page_id: z.number().int().positive(),
|
|
4579
|
+
product_id: z.number().int().positive(),
|
|
4580
|
+
profile: z.literal("product_card_buy_now_v1"),
|
|
4581
|
+
section_label: z.string().min(1),
|
|
4582
|
+
section_sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4583
|
+
page_sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4584
|
+
addon_version: z.literal("1.0.0"),
|
|
4585
|
+
addon_schema_sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4586
|
+
builder_version: z.string().min(1),
|
|
4587
|
+
})
|
|
4588
|
+
.strict()
|
|
4589
|
+
.optional()
|
|
4590
|
+
.describe("Prior exact-owned receipt for replacement. Mutually exclusive with position."),
|
|
4591
|
+
dry_run: DRY_RUN_FIELD,
|
|
4592
|
+
},
|
|
4593
|
+
annotations: { idempotentHint: false },
|
|
4594
|
+
_meta: { idempotent: "conditional" },
|
|
4595
|
+
}, async ({ page_id, product_id, profile, expected_page_checksum, position, receipt, dry_run }) => {
|
|
4596
|
+
const body = {
|
|
4597
|
+
page_id,
|
|
4598
|
+
product_id,
|
|
4599
|
+
profile,
|
|
4600
|
+
expected_page_checksum,
|
|
4601
|
+
};
|
|
4602
|
+
if (position !== undefined)
|
|
4603
|
+
body.position = position;
|
|
4604
|
+
if (receipt !== undefined)
|
|
4605
|
+
body.receipt = receipt;
|
|
4606
|
+
if (dry_run)
|
|
4607
|
+
body.dry_run = true;
|
|
4608
|
+
const result = await wp.requestEnveloped("/pro/fluentcart/campaign-section/apply", { method: "POST", body });
|
|
4609
|
+
return {
|
|
4610
|
+
content: [
|
|
4611
|
+
{
|
|
4612
|
+
type: "text",
|
|
4613
|
+
text: serializeEnvelope(result, "diviops_fc_campaign_section_apply"),
|
|
4614
|
+
},
|
|
4615
|
+
],
|
|
4616
|
+
};
|
|
4617
|
+
}, {
|
|
4618
|
+
target: "fluentcart",
|
|
4619
|
+
capabilityKey: "fluentcart_campaign_section_apply",
|
|
4620
|
+
requiredCapabilities: ["page_update_content_expected_checksum"],
|
|
4621
|
+
});
|
|
4622
|
+
registerProTool("diviops_fc_campaign_page_apply", {
|
|
4623
|
+
description: "Create one new draft campaign page or insert/replace one exact-owned campaign-page segment on an existing Divi page. Both PAGE profiles compose an H1 hero, a native Product Card section, and an H2 closing section; SECTION is unchanged. Choose preset_campaign_page_native_card_v1 for a short page with one native card CTA: 14 modules, exactly six installed preset roles (section, row, column, heading, body, product_card), and closing copy referring to the card above. The existing preset_campaign_page_v1 intentionally repeats the CTA with native Buy Now below the closing copy: 15 modules and all seven roles including buy_now. Neither profile is a flexible Divi-composed product design. It accepts one published storefront-ready FluentCart product. Dry-run audits presets and returns exact preset checksums, page markup, validation/render evidence, rollback plan, and a profile-bound plan checksum. Apply requires those exact preset checksums plus confirm_plan_sha256. Existing-page writes also require page_update_content_expected_checksum, an exact page checksum, mandatory backup, and either start/end insertion or a same-profile prior receipt. Cross-profile receipts are refused, not migrated. New pages are always drafts with an explicit title and sanitized slug; their rollback is exact page trash. The workflow never creates or repairs presets, accepts arbitrary copy/design input, publishes a page, or mutates FluentCart commerce state." +
|
|
4624
|
+
DRY_RUN_DESC_SUFFIX,
|
|
4625
|
+
inputSchema: {
|
|
4626
|
+
product_id: z.number().int().positive().describe("Published FluentCart product ID whose storefront_links.ready is true."),
|
|
4627
|
+
profile: z.enum(["preset_campaign_page_v1", "preset_campaign_page_native_card_v1"]),
|
|
4628
|
+
destination: z.discriminatedUnion("mode", [
|
|
4629
|
+
z
|
|
4630
|
+
.object({
|
|
4631
|
+
mode: z.literal("new_draft"),
|
|
4632
|
+
title: z.string().min(1).max(200),
|
|
4633
|
+
slug: z
|
|
4634
|
+
.string()
|
|
4635
|
+
.max(200)
|
|
4636
|
+
.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
4637
|
+
})
|
|
4638
|
+
.strict(),
|
|
4639
|
+
z
|
|
4640
|
+
.object({
|
|
4641
|
+
mode: z.literal("existing_page"),
|
|
4642
|
+
page_id: z.number().int().positive(),
|
|
4643
|
+
expected_page_checksum: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4644
|
+
position: z.enum(["start", "end"]).optional(),
|
|
4645
|
+
receipt: z
|
|
4646
|
+
.object({
|
|
4647
|
+
schema: z.literal("diviops.fluentcart_campaign_page.receipt.v1"),
|
|
4648
|
+
page_id: z.number().int().positive(),
|
|
4649
|
+
product_id: z.number().int().positive(),
|
|
4650
|
+
profile: z.enum(["preset_campaign_page_v1", "preset_campaign_page_native_card_v1"]),
|
|
4651
|
+
section_labels: z.object({ hero: z.string(), product: z.string(), closing: z.string() }).strict(),
|
|
4652
|
+
segment_sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4653
|
+
page_sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4654
|
+
preset_bindings_sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4655
|
+
addon_version: z.literal("1.0.0"),
|
|
4656
|
+
addon_schema_sha256: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4657
|
+
builder_version: z.string().min(1),
|
|
4658
|
+
})
|
|
4659
|
+
.strict()
|
|
4660
|
+
.optional(),
|
|
4661
|
+
})
|
|
4662
|
+
.strict(),
|
|
4663
|
+
]),
|
|
4664
|
+
preset_roles: z
|
|
4665
|
+
.object({
|
|
4666
|
+
section: z.string().min(1).max(128),
|
|
4667
|
+
row: z.string().min(1).max(128),
|
|
4668
|
+
column: z.string().min(1).max(128),
|
|
4669
|
+
heading: z.string().min(1).max(128),
|
|
4670
|
+
body: z.string().min(1).max(128),
|
|
4671
|
+
product_card: z.string().min(1).max(128),
|
|
4672
|
+
buy_now: z.string().min(1).max(128).optional().describe("Required only for preset_campaign_page_v1; forbidden for preset_campaign_page_native_card_v1."),
|
|
4673
|
+
})
|
|
4674
|
+
.strict(),
|
|
4675
|
+
expected_preset_checksums: z
|
|
4676
|
+
.object({
|
|
4677
|
+
section: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4678
|
+
row: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4679
|
+
column: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4680
|
+
heading: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4681
|
+
body: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4682
|
+
product_card: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
4683
|
+
buy_now: z.string().regex(/^sha256:[a-f0-9]{64}$/).optional().describe("Required only for preset_campaign_page_v1; forbidden for preset_campaign_page_native_card_v1."),
|
|
4684
|
+
})
|
|
4685
|
+
.strict()
|
|
4686
|
+
.optional()
|
|
4687
|
+
.describe("Exact role checksums returned by dry-run. Required for apply."),
|
|
4688
|
+
confirm_plan_sha256: z
|
|
4689
|
+
.string()
|
|
4690
|
+
.regex(/^sha256:[a-f0-9]{64}$/)
|
|
4691
|
+
.optional()
|
|
4692
|
+
.describe("Exact confirmation.plan_sha256 returned by dry-run. Required for apply."),
|
|
4693
|
+
dry_run: DRY_RUN_FIELD,
|
|
4694
|
+
},
|
|
4695
|
+
annotations: { idempotentHint: false },
|
|
4696
|
+
_meta: { idempotent: "conditional" },
|
|
4697
|
+
}, async ({ product_id, profile, destination, preset_roles, expected_preset_checksums, confirm_plan_sha256, dry_run }) => {
|
|
4698
|
+
// The SDK publishes a raw object shape; enforce its cross-field profile rules before transport.
|
|
4699
|
+
const needsBuyNow = profile === "preset_campaign_page_v1";
|
|
4700
|
+
const roleMismatch = [preset_roles, expected_preset_checksums].some((roles) => roles !== undefined && Object.hasOwn(roles, "buy_now") !== needsBuyNow);
|
|
4701
|
+
const receiptMismatch = destination.mode === "existing_page" && destination.receipt !== undefined && destination.receipt.profile !== profile;
|
|
4702
|
+
if (roleMismatch || receiptMismatch) {
|
|
4703
|
+
return {
|
|
4704
|
+
isError: true,
|
|
4705
|
+
content: [{ type: "text", text: serializeEnvelope({
|
|
4706
|
+
ok: false,
|
|
4707
|
+
error: { code: "invalid_input", message: "Preset roles, checksum roles, and prior receipt must match the selected PAGE profile.", data: { mutated: false } },
|
|
4708
|
+
}, "diviops_fc_campaign_page_apply") }],
|
|
4709
|
+
};
|
|
4710
|
+
}
|
|
4711
|
+
const body = { product_id, profile, destination, preset_roles };
|
|
4712
|
+
if (expected_preset_checksums !== undefined)
|
|
4713
|
+
body.expected_preset_checksums = expected_preset_checksums;
|
|
4714
|
+
if (confirm_plan_sha256 !== undefined)
|
|
4715
|
+
body.confirm_plan_sha256 = confirm_plan_sha256;
|
|
4716
|
+
if (dry_run)
|
|
4717
|
+
body.dry_run = true;
|
|
4718
|
+
const result = await wp.requestEnveloped("/pro/fluentcart/campaign-page/apply", { method: "POST", body });
|
|
4719
|
+
return {
|
|
4720
|
+
content: [
|
|
4721
|
+
{
|
|
4722
|
+
type: "text",
|
|
4723
|
+
text: serializeEnvelope(result, "diviops_fc_campaign_page_apply"),
|
|
4724
|
+
},
|
|
4725
|
+
],
|
|
4726
|
+
};
|
|
4727
|
+
}, {
|
|
4728
|
+
target: "fluentcart",
|
|
4729
|
+
capabilityKey: "fluentcart_campaign_page_apply",
|
|
4730
|
+
requiredCapabilities: ["page_update_content_expected_checksum"],
|
|
4731
|
+
});
|
|
4530
4732
|
// ── V2 — simple product writes ─────────────────────────────────────
|
|
4531
4733
|
//
|
|
4532
4734
|
// Three Pro write tools backing the constrained simple-onetime-product
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diviops/mcp-server",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.45",
|
|
4
4
|
"description": "MCP server exposing Divi 5 Visual Builder as tools for Claude",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@hono/node-server": "2.1.0",
|
|
64
64
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
65
65
|
"body-parser": "2.3.0",
|
|
66
|
-
"fast-uri": "3.1.
|
|
66
|
+
"fast-uri": "3.1.7",
|
|
67
67
|
"hono": "4.13.1",
|
|
68
68
|
"ip-address": "10.5.0",
|
|
69
69
|
"zod": "^4.3.6"
|