@diviops/mcp-server 1.5.42 → 1.5.44
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 +98 -6
- 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)
|
|
@@ -4506,7 +4539,7 @@ function registerProTools() {
|
|
|
4506
4539
|
}, { target: "fluentcart", capabilityKey: "fluentcart_product_list" });
|
|
4507
4540
|
// diviops_fc_product_get — bridges /diviops/v1/pro/fluentcart/products/{id}
|
|
4508
4541
|
registerProTool("diviops_fc_product_get", {
|
|
4509
|
-
description: "Fetch a single FluentCart Pro product by ID, including the ProductDetail row, default-variation read-back fields, a compact value-free shape-readiness verdict, buyer-safe storefront links, and a list of variation IDs (Pro tier; requires FluentCart Pro installed + activated). Read-only. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; the success payload is { product: { id, title, slug, status, created_at, modified_at, variation_type, variants_count, min_price, max_price, stock_availability, excerpt, content, author_id, view_url, edit_url }, detail: { fulfillment_type, variation_type, min_price, max_price, manage_stock, manage_downloadable, stock_availability, default_variation_id, ... } | null, default_variation: { id, sku, item_price, compare_price } | null, storefront_links: { view_url: string|null, checkout_url: string|null, checkout_variation_id: number|null, ready: boolean, problems: string[], draft_preview_available: false }, shape_readiness: { profile: \"simple_onetime\"|\"simple_annual_subscription\"|\"unsupported\", ready: boolean, problems: string[] }, variation_ids: number[], variations_count }. storefront_links is ready only for a published,
|
|
4542
|
+
description: "Fetch a single FluentCart Pro product by ID, including the ProductDetail row, default-variation read-back fields, a compact value-free shape-readiness verdict, buyer-safe storefront links, and a list of variation IDs (Pro tier; requires FluentCart Pro installed + activated). Read-only. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; the success payload is { product: { id, title, slug, status, created_at, modified_at, variation_type, variants_count, min_price, max_price, stock_availability, excerpt, content, author_id, view_url, edit_url }, detail: { fulfillment_type, variation_type, min_price, max_price, manage_stock, manage_downloadable, stock_availability, default_variation_id, ... } | null, default_variation: { id, sku, item_price, compare_price } | null, storefront_links: { view_url: string|null, checkout_url: string|null, checkout_variation_id: number|null, ready: boolean, problems: string[], draft_preview_available: false }, shape_readiness: { profile: \"simple_onetime\"|\"simple_annual_subscription\"|\"unsupported\", ready: boolean, problems: string[] }, variation_ids: number[], variations_count }. storefront_links is ready only for a published, simple product with exactly one resolvable variation that passes FluentCart's native canPurchase(1) check. Native simple products may use the bounded sole-variation fallback when their default pointer is empty. Missing or drifted DiviOps-authored defaults remain visible in shape_readiness and every mutation remains strict. storefront_links.checkout_url comes from FluentCart's native getPurchaseUrl() query-string route; DiviOps does not invent add-to-cart URLs. Draft, pending, and private products return both buyer URLs as null. storefront_links.problems uses finite codes: product_not_published, product_shape_not_ready, default_variation_missing, variation_not_purchasable, checkout_url_unavailable. product_shape_not_ready is limited to non-simple products or products without exactly one variation. product.view_url remains unchanged for backward-compatible administrative readback and is not a buyer-safety verdict. shape_readiness never returns raw other_info; problems contains only finite codes: detail_missing, variation_type_unsupported, variation_count_not_one, default_variation_pointer_missing, default_variation_pointer_dangling, detail_defaults_drift, payment_profile_unsupported, payment_type_drift, variation_defaults_drift. An intentionally independent variation_title is supported and does not affect readiness. The default_variation block closes the read-after-write loop for the V2 simple-product write tools — sku and compare_price round-trip cleanly without a FluentCart admin fallback. Unit asymmetry: product_create / product_update accept price and compare_price in currency units (e.g. 29.99); product_get returns min_price, max_price, default_variation.item_price, and default_variation.compare_price in stored cents (e.g. 2999). default_variation.sku is null when the stored SKU is SQL NULL; clearing a SKU with sku: \"\" on update reads back as null. default_variation itself is null when the product has no default variation row. Apply/no-op product_create and product_update responses include the same storefront_links projection. Use the variation_ids list to follow up with diviops_fc_variation_list. Error codes: invalid_input (HTTP 400) when id is not a positive integer; not_found (HTTP 404) when no product matches the ID (or it's filtered out by the FluentCart auto-draft global scope); fluentcart.module_inactive (HTTP 412) when FluentCart is uninstalled or the module toggle is off; fluentcart.query_failed (HTTP 500) when the FluentCart model query raises an exception.",
|
|
4510
4543
|
inputSchema: {
|
|
4511
4544
|
id: z
|
|
4512
4545
|
.number()
|
|
@@ -4527,6 +4560,65 @@ 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
|
+
});
|
|
4530
4622
|
// ── V2 — simple product writes ─────────────────────────────────────
|
|
4531
4623
|
//
|
|
4532
4624
|
// 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.44",
|
|
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"
|