@contentful/mcp-tools 0.12.13 → 0.12.14

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/dist/index.d.ts +140 -44
  2. package/dist/index.js +139 -80
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4238,7 +4238,7 @@ declare class ContentfulMcpTools {
4238
4238
  componentId: zod.ZodOptional<zod.ZodString>;
4239
4239
  name: zod.ZodString;
4240
4240
  description: zod.ZodString;
4241
- viewports: zod.ZodArray<zod.ZodObject<{
4241
+ viewports: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
4242
4242
  id: zod.ZodString;
4243
4243
  query: zod.ZodString;
4244
4244
  displayName: zod.ZodString;
@@ -4253,7 +4253,7 @@ declare class ContentfulMcpTools {
4253
4253
  query: string;
4254
4254
  displayName: string;
4255
4255
  previewSize: string;
4256
- }>, "many">;
4256
+ }>, "many">>;
4257
4257
  contentProperties: zod.ZodArray<zod.ZodIntersection<zod.ZodType<contentful_management.DataTypeDefinition, zod.ZodTypeDef, contentful_management.DataTypeDefinition>, zod.ZodObject<{
4258
4258
  id: zod.ZodString;
4259
4259
  name: zod.ZodString;
@@ -4636,12 +4636,6 @@ declare class ContentfulMcpTools {
4636
4636
  id: string;
4637
4637
  defaultValue?: unknown;
4638
4638
  })[];
4639
- viewports: {
4640
- id: string;
4641
- query: string;
4642
- displayName: string;
4643
- previewSize: string;
4644
- }[];
4645
4639
  metadata?: {
4646
4640
  tags?: {
4647
4641
  sys: {
@@ -4675,6 +4669,12 @@ declare class ContentfulMcpTools {
4675
4669
  allowedTypes: string[];
4676
4670
  }[] | undefined;
4677
4671
  }[] | undefined;
4672
+ viewports?: {
4673
+ id: string;
4674
+ query: string;
4675
+ displayName: string;
4676
+ previewSize: string;
4677
+ }[] | undefined;
4678
4678
  componentTree?: contentful_management.TreeNodeV2[] | undefined;
4679
4679
  }, extra?: _modelcontextprotocol_sdk_shared_protocol_js.RequestHandlerExtra<_modelcontextprotocol_sdk_types_js.ServerRequest, _modelcontextprotocol_sdk_types_js.ServerNotification>) => Promise<ToolResponse>;
4680
4680
  };
@@ -5261,7 +5261,7 @@ declare class ContentfulMcpTools {
5261
5261
  } & {
5262
5262
  name: zod.ZodString;
5263
5263
  description: zod.ZodString;
5264
- viewports: zod.ZodArray<zod.ZodObject<{
5264
+ viewports: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
5265
5265
  id: zod.ZodString;
5266
5266
  query: zod.ZodString;
5267
5267
  displayName: zod.ZodString;
@@ -5276,7 +5276,7 @@ declare class ContentfulMcpTools {
5276
5276
  query: string;
5277
5277
  displayName: string;
5278
5278
  previewSize: string;
5279
- }>, "many">;
5279
+ }>, "many">>;
5280
5280
  contentProperties: zod.ZodArray<zod.ZodIntersection<zod.ZodType<contentful_management.DataTypeDefinition, zod.ZodTypeDef, contentful_management.DataTypeDefinition>, zod.ZodObject<{
5281
5281
  id: zod.ZodString;
5282
5282
  name: zod.ZodString;
@@ -5659,12 +5659,6 @@ declare class ContentfulMcpTools {
5659
5659
  id: string;
5660
5660
  defaultValue?: unknown;
5661
5661
  })[];
5662
- viewports: {
5663
- id: string;
5664
- query: string;
5665
- displayName: string;
5666
- previewSize: string;
5667
- }[];
5668
5662
  metadata?: {
5669
5663
  tags?: {
5670
5664
  sys: {
@@ -5697,6 +5691,12 @@ declare class ContentfulMcpTools {
5697
5691
  allowedTypes: string[];
5698
5692
  }[] | undefined;
5699
5693
  }[] | undefined;
5694
+ viewports?: {
5695
+ id: string;
5696
+ query: string;
5697
+ displayName: string;
5698
+ previewSize: string;
5699
+ }[] | undefined;
5700
5700
  componentTree?: contentful_management.TreeNodeV2[] | undefined;
5701
5701
  }, extra?: _modelcontextprotocol_sdk_shared_protocol_js.RequestHandlerExtra<_modelcontextprotocol_sdk_types_js.ServerRequest, _modelcontextprotocol_sdk_types_js.ServerNotification>) => Promise<ToolResponse>;
5702
5702
  };
@@ -6310,7 +6310,7 @@ declare class ContentfulMcpTools {
6310
6310
  urn: string;
6311
6311
  };
