@diviops/mcp-server 1.5.44 → 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.
Files changed (2) hide show
  1. package/dist/index.js +110 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4619,6 +4619,116 @@ function registerProTools() {
4619
4619
  capabilityKey: "fluentcart_campaign_section_apply",
4620
4620
  requiredCapabilities: ["page_update_content_expected_checksum"],
4621
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
+ });
4622
4732
  // ── V2 — simple product writes ─────────────────────────────────────
4623
4733
  //
4624
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.44",
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",