6312
6312
  }>;
6313
- viewports: zod.ZodArray<zod.ZodObject<{
6313
+ viewports: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
6314
6314
  id: zod.ZodString;
6315
6315
  query: zod.ZodString;
6316
6316
  displayName: zod.ZodString;
@@ -6325,8 +6325,8 @@ declare class ContentfulMcpTools {
6325
6325
  query: string;
6326
6326
  displayName: string;
6327
6327
  previewSize: string;
6328
- }>, "many">;
6329
- designProperties: zod.ZodRecord<zod.ZodString, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodObject<{
6328
+ }>, "many">>;
6329
+ designProperties: zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodUnion<[zod.ZodObject<{
6330
6330
  type: zod.ZodLiteral<"ManualDesignValue">;
6331
6331
  value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
6332
6332
  }, "strip", zod.ZodTypeAny, {
@@ -6344,7 +6344,25 @@ declare class ContentfulMcpTools {
6344
6344
  }, {
6345
6345
  value: string;
6346
6346
  type: "DesignToken";
6347
- }>]>>>;
6347
+ }>]>, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodObject<{
6348
+ type: zod.ZodLiteral<"ManualDesignValue">;
6349
+ value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
6350
+ }, "strip", zod.ZodTypeAny, {
6351
+ value: string | number | boolean;
6352
+ type: "ManualDesignValue";
6353
+ }, {
6354
+ value: string | number | boolean;
6355
+ type: "ManualDesignValue";
6356
+ }>, zod.ZodObject<{
6357
+ type: zod.ZodLiteral<"DesignToken">;
6358
+ value: zod.ZodString;
6359
+ }, "strip", zod.ZodTypeAny, {
6360
+ value: string;
6361
+ type: "DesignToken";
6362
+ }, {
6363
+ value: string;
6364
+ type: "DesignToken";
6365
+ }>]>>]>>;
6348
6366
  contentBindings: zod.ZodOptional<zod.ZodObject<{
6349
6367
  sys: zod.ZodObject<{
6350
6368
  type: zod.ZodLiteral<"ResourceLink">;
@@ -6523,19 +6541,19 @@ declare class ContentfulMcpTools {
6523
6541
  urn: string;
6524
6542
  };
6525
6543
  };
6526
- designProperties: Record<string, Record<string, {
6544
+ designProperties: Record<string, {
6545
+ value: string;
6546
+ type: "DesignToken";
6547
+ } | {
6548
+ value: string | number | boolean;
6549
+ type: "ManualDesignValue";
6550
+ } | Record<string, {
6527
6551
  value: string;
6528
6552
  type: "DesignToken";
6529
6553
  } | {
6530
6554
  value: string | number | boolean;
6531
6555
  type: "ManualDesignValue";
6532
6556
  }>>;
6533
- viewports: {
6534
- id: string;
6535
- query: string;
6536
- displayName: string;
6537
- previewSize: string;
6538
- }[];
6539
6557
  metadata?: {
6540
6558
  name?: string | undefined;
6541
6559
  tags?: {
@@ -6568,6 +6586,12 @@ declare class ContentfulMcpTools {
6568
6586
  };
6569
6587
  }>;
6570
6588
  } | undefined;
6589
+ viewports?: {
6590
+ id: string;
6591
+ query: string;
6592
+ displayName: string;
6593
+ previewSize: string;
6594
+ }[] | undefined;
6571
6595
  }, extra?: _modelcontextprotocol_sdk_shared_protocol_js.RequestHandlerExtra<_modelcontextprotocol_sdk_types_js.ServerRequest, _modelcontextprotocol_sdk_types_js.ServerNotification>) => Promise<ToolResponse>;
6572
6596
  };
6573
6597
  upsertExperience: {
@@ -6597,7 +6621,25 @@ declare class ContentfulMcpTools {
6597
6621
  displayName: string;
6598
6622
  previewSize: string;
6599
6623
  }>, "many">>;
6600
- designProperties: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodObject<{
6624
+ designProperties: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodUnion<[zod.ZodObject<{
6625
+ type: zod.ZodLiteral<"ManualDesignValue">;
6626
+ value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
6627
+ }, "strip", zod.ZodTypeAny, {
6628
+ value: string | number | boolean;
6629
+ type: "ManualDesignValue";
6630
+ }, {
6631
+ value: string | number | boolean;
6632
+ type: "ManualDesignValue";
6633
+ }>, zod.ZodObject<{
6634
+ type: zod.ZodLiteral<"DesignToken">;
6635
+ value: zod.ZodString;
6636
+ }, "strip", zod.ZodTypeAny, {
6637
+ value: string;
6638
+ type: "DesignToken";
6639
+ }, {
6640
+ value: string;
6641
+ type: "DesignToken";
6642
+ }>]>, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodObject<{
6601
6643
  type: zod.ZodLiteral<"ManualDesignValue">;
6602
6644
  value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
6603
6645
  }, "strip", zod.ZodTypeAny, {
@@ -6615,7 +6657,7 @@ declare class ContentfulMcpTools {
6615
6657
  }, {
6616
6658
  value: string;
6617
6659
  type: "DesignToken";
6618
- }>]>>>>;
6660
+ }>]>>]>>>;
6619
6661
  contentBindings: zod.ZodOptional<zod.ZodObject<{
6620
6662
  sys: zod.ZodObject<{
6621
6663
  type: zod.ZodLiteral<"ResourceLink">;
@@ -6806,7 +6848,13 @@ declare class ContentfulMcpTools {
6806
6848
  }[] | undefined;
6807
6849
  } | undefined;
6808
6850
  description?: string | undefined;
6809
- designProperties?: Record<string, Record<string, {
6851
+ designProperties?: Record<string, {
6852
+ value: string;
6853
+ type: "DesignToken";
6854
+ } | {
6855
+ value: string | number | boolean;
6856
+ type: "ManualDesignValue";
6857
+ } | Record<string, {
6810
6858
  value: string;
6811
6859
  type: "DesignToken";
6812
6860
  } | {
@@ -9297,7 +9345,7 @@ declare class ContentfulMcpTools {
9297
9345
  urn: string;
9298
9346
  };
9299
9347
  }>;
9300
- viewports: zod.ZodArray<zod.ZodObject<{
9348
+ viewports: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
9301
9349
  id: zod.ZodString;
9302
9350
  query: zod.ZodString;
9303
9351
  displayName: zod.ZodString;
@@ -9312,8 +9360,8 @@ declare class ContentfulMcpTools {
9312
9360
  query: string;
9313
9361
  displayName: string;
9314
9362
  previewSize: string;
9315
- }>, "many">;
9316
- designProperties: zod.ZodRecord<zod.ZodString, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodObject<{
9363
+ }>, "many">>;
9364
+ designProperties: zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodUnion<[zod.ZodObject<{
9317
9365
  type: zod.ZodLiteral<"ManualDesignValue">;
9318
9366
  value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
9319
9367
  }, "strip", zod.ZodTypeAny, {
@@ -9331,7 +9379,25 @@ declare class ContentfulMcpTools {
9331
9379
  }, {
9332
9380
  value: string;
9333
9381
  type: "DesignToken";
9334
- }>]>>>;
9382
+ }>]>, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodObject<{
9383
+ type: zod.ZodLiteral<"ManualDesignValue">;
9384
+ value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
9385
+ }, "strip", zod.ZodTypeAny, {
9386
+ value: string | number | boolean;
9387
+ type: "ManualDesignValue";
9388
+ }, {
9389
+ value: string | number | boolean;
9390
+ type: "ManualDesignValue";
9391
+ }>, zod.ZodObject<{
9392
+ type: zod.ZodLiteral<"DesignToken">;
9393
+ value: zod.ZodString;
9394
+ }, "strip", zod.ZodTypeAny, {
9395
+ value: string;
9396
+ type: "DesignToken";
9397
+ }, {
9398
+ value: string;
9399
+ type: "DesignToken";
9400
+ }>]>>]>>;
9335
9401
  contentBindings: zod.ZodOptional<zod.ZodObject<{
9336
9402
  sys: zod.ZodObject<{
9337
9403
  type: zod.ZodLiteral<"ResourceLink">;
@@ -9510,19 +9576,19 @@ declare class ContentfulMcpTools {
9510
9576
  urn: string;
9511
9577
  };
9512
9578
  };
9513
- designProperties: Record<string, Record<string, {
9579
+ designProperties: Record<string, {
9580
+ value: string;
9581
+ type: "DesignToken";
9582
+ } | {
9583
+ value: string | number | boolean;
9584
+ type: "ManualDesignValue";
9585
+ } | Record<string, {
9514
9586
  value: string;
9515
9587
  type: "DesignToken";
9516
9588
  } | {
9517
9589
  value: string | number | boolean;
9518
9590
  type: "ManualDesignValue";
9519
9591
  }>>;
9520
- viewports: {
9521
- id: string;
9522
- query: string;
9523
- displayName: string;
9524
- previewSize: string;
9525
- }[];
9526
9592
  metadata?: {
9527
9593
  name?: string | undefined;
9528
9594
  tags?: {
@@ -9555,6 +9621,12 @@ declare class ContentfulMcpTools {
9555
9621
  };
9556
9622
  }>;
9557
9623
  } | undefined;
9624
+ viewports?: {
9625
+ id: string;
9626
+ query: string;
9627
+ displayName: string;
9628
+ previewSize: string;
9629
+ }[] | undefined;
9558
9630
  }, extra?: _modelcontextprotocol_sdk_shared_protocol_js.RequestHandlerExtra<_modelcontextprotocol_sdk_types_js.ServerRequest, _modelcontextprotocol_sdk_types_js.ServerNotification>) => Promise<ToolResponse>;
9559
9631
  };
9560
9632
  updateExperienceFragment: {
@@ -9584,7 +9656,25 @@ declare class ContentfulMcpTools {
9584
9656
  displayName: string;
9585
9657
  previewSize: string;
9586
9658
  }>, "many">>;
9587
- designProperties: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodObject<{
9659
+ designProperties: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodUnion<[zod.ZodObject<{
9660
+ type: zod.ZodLiteral<"ManualDesignValue">;
9661
+ value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
9662
+ }, "strip", zod.ZodTypeAny, {
9663
+ value: string | number | boolean;
9664
+ type: "ManualDesignValue";
9665
+ }, {
9666
+ value: string | number | boolean;
9667
+ type: "ManualDesignValue";
9668
+ }>, zod.ZodObject<{
9669
+ type: zod.ZodLiteral<"DesignToken">;
9670
+ value: zod.ZodString;
9671
+ }, "strip", zod.ZodTypeAny, {
9672
+ value: string;
9673
+ type: "DesignToken";
9674
+ }, {
9675
+ value: string;
9676
+ type: "DesignToken";
9677
+ }>]>, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodObject<{
9588
9678
  type: zod.ZodLiteral<"ManualDesignValue">;
9589
9679
  value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
9590
9680
  }, "strip", zod.ZodTypeAny, {
@@ -9602,7 +9692,7 @@ declare class ContentfulMcpTools {
9602
9692
  }, {
9603
9693
  value: string;
9604
9694
  type: "DesignToken";
9605
- }>]>>>>;
9695
+ }>]>>]>>>;
9606
9696
  contentBindings: zod.ZodOptional<zod.ZodObject<{
9607
9697
  sys: zod.ZodObject<{
9608
9698
  type: zod.ZodLiteral<"ResourceLink">;
@@ -9793,7 +9883,13 @@ declare class ContentfulMcpTools {
9793
9883
  }[] | undefined;
9794
9884
  } | undefined;
9795
9885
  description?: string | undefined;
9796
- designProperties?: Record<string, Record<string, {
9886
+ designProperties?: Record<string, {
9887
+ value: string;
9888
+ type: "DesignToken";
9889
+ } | {
9890
+ value: string | number | boolean;
9891
+ type: "ManualDesignValue";
9892
+ } | Record<string, {
9797
9893
  value: string;
9798
9894
  type: "DesignToken";
9799
9895
  } | {
package/dist/index.js CHANGED
@@ -6499,6 +6499,14 @@ var ExperienceSlotNodeSchema = z87.lazy(
6499
6499
  () => z87.union([ExperienceFragmentNodeSchema, InlineExperienceFragmentNodeSchema])
6500
6500
  );
6501
6501
 
6502
+ // src/types/cmaViewportCompatibility.ts
6503
+ function asViewportOptionalCmaPayload(payload) {
6504
+ return payload;
6505
+ }
6506
+ function asViewportOptionalCmaPayloadWithFlattenedDesignProperties(payload) {
6507
+ return payload;
6508
+ }
6509
+
6502
6510
  // src/tools/exo/components/createComponent.ts
6503
6511
  var CreateComponentToolParams = BaseToolSchema.extend({
6504
6512
  componentId: z88.string().optional().describe(
@@ -6506,7 +6514,9 @@ var CreateComponentToolParams = BaseToolSchema.extend({
6506
6514
  ),
6507
6515
  name: z88.string().describe("The name of the component"),
6508
6516
  description: z88.string().describe("Description of the component"),
6509
- viewports: z88.array(ViewportSchema).describe("Viewport definitions for the component (may be empty)"),
6517
+ viewports: z88.array(ViewportSchema).optional().describe(
6518
+ "Optional viewport definitions for the component. Omit for viewport-free components."
6519
+ ),
6510
6520
  contentProperties: z88.array(ContentPropertySchema).describe("Content property definitions (may be empty)"),
6511
6521
  designProperties: z88.array(DesignPropertySchema).describe("Design property definitions (may be empty)"),
6512
6522
  componentTree: z88.array(TreeNodeSchema).optional().describe("Optional component tree node definitions"),
@@ -6525,7 +6535,7 @@ function createComponentTool(config) {
6525
6535
  const componentData = {
6526
6536
  name: args.name,
6527
6537
  description: args.description,
6528
- viewports: args.viewports,
6538
+ ...args.viewports !== void 0 && { viewports: args.viewports },
6529
6539
  contentProperties: args.contentProperties,
6530
6540
  designProperties: args.designProperties,
6531
6541
  ...args.componentTree && { componentTree: args.componentTree },
@@ -6538,13 +6548,13 @@ function createComponentTool(config) {
6538
6548
  environmentId: args.environmentId,
6539
6549
  componentId: args.componentId
6540
6550
  },
6541
- {
6551
+ asViewportOptionalCmaPayload({
6542
6552
  sys: { id: args.componentId, type: "Component" },
6543
6553
  ...componentData
6544
- }
6554
+ })
6545
6555
  ) : await contentfulClient.component.create(
6546
6556
  { spaceId: args.spaceId, environmentId: args.environmentId },
6547
- componentData
6557
+ asViewportOptionalCmaPayload(componentData)
6548
6558
  );
6549
6559
  return createSuccessResponse("Component created successfully", {
6550
6560
  component
@@ -6589,7 +6599,8 @@ function upsertComponentTool(config) {
6589
6599
  `Version conflict: the component has changed since you read it (your version: ${args.version}, current version: ${current.sys.version}). Re-fetch the component with get_component and retry the update with the latest sys.version.`
6590
6600
  );
6591
6601
  }
6592
- const component = await contentfulClient.component.upsert(params, {
6602
+ const viewports = args.viewports ?? current.viewports;
6603
+ const componentData = {
6593
6604
  sys: {
6594
6605
  id: current.sys.id,
6595
6606
  type: "Component",
@@ -6597,14 +6608,18 @@ function upsertComponentTool(config) {
6597
6608
  },
6598
6609
  name: args.name ?? current.name,
6599
6610
  description: args.description ?? current.description,
6600
- viewports: args.viewports ?? current.viewports,
6611
+ ...viewports !== void 0 && { viewports },
6601
6612
  contentProperties: args.contentProperties ?? current.contentProperties,
6602
6613
  designProperties: args.designProperties ?? current.designProperties,
6603
6614
  ...args.componentTree ?? current.componentTree ? { componentTree: args.componentTree ?? current.componentTree } : {},
6604
6615
  ...args.slots ?? current.slots ? { slots: args.slots ?? current.slots } : {},
6605
6616
  ...args.metadata ?? current.metadata ? { metadata: args.metadata ?? current.metadata } : {},
6606
6617
  ...current.dataAssemblies ? { dataAssemblies: current.dataAssemblies } : {}
6607
- });
6618
+ };
6619
+ const component = await contentfulClient.component.upsert(
6620
+ params,
6621
+ asViewportOptionalCmaPayload(componentData)
6622
+ );
6608
6623
  return createSuccessResponse("Component updated successfully", {
6609
6624
  component
6610
6625
  });
@@ -6892,8 +6907,16 @@ var CreateExperienceFragmentToolParams = BaseToolSchema.extend({
6892
6907
  component: ComponentResourceLinkSchema.describe(
6893
6908
  "Resource link to the component this experience fragment is based on"
6894
6909
  ),
6895
- viewports: z95.array(ViewportSchema).describe("Viewport definitions (may be empty)"),
6896
- designProperties: z95.record(z95.string(), DimensionedDesignPropertyValueSchema).describe(
6910
+ viewports: z95.array(ViewportSchema).optional().describe(
6911
+ "Optional viewport definitions for the experience fragment. Omit for viewport-free experience fragments."
6912
+ ),
6913
+ designProperties: z95.record(
6914
+ z95.string(),
6915
+ z95.union([
6916
+ DesignPropertyValueSchema,
6917
+ DimensionedDesignPropertyValueSchema
6918
+ ])
6919
+ ).describe(
6897
6920
  "Design property values keyed by property ID (may be empty object)"
6898
6921
  ),
6899
6922
  contentBindings: ExperienceContentBindingsSchema.optional().describe(
@@ -6911,18 +6934,21 @@ function createExperienceFragmentTool(config) {
6911
6934
  config.protectedEnvironments
6912
6935
  );
6913
6936
  const contentfulClient = createExoToolClient(config, args);
6937
+ const experienceFragmentData = {
6938
+ name: args.name,
6939
+ description: args.description,
6940
+ component: args.component,
6941
+ ...args.viewports !== void 0 && { viewports: args.viewports },
6942
+ designProperties: args.designProperties,
6943
+ ...args.contentBindings && { contentBindings: args.contentBindings },
6944
+ ...args.slots && { slots: args.slots },
6945
+ ...args.metadata && { metadata: args.metadata }
6946
+ };
6914
6947
  const experienceFragment = await contentfulClient.experienceFragment.create(
6915
6948
  { spaceId: args.spaceId, environmentId: args.environmentId },
6916
- {
6917
- name: args.name,
6918
- description: args.description,
6919
- component: args.component,
6920
- viewports: args.viewports,
6921
- designProperties: args.designProperties,
6922
- ...args.contentBindings && { contentBindings: args.contentBindings },
6923
- ...args.slots && { slots: args.slots },
6924
- ...args.metadata && { metadata: args.metadata }
6925
- }
6949
+ asViewportOptionalCmaPayloadWithFlattenedDesignProperties(
6950
+ experienceFragmentData
6951
+ )
6926
6952
  );
6927
6953
  return createSuccessResponse("Experience fragment created successfully", {
6928
6954
  experienceFragment
@@ -6941,7 +6967,13 @@ var UpdateExperienceFragmentToolParams = BaseToolSchema.extend({
6941
6967
  name: z96.string().optional().describe("The name of the experience fragment"),
6942
6968
  description: z96.string().optional().describe("Description of the experience fragment"),
6943
6969
  viewports: z96.array(ViewportSchema).optional().describe("Viewport definitions; replaces existing viewports if provided"),
6944
- designProperties: z96.record(z96.string(), DimensionedDesignPropertyValueSchema).optional().describe("Design property values; replaces existing if provided"),
6970
+ designProperties: z96.record(
6971
+ z96.string(),
6972
+ z96.union([
6973
+ DesignPropertyValueSchema,
6974
+ DimensionedDesignPropertyValueSchema
6975
+ ])
6976
+ ).optional().describe("Design property values; replaces existing if provided"),
6945
6977
  contentBindings: ExperienceContentBindingsSchema.optional().describe(
6946
6978
  "Content bindings; replaces existing if provided"
6947
6979
  ),
@@ -6968,22 +7000,26 @@ function updateExperienceFragmentTool(config) {
6968
7000
  `Version conflict: the experience fragment has changed since you read it (your version: ${args.version}, current version: ${current.sys.version}). Re-fetch the experience fragment with get_experience_fragment and retry the update with the latest sys.version.`
6969
7001
  );
6970
7002
  }
7003
+ const viewports = args.viewports ?? current.viewports;
7004
+ const experienceFragmentData = {
7005
+ sys: {
7006
+ id: current.sys.id,
7007
+ type: "ExperienceFragment",
7008
+ version: current.sys.version
7009
+ },
7010
+ name: args.name ?? current.name,
7011
+ description: args.description ?? current.description,
7012
+ ...viewports !== void 0 && { viewports },
7013
+ designProperties: args.designProperties ?? current.designProperties,
7014
+ ...args.contentBindings ?? current.contentBindings ? { contentBindings: args.contentBindings ?? current.contentBindings } : {},
7015
+ ...args.slots ?? current.slots ? { slots: args.slots ?? current.slots } : {},
7016
+ ...args.metadata ?? current.metadata ? { metadata: args.metadata ?? current.metadata } : {}
7017
+ };
6971
7018
  const experienceFragment = await contentfulClient.experienceFragment.upsert(
6972
7019
  params,
6973
- {
6974
- sys: {
6975
- id: current.sys.id,
6976
- type: "ExperienceFragment",
6977
- version: current.sys.version
6978
- },
6979
- name: args.name ?? current.name,
6980
- description: args.description ?? current.description,
6981
- viewports: args.viewports ?? current.viewports,
6982
- designProperties: args.designProperties ?? current.designProperties,
6983
- ...args.contentBindings ?? current.contentBindings ? { contentBindings: args.contentBindings ?? current.contentBindings } : {},
6984
- ...args.slots ?? current.slots ? { slots: args.slots ?? current.slots } : {},
6985
- ...args.metadata ?? current.metadata ? { metadata: args.metadata ?? current.metadata } : {}
6986
- }
7020
+ asViewportOptionalCmaPayloadWithFlattenedDesignProperties(
7021
+ experienceFragmentData
7022
+ )
6987
7023
  );
6988
7024
  return createSuccessResponse("Experience fragment updated successfully", {
6989
7025
  experienceFragment
@@ -7272,8 +7308,8 @@ import { z as z102 } from "zod";
7272
7308
  var CreateExperienceTemplateToolParams = BaseToolSchema.extend({
7273
7309
  name: z102.string().describe("The name of the experience template"),
7274
7310
  description: z102.string().describe("Description of the experience template"),
7275
- viewports: z102.array(ViewportSchema).describe(
7276
- "Viewport definitions for the experience template (may be empty)"
7311
+ viewports: z102.array(ViewportSchema).optional().describe(
7312
+ "Optional viewport definitions for the experience template. Omit for viewport-free experience templates."
7277
7313
  ),
7278
7314
  contentProperties: z102.array(ContentPropertySchema).describe("Content property definitions (may be empty)"),
7279
7315
  designProperties: z102.array(DesignPropertySchema).describe("Design property definitions (may be empty)"),
@@ -7290,18 +7326,19 @@ function createExperienceTemplateTool(config) {
7290
7326
  config.protectedEnvironments
7291
7327
  );
7292
7328
  const contentfulClient = createExoToolClient(config, args);
7329
+ const experienceTemplateData = {
7330
+ name: args.name,
7331
+ description: args.description,
7332
+ ...args.viewports !== void 0 && { viewports: args.viewports },
7333
+ contentProperties: args.contentProperties,
7334
+ designProperties: args.designProperties,
7335
+ ...args.componentTree && { componentTree: args.componentTree },
7336
+ ...args.slots && { slots: args.slots },
7337
+ ...args.metadata && { metadata: args.metadata }
7338
+ };
7293
7339
  const experienceTemplate = await contentfulClient.experienceTemplate.create(
7294
7340
  { spaceId: args.spaceId, environmentId: args.environmentId },
7295
- {
7296
- name: args.name,
7297
- description: args.description,
7298
- viewports: args.viewports,
7299
- contentProperties: args.contentProperties,
7300
- designProperties: args.designProperties,
7301
- ...args.componentTree && { componentTree: args.componentTree },
7302
- ...args.slots && { slots: args.slots },
7303
- ...args.metadata && { metadata: args.metadata }
7304
- }
7341
+ asViewportOptionalCmaPayload(experienceTemplateData)
7305
7342
  );
7306
7343
  return createSuccessResponse("Experience template created successfully", {
7307
7344
  experienceTemplate
@@ -7346,24 +7383,26 @@ function upsertExperienceTemplateTool(config) {
7346
7383
  `Version conflict: the experience template has changed since you read it (your version: ${args.version}, current version: ${current.sys.version}). Re-fetch the experience template with get_experience_template and retry the update with the latest sys.version.`
7347
7384
  );
7348
7385
  }
7386
+ const viewports = args.viewports ?? current.viewports;
7387
+ const experienceTemplateData = {
7388
+ sys: {
7389
+ id: current.sys.id,
7390
+ type: "ExperienceTemplate",
7391
+ version: current.sys.version
7392
+ },
7393
+ name: args.name ?? current.name,
7394
+ description: args.description ?? current.description,
7395
+ ...viewports !== void 0 && { viewports },
7396
+ contentProperties: args.contentProperties ?? current.contentProperties,
7397
+ designProperties: args.designProperties ?? current.designProperties,
7398
+ ...args.componentTree ?? current.componentTree ? { componentTree: args.componentTree ?? current.componentTree } : {},
7399
+ ...args.slots ?? current.slots ? { slots: args.slots ?? current.slots } : {},
7400
+ ...args.metadata ?? current.metadata ? { metadata: args.metadata ?? current.metadata } : {},
7401
+ ...current.dataAssemblies ? { dataAssemblies: current.dataAssemblies } : {}
7402
+ };
7349
7403
  const experienceTemplate = await contentfulClient.experienceTemplate.upsert(
7350
7404
  params,
7351
- {
7352
- sys: {
7353
- id: current.sys.id,
7354
- type: "ExperienceTemplate",
7355
- version: current.sys.version
7356
- },
7357
- name: args.name ?? current.name,
7358
- description: args.description ?? current.description,
7359
- viewports: args.viewports ?? current.viewports,
7360
- contentProperties: args.contentProperties ?? current.contentProperties,
7361
- designProperties: args.designProperties ?? current.designProperties,
7362
- ...args.componentTree ?? current.componentTree ? { componentTree: args.componentTree ?? current.componentTree } : {},
7363
- ...args.slots ?? current.slots ? { slots: args.slots ?? current.slots } : {},
7364
- ...args.metadata ?? current.metadata ? { metadata: args.metadata ?? current.metadata } : {},
7365
- ...current.dataAssemblies ? { dataAssemblies: current.dataAssemblies } : {}
7366
- }
7405
+ asViewportOptionalCmaPayload(experienceTemplateData)
7367
7406
  );
7368
7407
  return createSuccessResponse("Experience template updated successfully", {
7369
7408
  experienceTemplate
@@ -7655,9 +7694,17 @@ var CreateExperienceToolParams = BaseToolSchema.extend({
7655
7694
  experienceTemplate: ExperienceTemplateResourceLinkSchema.describe(
7656
7695
  "Resource link to the ExperienceTemplate this experience is backed by"
7657
7696
  ),
7658
- viewports: z109.array(ViewportSchema).describe("Viewport definitions for the experience (may be empty)"),
7659
- designProperties: z109.record(z109.string(), DimensionedDesignPropertyValueSchema).describe(
7660
- "Design property values keyed by property ID. Each value is a dimensioned map (viewport ID \u2192 design value). May be an empty object."
7697
+ viewports: z109.array(ViewportSchema).optional().describe(
7698
+ "Optional viewport definitions for the experience. Omit for viewport-free experiences."
7699
+ ),
7700
+ designProperties: z109.record(
7701
+ z109.string(),
7702
+ z109.union([
7703
+ DesignPropertyValueSchema,
7704
+ DimensionedDesignPropertyValueSchema
7705
+ ])
7706
+ ).describe(
7707
+ "Design property values keyed by property ID. When viewports are provided, each value is a dimensioned map (viewport ID \u2192 design value); without viewports, use a direct design value. May be an empty object."
7661
7708
  ),
7662
7709
  contentBindings: ExperienceContentBindingsSchema.optional().describe(
7663
7710
  "Optional content bindings linking this experience to a data assembly"
@@ -7676,18 +7723,19 @@ function createExperienceTool(config) {
7676
7723
  config.protectedEnvironments
7677
7724
  );
7678
7725
  const contentfulClient = createExoToolClient(config, args);
7726
+ const experienceData = {
7727
+ name: args.name,
7728
+ description: args.description,
7729
+ experienceTemplate: args.experienceTemplate,
7730
+ ...args.viewports !== void 0 && { viewports: args.viewports },
7731
+ designProperties: args.designProperties,
7732
+ ...args.contentBindings && { contentBindings: args.contentBindings },
7733
+ ...args.slots && { slots: args.slots },
7734
+ ...args.metadata && { metadata: args.metadata }
7735
+ };
7679
7736
  const experience = await contentfulClient.experience.create(
7680
7737
  { spaceId: args.spaceId, environmentId: args.environmentId },
7681
- {
7682
- name: args.name,
7683
- description: args.description,
7684
- experienceTemplate: args.experienceTemplate,
7685
- viewports: args.viewports,
7686
- designProperties: args.designProperties,
7687
- ...args.contentBindings && { contentBindings: args.contentBindings },
7688
- ...args.slots && { slots: args.slots },
7689
- ...args.metadata && { metadata: args.metadata }
7690
- }
7738
+ asViewportOptionalCmaPayloadWithFlattenedDesignProperties(experienceData)
7691
7739
  );
7692
7740
  return createSuccessResponse("Experience created successfully", {
7693
7741
  experience
@@ -7706,7 +7754,13 @@ var UpsertExperienceToolParams = BaseToolSchema.extend({
7706
7754
  name: z110.string().optional().describe("The name of the experience"),
7707
7755
  description: z110.string().optional().describe("Description of the experience"),
7708
7756
  viewports: z110.array(ViewportSchema).optional().describe("Viewport definitions; replaces existing viewports if provided"),
7709
- designProperties: z110.record(z110.string(), DimensionedDesignPropertyValueSchema).optional().describe(
7757
+ designProperties: z110.record(
7758
+ z110.string(),
7759
+ z110.union([
7760
+ DesignPropertyValueSchema,
7761
+ DimensionedDesignPropertyValueSchema
7762
+ ])
7763
+ ).optional().describe(
7710
7764
  "Design property values keyed by property ID; replaces existing if provided"
7711
7765
  ),
7712
7766
  contentBindings: ExperienceContentBindingsSchema.optional().describe(
@@ -7735,7 +7789,8 @@ function upsertExperienceTool(config) {
7735
7789
  `Version conflict: the experience has changed since you read it (your version: ${args.version}, current version: ${current.sys.version}). Re-fetch the experience with get_experience and retry the update with the latest sys.version.`
7736
7790
  );
7737
7791
  }
7738
- const experience = await contentfulClient.experience.upsert(params, {
7792
+ const viewports = args.viewports ?? current.viewports;
7793
+ const experienceData = {
7739
7794
  sys: {
7740
7795
  id: current.sys.id,
7741
7796
  type: "Experience",
@@ -7743,12 +7798,16 @@ function upsertExperienceTool(config) {
7743
7798
  },
7744
7799
  name: args.name ?? current.name,
7745
7800
  description: args.description ?? current.description,
7746
- viewports: args.viewports ?? current.viewports,
7801
+ ...viewports !== void 0 && { viewports },
7747
7802
  designProperties: args.designProperties ?? current.designProperties,
7748
7803
  ...args.contentBindings ?? current.contentBindings ? { contentBindings: args.contentBindings ?? current.contentBindings } : {},
7749
7804
  ...args.slots ?? current.slots ? { slots: args.slots ?? current.slots } : {},
7750
7805
  ...args.metadata ?? current.metadata ? { metadata: args.metadata ?? current.metadata } : {}
7751
- });
7806
+ };
7807
+ const experience = await contentfulClient.experience.upsert(
7808
+ params,
7809
+ asViewportOptionalCmaPayloadWithFlattenedDesignProperties(experienceData)
7810
+ );
7752
7811
  return createSuccessResponse("Experience updated successfully", {
7753
7812
  experience
7754
7813
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/mcp-tools",
3
- "version": "0.12.13",
3
+ "version": "0.12.14",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",