@umbraco-cms/mcp-dev 18.1.10 → 18.1.12

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __create = Object.create;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -15964,6 +15964,32 @@ var GetDocumentPublishTool = {
15964
15964
  };
15965
15965
  var get_document_publish_default = _mcpserversdk.withStandardDecorators.call(void 0, GetDocumentPublishTool);
15966
15966
 
15967
+ // src/umbraco-api/tools/document/get/get-document-publish-with-descendants-result.ts
15968
+
15969
+
15970
+
15971
+
15972
+
15973
+ var GetDocumentPublishWithDescendantsResultTool = {
15974
+ name: "get-document-publish-with-descendants-result",
15975
+ description: `Gets the status/result of an in-progress or previously-polled publish-with-descendants operation by Id and taskId.
15976
+ Use this to follow up after publish-document-with-descendants reports the publish is still running, or returned an error.
15977
+ Returns isComplete: true once the publish has finished. If some descendants failed to publish, this returns an error result carrying the failed branch items.`,
15978
+ inputSchema: getDocumentByIdPublishWithDescendantsResultByTaskIdParams.shape,
15979
+ outputSchema: getDocumentByIdPublishWithDescendantsResultByTaskIdResponse.shape,
15980
+ annotations: {
15981
+ readOnlyHint: true
15982
+ },
15983
+ slices: ["publish"],
15984
+ enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Publish),
15985
+ handler: (async ({ id, taskId }) => {
15986
+ return _mcpserversdk.executeGetApiCall.call(void 0,
15987
+ (client) => client.getDocumentByIdPublishWithDescendantsResultByTaskId(id, taskId, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
15988
+ );
15989
+ })
15990
+ };
15991
+ var get_document_publish_with_descendants_result_default = _mcpserversdk.withStandardDecorators.call(void 0, GetDocumentPublishWithDescendantsResultTool);
15992
+
15967
15993
  // src/umbraco-api/tools/document/get/get-document-configuration.ts
15968
15994
 
15969
15995
 
@@ -16851,6 +16877,9 @@ var put_document_notifications_default = _mcpserversdk.withStandardDecorators.ca
16851
16877
 
16852
16878
 
16853
16879
 
16880
+
16881
+
16882
+
16854
16883
  var inputSchema12 = {
16855
16884
  id: _zod.z.string().uuid(),
16856
16885
  data: _zod.z.object(putDocumentByIdPublishWithDescendantsBody.shape)
@@ -16858,9 +16887,15 @@ var inputSchema12 = {
16858
16887
  var PublishDocumentWithDescendantsTool = {
16859
16888
  name: "publish-document-with-descendants",
16860
16889
  description: `Publishes a document and its descendants by Id. This is an asynchronous operation that may take time for large document trees.
16861
- The tool will poll for completion and return the final result when finished.`,
16890
+ The tool polls for completion for up to 60 seconds. If the publish is still running or ambiguous when that limit is reached, follow up with get-document-publish-with-descendants-result using the returned taskId.`,
16862
16891
  inputSchema: inputSchema12,
16863
- annotations: {},
16892
+ annotations: {
16893
+ // Unlike the other document put/ tools, this one starts a new async,
16894
+ // recursive publish task on every call rather than converging to the
16895
+ // same end state — a retried call fires a second concurrent job over
16896
+ // the same subtree, so it is not safe to advertise as idempotent.
16897
+ idempotentHint: false
16898
+ },
16864
16899
  slices: ["publish"],
16865
16900
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Publish),
16866
16901
  handler: (async (model) => {
@@ -16885,12 +16920,25 @@ var PublishDocumentWithDescendantsTool = {
16885
16920
  while (attempts < maxAttempts) {
16886
16921
  attempts++;
16887
16922
  await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
16923
+ let statusResponse;
16888
16924
  try {
16889
- const statusResponse = await client.getDocumentByIdPublishWithDescendantsResultByTaskId(
16925
+ statusResponse = await client.getDocumentByIdPublishWithDescendantsResultByTaskId(
16890
16926
  model.id,
16891
- initialResponse.taskId
16927
+ initialResponse.taskId,
16928
+ _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE
16892
16929
  );
16893
- if (statusResponse.isComplete) {
16930
+ } catch (error) {
16931
+ return _mcpserversdk.createToolResultError.call(void 0, {
16932
+ type: "Error",
16933
+ title: "Failed to poll publish-with-descendants status",
16934
+ detail: error instanceof Error ? error.message : String(error),
16935
+ status: 500,
16936
+ taskId: initialResponse.taskId
16937
+ });
16938
+ }
16939
+ if (statusResponse.status >= 200 && statusResponse.status < 300) {
16940
+ const data = statusResponse.data;
16941
+ if (_optionalChain([data, 'optionalAccess', _14 => _14.isComplete])) {
16894
16942
  return {
16895
16943
  content: [
16896
16944
  {
@@ -16900,29 +16948,22 @@ var PublishDocumentWithDescendantsTool = {
16900
16948
  ]
16901
16949
  };
16902
16950
  }
16903
- } catch (error) {
16904
- return {
16905
- content: [
16906
- {
16907
- type: "text",
16908
- text: JSON.stringify({
16909
- status: "error",
16910
- taskId: initialResponse.taskId,
16911
- message: `Failed to poll status: ${error}. You can manually check status using taskId.`
16912
- })
16913
- }
16914
- ]
16915
- };
16951
+ continue;
16916
16952
  }
16953
+ return _mcpserversdk.createToolResultError.call(void 0, {
16954
+ ..._mcpserversdk.toProblemDetails.call(void 0, statusResponse),
16955
+ documentId: model.id,
16956
+ taskId: initialResponse.taskId
16957
+ });
16917
16958
  }
16918
16959
  return {
16919
16960
  content: [
16920
16961
  {
16921
16962
  type: "text",
16922
16963
  text: JSON.stringify({
16923
- status: "timeout",
16964
+ status: "in-progress",
16924
16965
  taskId: initialResponse.taskId,
16925
- message: "Publish operation timed out after 1 minute. The operation may still be running. Use the taskId to check status manually."
16966
+ message: `Publishing is still in progress after 60 seconds. Use get-document-publish-with-descendants-result with id "${model.id}" and taskId "${initialResponse.taskId}" to check whether it has finished.`
16926
16967
  })
16927
16968
  }
16928
16969
  ]
@@ -16946,7 +16987,9 @@ var UnpublishDocumentTool = {
16946
16987
  name: "unpublish-document",
16947
16988
  description: "Unpublishes a document by Id.",
16948
16989
  inputSchema: inputSchema13,
16949
- annotations: {},
16990
+ annotations: {
16991
+ idempotentHint: true
16992
+ },
16950
16993
  slices: ["publish"],
16951
16994
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Unpublish),
16952
16995
  handler: (async (model) => {
@@ -16968,7 +17011,9 @@ var SortDocumentTool = {
16968
17011
  name: "sort-document",
16969
17012
  description: "Sorts the order of documents under a parent.",
16970
17013
  inputSchema: putDocumentSortBody.shape,
16971
- annotations: {},
17014
+ annotations: {
17015
+ idempotentHint: true
17016
+ },
16972
17017
  slices: ["sort"],
16973
17018
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Sort),
16974
17019
  handler: (async (model) => {
@@ -16998,7 +17043,9 @@ var SortDocumentChildrenTool = {
16998
17043
 
16999
17044
  When sorting by Name, an optional culture selects which variant name to sort by; the culture is not validated, so children that do not vary by it (or an unrecognised culture) fall back to the invariant name.`,
17000
17045
  inputSchema: inputSchema14,
17001
- annotations: {},
17046
+ annotations: {
17047
+ idempotentHint: true
17048
+ },
17002
17049
  slices: ["sort"],
17003
17050
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Sort),
17004
17051
  handler: (async (model) => {
@@ -17023,7 +17070,9 @@ var SortDocumentRootChildrenTool = {
17023
17070
 
17024
17071
  When sorting by Name, an optional culture selects which variant name to sort by; the culture is not validated, so documents that do not vary by it (or an unrecognised culture) fall back to the invariant name.`,
17025
17072
  inputSchema: putDocumentRootSortChildrenBody.shape,
17026
- annotations: {},
17073
+ annotations: {
17074
+ idempotentHint: true
17075
+ },
17027
17076
  slices: ["sort"],
17028
17077
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Sort),
17029
17078
  handler: (async (model) => {
@@ -17049,7 +17098,9 @@ var MoveDocumentTool = {
17049
17098
  name: "move-document",
17050
17099
  description: "Move a document to a new location",
17051
17100
  inputSchema: inputSchema15,
17052
- annotations: {},
17101
+ annotations: {
17102
+ idempotentHint: true
17103
+ },
17053
17104
  slices: ["move"],
17054
17105
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Move),
17055
17106
  handler: (async (model) => {
@@ -17078,7 +17129,9 @@ var PublishDocumentTool = {
17078
17129
  When the culture is not provided, the default culture is null.
17079
17130
  When the schedule is not provided, the default schedule is null.`,
17080
17131
  inputSchema: inputSchema16,
17081
- annotations: {},
17132
+ annotations: {
17133
+ idempotentHint: true
17134
+ },
17082
17135
  slices: ["publish"],
17083
17136
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Publish),
17084
17137
  handler: (async (model) => {
@@ -17125,7 +17178,9 @@ var RestoreFromRecycleBinTool = {
17125
17178
  name: "restore-document-from-recycle-bin",
17126
17179
  description: "Restores a document from the recycle bin.",
17127
17180
  inputSchema: putRecycleBinDocumentByIdRestoreParams.shape,
17128
- annotations: {},
17181
+ annotations: {
17182
+ idempotentHint: true
17183
+ },
17129
17184
  slices: ["move", "recycle-bin"],
17130
17185
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Delete),
17131
17186
  handler: (async ({ id }) => {
@@ -17146,7 +17201,9 @@ var MoveDocumentToRecycleBinTool = {
17146
17201
  name: "move-document-to-recycle-bin",
17147
17202
  description: "Move a document to the recycle bin",
17148
17203
  inputSchema: putDocumentByIdMoveToRecycleBinParams.shape,
17149
- annotations: {},
17204
+ annotations: {
17205
+ idempotentHint: true
17206
+ },
17150
17207
  slices: ["move", "recycle-bin"],
17151
17208
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Delete),
17152
17209
  handler: (async ({ id }) => {
@@ -17199,14 +17256,14 @@ var UpdateDocumentTool = {
17199
17256
  slices: ["update"],
17200
17257
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Update),
17201
17258
  handler: (async (model) => {
17202
- const incomingValues = _optionalChain([model, 'access', _14 => _14.data, 'optionalAccess', _15 => _15.values]);
17259
+ const incomingValues = _optionalChain([model, 'access', _15 => _15.data, 'optionalAccess', _16 => _16.values]);
17203
17260
  if (Array.isArray(incomingValues) && incomingValues.length === 0 && !model.confirmClearValues) {
17204
17261
  const client = UmbracoManagementClient3.getClient();
17205
17262
  let currentDocument;
17206
17263
  try {
17207
17264
  currentDocument = await client.getDocumentById(model.id);
17208
17265
  } catch (error) {
17209
- const status = _optionalChain([error, 'optionalAccess', _16 => _16.response, 'optionalAccess', _17 => _17.status]);
17266
+ const status = _optionalChain([error, 'optionalAccess', _17 => _17.response, 'optionalAccess', _18 => _18.status]);
17210
17267
  if (status !== 404) {
17211
17268
  throw error;
17212
17269
  }
@@ -17275,20 +17332,25 @@ async function getAllDocumentTypeProperties(documentTypeId) {
17275
17332
  const client = UmbracoManagementClient3.getClient();
17276
17333
  const visitedIds = /* @__PURE__ */ new Set();
17277
17334
  const properties = [];
17278
- async function resolveDocumentType(docTypeId) {
17335
+ const rootDocType = await client.getDocumentTypeById(documentTypeId);
17336
+ const rootVariesByCulture = rootDocType.variesByCulture;
17337
+ const rootVariesBySegment = rootDocType.variesBySegment;
17338
+ async function resolveDocumentType(docTypeId, preloaded) {
17279
17339
  if (visitedIds.has(docTypeId)) {
17280
17340
  return;
17281
17341
  }
17282
17342
  visitedIds.add(docTypeId);
17283
- const docType = await client.getDocumentTypeById(docTypeId);
17343
+ const docType = await _asyncNullishCoalesce(preloaded, async () => ( await client.getDocumentTypeById(docTypeId)));
17284
17344
  for (const prop of docType.properties) {
17285
17345
  if (!properties.some((p) => p.alias === prop.alias)) {
17286
17346
  properties.push({
17287
17347
  alias: prop.alias,
17288
17348
  name: prop.name,
17289
17349
  dataTypeId: prop.dataType.id,
17290
- variesByCulture: prop.variesByCulture,
17291
- variesBySegment: prop.variesBySegment
17350
+ // AND with the root document type's own flag: a composition's property can't
17351
+ // vary more than the document type it's actually used on.
17352
+ variesByCulture: prop.variesByCulture && rootVariesByCulture,
17353
+ variesBySegment: prop.variesBySegment && rootVariesBySegment
17292
17354
  });
17293
17355
  }
17294
17356
  }
@@ -17296,7 +17358,7 @@ async function getAllDocumentTypeProperties(documentTypeId) {
17296
17358
  await resolveDocumentType(composition.documentType.id);
17297
17359
  }
17298
17360
  }
17299
- await resolveDocumentType(documentTypeId);
17361
+ await resolveDocumentType(documentTypeId, rootDocType);
17300
17362
  return properties;
17301
17363
  }
17302
17364
  function validateCultureSegment(prop, def) {
@@ -18171,14 +18233,14 @@ function removeRteBlockElement(markup, contentKey) {
18171
18233
  return markup.slice(0, start) + markup.slice(end);
18172
18234
  }
18173
18235
  function getBlockTypeConfigurations(dataTypeValues) {
18174
- const blocks = _optionalChain([dataTypeValues, 'optionalAccess', _18 => _18.find, 'call', _19 => _19((v) => v.alias === "blocks"), 'optionalAccess', _20 => _20.value]);
18236
+ const blocks = _optionalChain([dataTypeValues, 'optionalAccess', _19 => _19.find, 'call', _20 => _20((v) => v.alias === "blocks"), 'optionalAccess', _21 => _21.value]);
18175
18237
  return Array.isArray(blocks) ? blocks : [];
18176
18238
  }
18177
18239
  function findBlockTypeConfiguration(configs, contentElementTypeKey) {
18178
18240
  return configs.find((c) => c.contentElementTypeKey === contentElementTypeKey);
18179
18241
  }
18180
18242
  function findAreaConfiguration(configs, parentContentTypeKey, areaKey) {
18181
- return _optionalChain([findBlockTypeConfiguration, 'call', _21 => _21(configs, parentContentTypeKey), 'optionalAccess', _22 => _22.areas, 'optionalAccess', _23 => _23.find, 'call', _24 => _24((a) => a.key === areaKey)]);
18243
+ return _optionalChain([findBlockTypeConfiguration, 'call', _22 => _22(configs, parentContentTypeKey), 'optionalAccess', _23 => _23.areas, 'optionalAccess', _24 => _24.find, 'call', _25 => _25((a) => a.key === areaKey)]);
18182
18244
  }
18183
18245
  function checkAllowedInArea(blockConfig, area) {
18184
18246
  if (blockConfig.allowInAreas === false) {
@@ -18288,7 +18350,10 @@ async function saveDocumentValues(documentId, document) {
18288
18350
 
18289
18351
 
18290
18352
 
18291
- var createDocumentBlockOutputSchema = updateBlockPropertyOutputSchema;
18353
+ var blockEditorKindSchema = _zod.z.enum(["BlockList", "BlockGrid", "RichText"]);
18354
+ var createDocumentBlockOutputSchema = updateBlockPropertyOutputSchema.extend({
18355
+ kind: blockEditorKindSchema
18356
+ });
18292
18357
  var blockPropertyValueSchema = _zod.z.object({
18293
18358
  alias: _zod.z.string().min(1).describe("The property alias on the block's element type"),
18294
18359
  value: _zod.z.any().nullish().describe("The property value"),
@@ -18322,7 +18387,8 @@ var createDocumentBlockSchema = {
18322
18387
  properties: _zod.z.array(blockPropertyValueSchema).describe("Settings property values")
18323
18388
  }).optional().describe("Settings for the new block; the settings element type comes from the data type configuration. When the block type has a settings element type, a settings entry is always created (empty if this is omitted), as the backoffice does"),
18324
18389
  placement: placementSchema.optional().describe("Where to place the block relative to siblings (default: append)"),
18325
- grid: gridSchema.optional().describe("BlockGrid-only layout options. Rejected for BlockList/RichText properties")
18390
+ grid: gridSchema.optional().describe("BlockGrid-only layout options. Rejected for BlockList/RichText properties"),
18391
+ expectedKind: blockEditorKindSchema.optional().describe("Optional guard: the editor the property must use. If the property uses a different editor, nothing is written and the call is rejected")
18326
18392
  };
18327
18393
  async function validateBlockProperties(elementTypeKey, properties, label) {
18328
18394
  if (properties.length === 0) {
@@ -18357,7 +18423,9 @@ var CreateDocumentBlockTool = {
18357
18423
  or the named area given in grid.
18358
18424
  - grid (BlockGrid only): columnSpan (default 12), rowSpan (default 1), and areaKey + parentContentKey
18359
18425
  to insert into a named area of an existing block.
18360
- - New block keys are generated; the result returns the new contentKey.
18426
+ - expectedKind (optional): "BlockList" | "BlockGrid" | "RichText". When given, the call is rejected
18427
+ without writing anything if the property uses a different editor.
18428
+ - New block keys are generated; the result returns the new contentKey and the property's editor kind.
18361
18429
  - The document is saved, not published.
18362
18430
 
18363
18431
  Example: { documentId: "...", propertyAlias: "mainContent", contentTypeKey: "...",
@@ -18375,15 +18443,21 @@ var CreateDocumentBlockTool = {
18375
18443
  const { kind, container, blockConfigs } = ctx;
18376
18444
  const placement = _nullishCoalesce(model.placement, () => ( { position: "append" }));
18377
18445
  const contentProperties = _nullishCoalesce(model.properties, () => ( []));
18378
- const settingsProperties = _nullishCoalesce(_optionalChain([model, 'access', _25 => _25.settings, 'optionalAccess', _26 => _26.properties]), () => ( []));
18446
+ const settingsProperties = _nullishCoalesce(_optionalChain([model, 'access', _26 => _26.settings, 'optionalAccess', _27 => _27.properties]), () => ( []));
18447
+ if (model.expectedKind && kind !== model.expectedKind) {
18448
+ throw new (0, _mcpserversdk.ToolValidationError)({
18449
+ title: "Unexpected block editor",
18450
+ detail: `Property '${model.propertyAlias}' is a ${kind} property, not ${model.expectedKind}`
18451
+ });
18452
+ }
18379
18453
  if (model.grid && kind !== "BlockGrid") {
18380
18454
  throw new (0, _mcpserversdk.ToolValidationError)({
18381
18455
  title: "grid options not supported",
18382
18456
  detail: `'grid' only applies to BlockGrid properties; '${model.propertyAlias}' is a ${kind} property`
18383
18457
  });
18384
18458
  }
18385
- const areaKey = _optionalChain([model, 'access', _27 => _27.grid, 'optionalAccess', _28 => _28.areaKey]);
18386
- const parentContentKey = _optionalChain([model, 'access', _29 => _29.grid, 'optionalAccess', _30 => _30.parentContentKey]);
18459
+ const areaKey = _optionalChain([model, 'access', _28 => _28.grid, 'optionalAccess', _29 => _29.areaKey]);
18460
+ const parentContentKey = _optionalChain([model, 'access', _30 => _30.grid, 'optionalAccess', _31 => _31.parentContentKey]);
18387
18461
  if (!!areaKey !== !!parentContentKey) {
18388
18462
  throw new (0, _mcpserversdk.ToolValidationError)({
18389
18463
  title: "Incomplete area target",
@@ -18433,7 +18507,7 @@ var CreateDocumentBlockTool = {
18433
18507
  title: "Area not found",
18434
18508
  detail: `Area '${key}' is not configured for block type '${parentBlock.contentTypeKey}'`,
18435
18509
  extensions: {
18436
- availableAreas: (_nullishCoalesce(_optionalChain([findBlockTypeConfiguration, 'call', _31 => _31(blockConfigs, parentBlock.contentTypeKey), 'optionalAccess', _32 => _32.areas]), () => ( []))).map((a) => ({ key: a.key, alias: _nullishCoalesce(a.alias, () => ( null)) }))
18510
+ availableAreas: (_nullishCoalesce(_optionalChain([findBlockTypeConfiguration, 'call', _32 => _32(blockConfigs, parentBlock.contentTypeKey), 'optionalAccess', _33 => _33.areas]), () => ( []))).map((a) => ({ key: a.key, alias: _nullishCoalesce(a.alias, () => ( null)) }))
18437
18511
  }
18438
18512
  });
18439
18513
  }
@@ -18455,7 +18529,7 @@ var CreateDocumentBlockTool = {
18455
18529
  detail: `No block with contentKey '${placement.contentKey}' exists in property '${model.propertyAlias}'`
18456
18530
  });
18457
18531
  }
18458
- if (areaKey && (sibling.areaKey !== areaKey || _optionalChain([sibling, 'access', _33 => _33.parent, 'optionalAccess', _34 => _34.contentKey]) !== parentContentKey)) {
18532
+ if (areaKey && (sibling.areaKey !== areaKey || _optionalChain([sibling, 'access', _34 => _34.parent, 'optionalAccess', _35 => _35.contentKey]) !== parentContentKey)) {
18459
18533
  throw new (0, _mcpserversdk.ToolValidationError)({
18460
18534
  title: "Sibling not in target area",
18461
18535
  detail: `Block '${placement.contentKey}' is not in area '${areaKey}' of block '${parentContentKey}'`
@@ -18500,8 +18574,8 @@ var CreateDocumentBlockTool = {
18500
18574
  const layoutEntry = buildLayoutEntry(kind, {
18501
18575
  contentKey,
18502
18576
  settingsKey,
18503
- columnSpan: _optionalChain([model, 'access', _35 => _35.grid, 'optionalAccess', _36 => _36.columnSpan]),
18504
- rowSpan: _optionalChain([model, 'access', _37 => _37.grid, 'optionalAccess', _38 => _38.rowSpan]),
18577
+ columnSpan: _optionalChain([model, 'access', _36 => _36.grid, 'optionalAccess', _37 => _37.columnSpan]),
18578
+ rowSpan: _optionalChain([model, 'access', _38 => _38.grid, 'optionalAccess', _39 => _39.rowSpan]),
18505
18579
  areaKeys: (_nullishCoalesce(blockConfig.areas, () => ( []))).map((a) => a.key)
18506
18580
  });
18507
18581
  const elementType = await client.getDocumentTypeById(model.contentTypeKey);
@@ -18550,6 +18624,7 @@ var CreateDocumentBlockTool = {
18550
18624
  return _mcpserversdk.createToolResult.call(void 0, {
18551
18625
  success: true,
18552
18626
  message: `Created 1 block in ${kind} property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}'`,
18627
+ kind,
18553
18628
  results: [{
18554
18629
  success: true,
18555
18630
  contentKey,
@@ -18857,6 +18932,7 @@ var DocumentCollection = {
18857
18932
  if (AuthorizationPolicies.TreeAccessDocuments(user)) {
18858
18933
  tools.push(get_document_by_id_default);
18859
18934
  tools.push(get_document_publish_default);
18935
+ tools.push(get_document_publish_with_descendants_result_default);
18860
18936
  tools.push(get_document_configuration_default);
18861
18937
  tools.push(get_document_type_schema_default);
18862
18938
  tools.push(copy_document_default);
@@ -19243,7 +19319,7 @@ var CopyDocumentTypeTool = {
19243
19319
  validateStatus: () => true
19244
19320
  });
19245
19321
  if (response.status === 201) {
19246
- const location = _optionalChain([response, 'access', _39 => _39.headers, 'optionalAccess', _40 => _40.location]) || "";
19322
+ const location = _optionalChain([response, 'access', _40 => _40.headers, 'optionalAccess', _41 => _41.location]) || "";
19247
19323
  const newId = location.split("/").pop() || "";
19248
19324
  const output = { id: newId };
19249
19325
  return _mcpserversdk.createToolResult.call(void 0, output);
@@ -21492,7 +21568,7 @@ var CopyElementTool = {
21492
21568
  validateStatus: () => true
21493
21569
  });
21494
21570
  if (response.status === 201) {
21495
- const location = _optionalChain([response, 'access', _41 => _41.headers, 'optionalAccess', _42 => _42.location]) || "";
21571
+ const location = _optionalChain([response, 'access', _42 => _42.headers, 'optionalAccess', _43 => _43.location]) || "";
21496
21572
  const newId = location.split("/").pop() || "";
21497
21573
  const output = { id: newId };
21498
21574
  return _mcpserversdk.createToolResult.call(void 0, output);
@@ -23440,6 +23516,11 @@ async function validateFilePath(filePath, allowedPaths) {
23440
23516
 
23441
23517
 
23442
23518
 
23519
+
23520
+
23521
+
23522
+
23523
+
23443
23524
  var BASE64_MAX_BYTES = 10 * 1024;
23444
23525
  function getExtensionFromMimeType(mimeType) {
23445
23526
  if (!mimeType) return void 0;
@@ -23448,19 +23529,47 @@ function getExtensionFromMimeType(mimeType) {
23448
23529
  return extension ? `.${extension}` : void 0;
23449
23530
  }
23450
23531
  function validateMediaTypeForSvg(filePath, fileUrl, fileName, mediaTypeName) {
23451
- const isSvg = _optionalChain([filePath, 'optionalAccess', _43 => _43.toLowerCase, 'call', _44 => _44(), 'access', _45 => _45.endsWith, 'call', _46 => _46(".svg")]) || _optionalChain([fileUrl, 'optionalAccess', _47 => _47.toLowerCase, 'call', _48 => _48(), 'access', _49 => _49.endsWith, 'call', _50 => _50(".svg")]) || fileName.toLowerCase().endsWith(".svg");
23452
- if (isSvg && mediaTypeName === _mcpserversdk.MEDIA_TYPE_IMAGE) {
23532
+ const isSvg = _optionalChain([filePath, 'optionalAccess', _44 => _44.toLowerCase, 'call', _45 => _45(), 'access', _46 => _46.endsWith, 'call', _47 => _47(".svg")]) || _optionalChain([fileUrl, 'optionalAccess', _48 => _48.toLowerCase, 'call', _49 => _49(), 'access', _50 => _50.endsWith, 'call', _51 => _51(".svg")]) || fileName.toLowerCase().endsWith(".svg");
23533
+ if (isSvg && mediaTypeName.toLowerCase() === _mcpserversdk.MEDIA_TYPE_IMAGE.toLowerCase()) {
23453
23534
  console.warn(`SVG detected - using ${_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS} media type instead of ${_mcpserversdk.MEDIA_TYPE_IMAGE}`);
23454
23535
  return _mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS;
23455
23536
  }
23456
23537
  return mediaTypeName;
23457
23538
  }
23539
+ var BUILT_IN_MEDIA_TYPES = {
23540
+ [_mcpserversdk.MEDIA_TYPE_IMAGE.toLowerCase()]: { name: _mcpserversdk.MEDIA_TYPE_IMAGE, alias: _mcpserversdk.MEDIA_TYPE_ALIASES.Image, fallbackToFile: false },
23541
+ [_mcpserversdk.MEDIA_TYPE_FILE.toLowerCase()]: { name: _mcpserversdk.MEDIA_TYPE_FILE, alias: _mcpserversdk.MEDIA_TYPE_ALIASES.File, fallbackToFile: false },
23542
+ [_mcpserversdk.MEDIA_TYPE_VIDEO.toLowerCase()]: { name: _mcpserversdk.MEDIA_TYPE_VIDEO, alias: _mcpserversdk.MEDIA_TYPE_ALIASES.Video, fallbackToFile: true },
23543
+ [_mcpserversdk.MEDIA_TYPE_AUDIO.toLowerCase()]: { name: _mcpserversdk.MEDIA_TYPE_AUDIO, alias: _mcpserversdk.MEDIA_TYPE_ALIASES.Audio, fallbackToFile: true },
23544
+ [_mcpserversdk.MEDIA_TYPE_ARTICLE.toLowerCase()]: { name: _mcpserversdk.MEDIA_TYPE_ARTICLE, alias: _mcpserversdk.MEDIA_TYPE_ALIASES.Article, fallbackToFile: true },
23545
+ [_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS.toLowerCase()]: { name: _mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS, alias: _mcpserversdk.MEDIA_TYPE_ALIASES.VectorGraphics, fallbackToFile: true }
23546
+ };
23547
+ function getSubstitutedMediaType(requestedName, resolved) {
23548
+ return requestedName.toLowerCase() === resolved.name.toLowerCase() ? void 0 : requestedName;
23549
+ }
23550
+ function getMediaTypeWarning(result) {
23551
+ return result.substitutedFor ? `This site has no '${result.substitutedFor}' media type, so '${result.mediaTypeName}' was used instead.` : void 0;
23552
+ }
23553
+ function formatMediaCreatedMessage(result) {
23554
+ return result.substitutedFor ? `Media "${result.name}" created as '${result.mediaTypeName}' \u2014 this site has no '${result.substitutedFor}' media type.` : `Media "${result.name}" created successfully`;
23555
+ }
23458
23556
  async function fetchMediaTypeId(client, mediaTypeName) {
23459
- const standardTypeKey = Object.keys(_mcpserversdk.STANDARD_MEDIA_TYPES).find(
23460
- (key) => key.toLowerCase() === mediaTypeName.toLowerCase()
23461
- );
23462
- if (standardTypeKey) {
23463
- return _mcpserversdk.STANDARD_MEDIA_TYPES[standardTypeKey];
23557
+ const builtIn = BUILT_IN_MEDIA_TYPES[mediaTypeName.toLowerCase()];
23558
+ if (builtIn) {
23559
+ const id = await _mcpserversdk.resolveMediaTypeId.call(void 0, builtIn.alias);
23560
+ if (id) {
23561
+ return { id, name: builtIn.name };
23562
+ }
23563
+ if (builtIn.fallbackToFile) {
23564
+ const fileId = await _mcpserversdk.resolveMediaTypeId.call(void 0, _mcpserversdk.MEDIA_TYPE_ALIASES.File);
23565
+ if (fileId) {
23566
+ console.warn(`Media type '${builtIn.name}' not found on this site - using ${_mcpserversdk.MEDIA_TYPE_FILE} instead`);
23567
+ return { id: fileId, name: _mcpserversdk.MEDIA_TYPE_FILE };
23568
+ }
23569
+ }
23570
+ throw new Error(
23571
+ `Media type '${builtIn.name}' (alias '${builtIn.alias}') not found on this site` + (builtIn.fallbackToFile ? `, and no '${_mcpserversdk.MEDIA_TYPE_FILE}' media type to fall back to` : "")
23572
+ );
23464
23573
  }
23465
23574
  const response = await client.getItemMediaTypeSearch({ query: mediaTypeName });
23466
23575
  const mediaType = response.items.find(
@@ -23472,7 +23581,7 @@ async function fetchMediaTypeId(client, mediaTypeName) {
23472
23581
  `Media type '${mediaTypeName}' not found. Available types: ${availableTypes || "None found"}`
23473
23582
  );
23474
23583
  }
23475
- return mediaType.id;
23584
+ return { id: mediaType.id, name: mediaType.name };
23476
23585
  }
23477
23586
  function getEditorAlias(mediaTypeName) {
23478
23587
  return mediaTypeName === _mcpserversdk.MEDIA_TYPE_IMAGE ? "Umbraco.ImageCropper" : "Umbraco.UploadField";
@@ -23586,7 +23695,7 @@ async function uploadMediaFile(client, params) {
23586
23695
  params.name,
23587
23696
  params.mediaTypeName
23588
23697
  );
23589
- const mediaTypeId = await fetchMediaTypeId(client, validatedMediaTypeName);
23698
+ const mediaType = await fetchMediaTypeId(client, validatedMediaTypeName);
23590
23699
  const { data, filename } = await createFilePayload(
23591
23700
  params.sourceType,
23592
23701
  params.filePath,
@@ -23602,14 +23711,14 @@ async function uploadMediaFile(client, params) {
23602
23711
  });
23603
23712
  } catch (error) {
23604
23713
  const err = error;
23605
- const errorData = _optionalChain([err, 'access', _51 => _51.response, 'optionalAccess', _52 => _52.data]) ? typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data) : err.message;
23606
- throw new Error(`Failed to upload temporary file: ${_optionalChain([err, 'access', _53 => _53.response, 'optionalAccess', _54 => _54.status]) || "Unknown error"} - ${errorData}`);
23714
+ const errorData = _optionalChain([err, 'access', _52 => _52.response, 'optionalAccess', _53 => _53.data]) ? typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data) : err.message;
23715
+ throw new Error(`Failed to upload temporary file: ${_optionalChain([err, 'access', _54 => _54.response, 'optionalAccess', _55 => _55.status]) || "Unknown error"} - ${errorData}`);
23607
23716
  }
23608
- const valueStructure = buildValueStructure(validatedMediaTypeName, params.temporaryFileId);
23717
+ const valueStructure = buildValueStructure(mediaType.name, params.temporaryFileId);
23609
23718
  let response;
23610
23719
  try {
23611
23720
  response = await client.postMedia({
23612
- mediaType: { id: mediaTypeId },
23721
+ mediaType: { id: mediaType.id },
23613
23722
  variants: [
23614
23723
  {
23615
23724
  culture: null,
@@ -23623,12 +23732,12 @@ async function uploadMediaFile(client, params) {
23623
23732
  }, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE);
23624
23733
  } catch (error) {
23625
23734
  const err = error;
23626
- throw new Error(`Failed to create media item: ${_optionalChain([err, 'access', _55 => _55.response, 'optionalAccess', _56 => _56.status]) || "Unknown error"} - ${JSON.stringify(_optionalChain([err, 'access', _57 => _57.response, 'optionalAccess', _58 => _58.data])) || err.message}`);
23735
+ throw new Error(`Failed to create media item: ${_optionalChain([err, 'access', _56 => _56.response, 'optionalAccess', _57 => _57.status]) || "Unknown error"} - ${JSON.stringify(_optionalChain([err, 'access', _58 => _58.response, 'optionalAccess', _59 => _59.data])) || err.message}`);
23627
23736
  }
23628
23737
  if (response.status < 200 || response.status >= 300) {
23629
23738
  throw new Error(`Request failed with status code ${response.status}`);
23630
23739
  }
23631
- const locationHeader = _optionalChain([response, 'access', _59 => _59.headers, 'optionalAccess', _60 => _60.location]) || _optionalChain([response, 'access', _61 => _61.headers, 'optionalAccess', _62 => _62.Location]);
23740
+ const locationHeader = _optionalChain([response, 'access', _60 => _60.headers, 'optionalAccess', _61 => _61.location]) || _optionalChain([response, 'access', _62 => _62.headers, 'optionalAccess', _63 => _63.Location]);
23632
23741
  if (!locationHeader) {
23633
23742
  throw new Error("No Location header in response - cannot determine created media ID");
23634
23743
  }
@@ -23637,7 +23746,12 @@ async function uploadMediaFile(client, params) {
23637
23746
  throw new Error(`Could not extract ID from Location header: ${locationHeader}`);
23638
23747
  }
23639
23748
  const mediaId = idMatch[1];
23640
- return { name: params.name, id: mediaId };
23749
+ return {
23750
+ name: params.name,
23751
+ id: mediaId,
23752
+ mediaTypeName: mediaType.name,
23753
+ substitutedFor: getSubstitutedMediaType(validatedMediaTypeName, mediaType)
23754
+ };
23641
23755
  }
23642
23756
 
23643
23757
  // src/umbraco-api/tools/media/post/helpers/source-type-helpers.ts
@@ -23660,7 +23774,7 @@ function buildSourceTypeSection(allowFilePath, otherSources) {
23660
23774
 
23661
23775
 
23662
23776
  function isStreamingUploadAvailable() {
23663
- return _optionalChain([_mcpserversdk.getActiveRequestContext.call(void 0, ), 'optionalAccess', _63 => _63.umbracoAuth]) !== void 0;
23777
+ return _optionalChain([_mcpserversdk.getActiveRequestContext.call(void 0, ), 'optionalAccess', _64 => _64.umbracoAuth]) !== void 0;
23664
23778
  }
23665
23779
  async function resolveAuth() {
23666
23780
  const { accessToken, baseUrl } = await _mcpserversdk.getSessionUmbracoAuth.call(void 0, );
@@ -23668,7 +23782,7 @@ async function resolveAuth() {
23668
23782
  }
23669
23783
  function ensureExtension(name, contentType, urlPath) {
23670
23784
  if (name.includes(".")) return name;
23671
- const fromUrl = _optionalChain([urlPath, 'access', _64 => _64.match, 'call', _65 => _65(/\.([a-z0-9]{1,8})$/i), 'optionalAccess', _66 => _66[0]]);
23785
+ const fromUrl = _optionalChain([urlPath, 'access', _65 => _65.match, 'call', _66 => _66(/\.([a-z0-9]{1,8})$/i), 'optionalAccess', _67 => _67[0]]);
23672
23786
  if (fromUrl) return `${name}${fromUrl}`;
23673
23787
  if (contentType) {
23674
23788
  const subtype = contentType.split(";")[0].split("/")[1];
@@ -23686,7 +23800,7 @@ async function streamingUploadFromUrl(params) {
23686
23800
  params.name,
23687
23801
  params.mediaTypeName
23688
23802
  );
23689
- const [mediaTypeId, auth] = await Promise.all([
23803
+ const [mediaType, auth] = await Promise.all([
23690
23804
  fetchMediaTypeId(client, validatedMediaTypeName),
23691
23805
  resolveAuth()
23692
23806
  ]);
@@ -23761,10 +23875,10 @@ Content-Type: ${sourceContentType}\r
23761
23875
  `Umbraco temporary-file POST failed: HTTP ${tempResp.status} ${tempResp.statusText} - ${errBody}`
23762
23876
  );
23763
23877
  }
23764
- const valueStructure = buildValueStructure(validatedMediaTypeName, temporaryFileId);
23878
+ const valueStructure = buildValueStructure(mediaType.name, temporaryFileId);
23765
23879
  const response = await client.postMedia(
23766
23880
  {
23767
- mediaType: { id: mediaTypeId },
23881
+ mediaType: { id: mediaType.id },
23768
23882
  variants: [{ culture: null, segment: null, name: params.name }],
23769
23883
  values: [valueStructure],
23770
23884
  parent: params.parentId ? { id: params.parentId } : null
@@ -23774,25 +23888,32 @@ Content-Type: ${sourceContentType}\r
23774
23888
  if (response.status < 200 || response.status >= 300) {
23775
23889
  throw new Error(`postMedia failed with status ${response.status}`);
23776
23890
  }
23777
- const locationHeader = _nullishCoalesce(_optionalChain([response, 'access', _67 => _67.headers, 'optionalAccess', _68 => _68.location]), () => ( _optionalChain([response, 'access', _69 => _69.headers, 'optionalAccess', _70 => _70.Location])));
23778
- const idMatch = _optionalChain([locationHeader, 'optionalAccess', _71 => _71.match, 'call', _72 => _72(/\/([a-f0-9-]{36})$/i)]);
23891
+ const locationHeader = _nullishCoalesce(_optionalChain([response, 'access', _68 => _68.headers, 'optionalAccess', _69 => _69.location]), () => ( _optionalChain([response, 'access', _70 => _70.headers, 'optionalAccess', _71 => _71.Location])));
23892
+ const idMatch = _optionalChain([locationHeader, 'optionalAccess', _72 => _72.match, 'call', _73 => _73(/\/([a-f0-9-]{36})$/i)]);
23779
23893
  if (!idMatch) {
23780
23894
  throw new Error(
23781
23895
  `Could not extract media id from Location header: ${_nullishCoalesce(locationHeader, () => ( "(missing)"))}`
23782
23896
  );
23783
23897
  }
23784
- return { name: params.name, id: idMatch[1] };
23898
+ return {
23899
+ name: params.name,
23900
+ id: idMatch[1],
23901
+ mediaTypeName: mediaType.name,
23902
+ substitutedFor: getSubstitutedMediaType(validatedMediaTypeName, mediaType)
23903
+ };
23785
23904
  } finally {
23786
23905
  clearTimeout(overallTimeout);
23787
23906
  }
23788
23907
  }
23789
23908
  async function streamingUploadToToolResult(params) {
23790
23909
  try {
23791
- const { name, id } = await streamingUploadFromUrl(params);
23910
+ const result = await streamingUploadFromUrl(params);
23911
+ const warning = getMediaTypeWarning(result);
23792
23912
  return _mcpserversdk.createToolResult.call(void 0, {
23793
- message: `Media "${name}" created successfully`,
23794
- name,
23795
- id
23913
+ message: formatMediaCreatedMessage(result),
23914
+ name: result.name,
23915
+ id: result.id,
23916
+ ...warning ? { warning } : {}
23796
23917
  });
23797
23918
  } catch (error) {
23798
23919
  return _mcpserversdk.createToolResultError.call(void 0, {
@@ -23822,7 +23943,9 @@ var fileObjectSchema = _zod.z.object({
23822
23943
  var createMediaOutputSchema = _zod.z.object({
23823
23944
  message: _zod.z.string(),
23824
23945
  name: _zod.z.string(),
23825
- id: _zod.z.string().guid()
23946
+ id: _zod.z.string().guid(),
23947
+ /** Set only when the site lacks the requested media type and another was used (e.g. Video → File). */
23948
+ warning: _zod.z.string().optional()
23826
23949
  });
23827
23950
  function createCreateMediaTool(options) {
23828
23951
  const sourceTypeValues = options.allowFilePath ? ["filePath", "url", "file", "base64"] : ["url", "file", "base64"];
@@ -23880,7 +24003,7 @@ ${filePathSection}
23880
24003
  let effectiveSourceType;
23881
24004
  let effectiveFileUrl = model.fileUrl;
23882
24005
  if (model.sourceType === "file") {
23883
- if (!_optionalChain([model, 'access', _73 => _73.file, 'optionalAccess', _74 => _74.download_url])) {
24006
+ if (!_optionalChain([model, 'access', _74 => _74.file, 'optionalAccess', _75 => _75.download_url])) {
23884
24007
  return _mcpserversdk.createToolResultError.call(void 0, {
23885
24008
  detail: "Error creating media: sourceType is 'file' but no file object was provided. ChatGPT's connector should inject this automatically when a file is attached \u2014 if it didn't, the user has nothing attached or your client doesn't support openai/fileParams."
23886
24009
  });
@@ -23906,7 +24029,7 @@ ${filePathSection}
23906
24029
  try {
23907
24030
  const client = UmbracoManagementClient3.getClient();
23908
24031
  const temporaryFileId = _uuid.v4.call(void 0, );
23909
- const { name: actualName, id } = await uploadMediaFile(client, {
24032
+ const result = await uploadMediaFile(client, {
23910
24033
  sourceType: effectiveSourceType,
23911
24034
  name: model.name,
23912
24035
  mediaTypeName: model.mediaTypeName,
@@ -23916,10 +24039,12 @@ ${filePathSection}
23916
24039
  parentId: model.parentId,
23917
24040
  temporaryFileId
23918
24041
  });
24042
+ const warning = getMediaTypeWarning(result);
23919
24043
  return _mcpserversdk.createToolResult.call(void 0, {
23920
- message: `Media "${actualName}" created successfully`,
23921
- name: actualName,
23922
- id
24044
+ message: formatMediaCreatedMessage(result),
24045
+ name: result.name,
24046
+ id: result.id,
24047
+ ...warning ? { warning } : {}
23923
24048
  });
23924
24049
  } catch (error) {
23925
24050
  return _mcpserversdk.createToolResultError.call(void 0, {
@@ -23952,9 +24077,15 @@ var createMediaMultipleOutputSchema = _zod.z.object({
23952
24077
  success: _zod.z.boolean(),
23953
24078
  name: _zod.z.string(),
23954
24079
  id: _zod.z.string().guid().optional(),
23955
- error: _zod.z.string().optional()
24080
+ error: _zod.z.string().optional(),
24081
+ /** Set only when the site lacks the requested media type and another was used (e.g. Video → File). */
24082
+ warning: _zod.z.string().optional()
23956
24083
  }))
23957
24084
  });
24085
+ function toSuccessResult(upload) {
24086
+ const warning = getMediaTypeWarning(upload);
24087
+ return { success: true, name: upload.name, id: upload.id, ...warning ? { warning } : {} };
24088
+ }
23958
24089
  var fileObjectSchema2 = _zod.z.object({
23959
24090
  download_url: _zod.z.string().describe("Temporary URL the host provides to fetch the file bytes"),
23960
24091
  file_id: _zod.z.string().describe("Persistent file identifier from the host"),
@@ -24029,7 +24160,7 @@ ${filePathSection}
24029
24160
  let effectiveSourceType;
24030
24161
  let effectiveFileUrl = file.fileUrl;
24031
24162
  if (model.sourceType === "file") {
24032
- if (!_optionalChain([file, 'access', _75 => _75.file, 'optionalAccess', _76 => _76.download_url])) {
24163
+ if (!_optionalChain([file, 'access', _76 => _76.file, 'optionalAccess', _77 => _77.download_url])) {
24033
24164
  return {
24034
24165
  success: false,
24035
24166
  name: file.name,
@@ -24049,16 +24180,16 @@ ${filePathSection}
24049
24180
  error: "fileUrl is required when sourceType is 'url'."
24050
24181
  };
24051
24182
  }
24052
- const { name: actualName2, id: mediaId2 } = await streamingUploadFromUrl({
24183
+ const upload2 = await streamingUploadFromUrl({
24053
24184
  sourceUrl: effectiveFileUrl,
24054
24185
  name: file.name,
24055
24186
  mediaTypeName,
24056
24187
  parentId: model.parentId
24057
24188
  });
24058
- return { success: true, name: actualName2, id: mediaId2 };
24189
+ return toSuccessResult(upload2);
24059
24190
  }
24060
24191
  const temporaryFileId = _uuid.v4.call(void 0, );
24061
- const { name: actualName, id: mediaId } = await uploadMediaFile(client, {
24192
+ const upload = await uploadMediaFile(client, {
24062
24193
  sourceType: effectiveSourceType,
24063
24194
  name: file.name,
24064
24195
  mediaTypeName,
@@ -24068,7 +24199,7 @@ ${filePathSection}
24068
24199
  parentId: model.parentId,
24069
24200
  temporaryFileId
24070
24201
  });
24071
- return { success: true, name: actualName, id: mediaId };
24202
+ return toSuccessResult(upload);
24072
24203
  } catch (error) {
24073
24204
  return { success: false, name: file.name, error: error.message };
24074
24205
  }
@@ -24095,6 +24226,7 @@ var create_media_multiple_default = createCreateMediaMultipleTool({ allowFilePat
24095
24226
 
24096
24227
 
24097
24228
 
24229
+
24098
24230
  var createMediaFolderSchema = _zod.z.object({
24099
24231
  name: _zod.z.string().describe("The name of the folder"),
24100
24232
  parentId: _zod.z.string().uuid().optional().describe("Parent folder ID. If not provided, the folder will be created at the root of the media library.")
@@ -24113,6 +24245,12 @@ var CreateMediaFolderTool = {
24113
24245
  handler: (async (model) => {
24114
24246
  try {
24115
24247
  const client = UmbracoManagementClient3.getClient();
24248
+ const folderMediaTypeId = await _mcpserversdk.resolveMediaTypeId.call(void 0, _mcpserversdk.MEDIA_TYPE_ALIASES.Folder);
24249
+ if (!folderMediaTypeId) {
24250
+ return _mcpserversdk.createToolResultError.call(void 0, {
24251
+ detail: `Error creating media folder: no media type with alias '${_mcpserversdk.MEDIA_TYPE_ALIASES.Folder}' was found on this Umbraco site.`
24252
+ });
24253
+ }
24116
24254
  const response = await client.postMedia({
24117
24255
  values: [],
24118
24256
  variants: [
@@ -24123,12 +24261,12 @@ var CreateMediaFolderTool = {
24123
24261
  }
24124
24262
  ],
24125
24263
  parent: model.parentId ? { id: model.parentId } : null,
24126
- mediaType: { id: _mcpserversdk.FOLDER_MEDIA_TYPE_ID }
24264
+ mediaType: { id: folderMediaTypeId }
24127
24265
  }, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE);
24128
24266
  if (response.status < 200 || response.status >= 300) {
24129
24267
  throw new Error(`Request failed with status code ${response.status}`);
24130
24268
  }
24131
- const locationHeader = _optionalChain([response, 'access', _77 => _77.headers, 'optionalAccess', _78 => _78.location]) || _optionalChain([response, 'access', _79 => _79.headers, 'optionalAccess', _80 => _80.Location]);
24269
+ const locationHeader = _optionalChain([response, 'access', _78 => _78.headers, 'optionalAccess', _79 => _79.location]) || _optionalChain([response, 'access', _80 => _80.headers, 'optionalAccess', _81 => _81.Location]);
24132
24270
  if (!locationHeader) {
24133
24271
  throw new Error("No Location header in response - cannot determine created folder ID");
24134
24272
  }
@@ -25414,7 +25552,7 @@ var CreateMediaTypeFolderTool = {
25414
25552
  validateStatus: () => true
25415
25553
  });
25416
25554
  if (response.status === 201) {
25417
- const locationHeader = _optionalChain([response, 'access', _81 => _81.headers, 'optionalAccess', _82 => _82["location"]]) || _optionalChain([response, 'access', _83 => _83.headers, 'optionalAccess', _84 => _84["Location"]]);
25555
+ const locationHeader = _optionalChain([response, 'access', _82 => _82.headers, 'optionalAccess', _83 => _83["location"]]) || _optionalChain([response, 'access', _84 => _84.headers, 'optionalAccess', _85 => _85["Location"]]);
25418
25556
  let createdId = model.id || "";
25419
25557
  if (locationHeader) {
25420
25558
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -25549,7 +25687,7 @@ var CreateMediaTypeTool = {
25549
25687
  validateStatus: () => true
25550
25688
  });
25551
25689
  if (response.status === 201) {
25552
- const locationHeader = _optionalChain([response, 'access', _85 => _85.headers, 'optionalAccess', _86 => _86["location"]]) || _optionalChain([response, 'access', _87 => _87.headers, 'optionalAccess', _88 => _88["Location"]]);
25690
+ const locationHeader = _optionalChain([response, 'access', _86 => _86.headers, 'optionalAccess', _87 => _87["location"]]) || _optionalChain([response, 'access', _88 => _88.headers, 'optionalAccess', _89 => _89["Location"]]);
25553
25691
  let createdId = model.id || "";
25554
25692
  if (locationHeader) {
25555
25693
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -25600,7 +25738,7 @@ var CopyMediaTypeTool = {
25600
25738
  validateStatus: () => true
25601
25739
  });
25602
25740
  if (response.status === 201) {
25603
- const locationHeader = _optionalChain([response, 'access', _89 => _89.headers, 'optionalAccess', _90 => _90["location"]]) || _optionalChain([response, 'access', _91 => _91.headers, 'optionalAccess', _92 => _92["Location"]]);
25741
+ const locationHeader = _optionalChain([response, 'access', _90 => _90.headers, 'optionalAccess', _91 => _91["location"]]) || _optionalChain([response, 'access', _92 => _92.headers, 'optionalAccess', _93 => _93["Location"]]);
25604
25742
  let createdId = "";
25605
25743
  if (locationHeader) {
25606
25744
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -25810,7 +25948,7 @@ var CreateMemberTool = {
25810
25948
  validateStatus: () => true
25811
25949
  });
25812
25950
  if (response.status === 201) {
25813
- const locationHeader = _optionalChain([response, 'access', _93 => _93.headers, 'optionalAccess', _94 => _94["location"]]) || _optionalChain([response, 'access', _95 => _95.headers, 'optionalAccess', _96 => _96["Location"]]);
25951
+ const locationHeader = _optionalChain([response, 'access', _94 => _94.headers, 'optionalAccess', _95 => _95["location"]]) || _optionalChain([response, 'access', _96 => _96.headers, 'optionalAccess', _97 => _97["Location"]]);
25814
25952
  let createdId = model.id || "";
25815
25953
  if (locationHeader) {
25816
25954
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -26359,7 +26497,7 @@ var CreateMemberTypeTool = {
26359
26497
  validateStatus: () => true
26360
26498
  });
26361
26499
  if (response.status === 201) {
26362
- const locationHeader = _optionalChain([response, 'access', _97 => _97.headers, 'optionalAccess', _98 => _98["location"]]) || _optionalChain([response, 'access', _99 => _99.headers, 'optionalAccess', _100 => _100["Location"]]);
26500
+ const locationHeader = _optionalChain([response, 'access', _98 => _98.headers, 'optionalAccess', _99 => _99["location"]]) || _optionalChain([response, 'access', _100 => _100.headers, 'optionalAccess', _101 => _101["Location"]]);
26363
26501
  let createdId = model.id || "";
26364
26502
  if (locationHeader) {
26365
26503
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -26529,7 +26667,7 @@ var CopyMemberTypeTool = {
26529
26667
  validateStatus: () => true
26530
26668
  });
26531
26669
  if (response.status === 201) {
26532
- const locationHeader = _optionalChain([response, 'access', _101 => _101.headers, 'optionalAccess', _102 => _102["location"]]) || _optionalChain([response, 'access', _103 => _103.headers, 'optionalAccess', _104 => _104["Location"]]);
26670
+ const locationHeader = _optionalChain([response, 'access', _102 => _102.headers, 'optionalAccess', _103 => _103["location"]]) || _optionalChain([response, 'access', _104 => _104.headers, 'optionalAccess', _105 => _105["Location"]]);
26533
26671
  let createdId = "";
26534
26672
  if (locationHeader) {
26535
26673
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -26889,7 +27027,7 @@ var CreatePartialViewTool = {
26889
27027
  validateStatus: () => true
26890
27028
  });
26891
27029
  if (response.status === 201) {
26892
- const locationHeader = _optionalChain([response, 'access', _105 => _105.headers, 'optionalAccess', _106 => _106["location"]]) || _optionalChain([response, 'access', _107 => _107.headers, 'optionalAccess', _108 => _108["Location"]]);
27030
+ const locationHeader = _optionalChain([response, 'access', _106 => _106.headers, 'optionalAccess', _107 => _107["location"]]) || _optionalChain([response, 'access', _108 => _108.headers, 'optionalAccess', _109 => _109["Location"]]);
26893
27031
  let createdPath = "";
26894
27032
  if (locationHeader) {
26895
27033
  const pathMatch = locationHeader.match(/partial-view\/(.+)$/);
@@ -26936,7 +27074,7 @@ var CreatePartialViewFolderTool = {
26936
27074
  validateStatus: () => true
26937
27075
  });
26938
27076
  if (response.status === 201) {
26939
- const locationHeader = _optionalChain([response, 'access', _109 => _109.headers, 'optionalAccess', _110 => _110["location"]]) || _optionalChain([response, 'access', _111 => _111.headers, 'optionalAccess', _112 => _112["Location"]]);
27077
+ const locationHeader = _optionalChain([response, 'access', _110 => _110.headers, 'optionalAccess', _111 => _111["location"]]) || _optionalChain([response, 'access', _112 => _112.headers, 'optionalAccess', _113 => _113["Location"]]);
26940
27078
  let createdPath = "";
26941
27079
  if (locationHeader) {
26942
27080
  const pathMatch = locationHeader.match(/partial-view\/folder\/(.+)$/);
@@ -27739,7 +27877,7 @@ var CreateScriptTool = {
27739
27877
  validateStatus: () => true
27740
27878
  });
27741
27879
  if (response.status === 201) {
27742
- const locationHeader = _optionalChain([response, 'access', _113 => _113.headers, 'optionalAccess', _114 => _114["location"]]) || _optionalChain([response, 'access', _115 => _115.headers, 'optionalAccess', _116 => _116["Location"]]);
27880
+ const locationHeader = _optionalChain([response, 'access', _114 => _114.headers, 'optionalAccess', _115 => _115["location"]]) || _optionalChain([response, 'access', _116 => _116.headers, 'optionalAccess', _117 => _117["Location"]]);
27743
27881
  let createdPath = "";
27744
27882
  if (locationHeader) {
27745
27883
  const pathMatch = locationHeader.match(/script\/(.+)$/);
@@ -27786,7 +27924,7 @@ var CreateScriptFolderTool = {
27786
27924
  validateStatus: () => true
27787
27925
  });
27788
27926
  if (response.status === 201) {
27789
- const locationHeader = _optionalChain([response, 'access', _117 => _117.headers, 'optionalAccess', _118 => _118["location"]]) || _optionalChain([response, 'access', _119 => _119.headers, 'optionalAccess', _120 => _120["Location"]]);
27927
+ const locationHeader = _optionalChain([response, 'access', _118 => _118.headers, 'optionalAccess', _119 => _119["location"]]) || _optionalChain([response, 'access', _120 => _120.headers, 'optionalAccess', _121 => _121["Location"]]);
27790
27928
  let createdPath = "";
27791
27929
  if (locationHeader) {
27792
27930
  const pathMatch = locationHeader.match(/script\/folder\/(.+)$/);
@@ -28383,7 +28521,7 @@ var CreateStylesheetTool = {
28383
28521
  validateStatus: () => true
28384
28522
  });
28385
28523
  if (response.status === 201) {
28386
- const locationHeader = _optionalChain([response, 'access', _121 => _121.headers, 'optionalAccess', _122 => _122["location"]]) || _optionalChain([response, 'access', _123 => _123.headers, 'optionalAccess', _124 => _124["Location"]]);
28524
+ const locationHeader = _optionalChain([response, 'access', _122 => _122.headers, 'optionalAccess', _123 => _123["location"]]) || _optionalChain([response, 'access', _124 => _124.headers, 'optionalAccess', _125 => _125["Location"]]);
28387
28525
  let createdPath = "";
28388
28526
  if (locationHeader) {
28389
28527
  const pathMatch = locationHeader.match(/stylesheet\/(.+)$/);
@@ -28430,7 +28568,7 @@ var CreateStylesheetFolderTool = {
28430
28568
  validateStatus: () => true
28431
28569
  });
28432
28570
  if (response.status === 201) {
28433
- const locationHeader = _optionalChain([response, 'access', _125 => _125.headers, 'optionalAccess', _126 => _126["location"]]) || _optionalChain([response, 'access', _127 => _127.headers, 'optionalAccess', _128 => _128["Location"]]);
28571
+ const locationHeader = _optionalChain([response, 'access', _126 => _126.headers, 'optionalAccess', _127 => _127["location"]]) || _optionalChain([response, 'access', _128 => _128.headers, 'optionalAccess', _129 => _129["Location"]]);
28434
28572
  let createdPath = "";
28435
28573
  if (locationHeader) {
28436
28574
  const pathMatch = locationHeader.match(/stylesheet\/folder\/(.+)$/);
@@ -28794,7 +28932,7 @@ var CreateTemplateTool = {
28794
28932
  validateStatus: () => true
28795
28933
  });
28796
28934
  if (response.status === 201) {
28797
- const locationHeader = _optionalChain([response, 'access', _129 => _129.headers, 'optionalAccess', _130 => _130["location"]]) || _optionalChain([response, 'access', _131 => _131.headers, 'optionalAccess', _132 => _132["Location"]]);
28935
+ const locationHeader = _optionalChain([response, 'access', _130 => _130.headers, 'optionalAccess', _131 => _131["location"]]) || _optionalChain([response, 'access', _132 => _132.headers, 'optionalAccess', _133 => _133["Location"]]);
28798
28936
  let createdId = "";
28799
28937
  if (locationHeader) {
28800
28938
  const idMatch = locationHeader.match(/template\/([a-f0-9-]+)$/i);
@@ -29722,7 +29860,7 @@ var CreateUserDataTool = {
29722
29860
  validateStatus: () => true
29723
29861
  });
29724
29862
  if (response.status === 201) {
29725
- const locationHeader = _optionalChain([response, 'access', _133 => _133.headers, 'optionalAccess', _134 => _134["location"]]) || _optionalChain([response, 'access', _135 => _135.headers, 'optionalAccess', _136 => _136["Location"]]);
29863
+ const locationHeader = _optionalChain([response, 'access', _134 => _134.headers, 'optionalAccess', _135 => _135["location"]]) || _optionalChain([response, 'access', _136 => _136.headers, 'optionalAccess', _137 => _137["Location"]]);
29726
29864
  let createdId = "";
29727
29865
  if (locationHeader) {
29728
29866
  const idMatch = locationHeader.match(/user-data\/([a-f0-9-]+)$/i);
@@ -29960,7 +30098,7 @@ var CreateUserGroupTool = {
29960
30098
  validateStatus: () => true
29961
30099
  });
29962
30100
  if (response.status === 201) {
29963
- const locationHeader = _optionalChain([response, 'access', _137 => _137.headers, 'optionalAccess', _138 => _138["location"]]) || _optionalChain([response, 'access', _139 => _139.headers, 'optionalAccess', _140 => _140["Location"]]);
30101
+ const locationHeader = _optionalChain([response, 'access', _138 => _138.headers, 'optionalAccess', _139 => _139["location"]]) || _optionalChain([response, 'access', _140 => _140.headers, 'optionalAccess', _141 => _141["Location"]]);
29964
30102
  let createdId = "";
29965
30103
  if (locationHeader) {
29966
30104
  const idMatch = locationHeader.match(/user-group\/([a-f0-9-]+)$/i);
@@ -30258,7 +30396,7 @@ var CreateWebhookTool = {
30258
30396
  validateStatus: () => true
30259
30397
  });
30260
30398
  if (response.status === 201) {
30261
- const locationHeader = _optionalChain([response, 'access', _141 => _141.headers, 'optionalAccess', _142 => _142["location"]]) || _optionalChain([response, 'access', _143 => _143.headers, 'optionalAccess', _144 => _144["Location"]]);
30399
+ const locationHeader = _optionalChain([response, 'access', _142 => _142.headers, 'optionalAccess', _143 => _143["location"]]) || _optionalChain([response, 'access', _144 => _144.headers, 'optionalAccess', _145 => _145["Location"]]);
30262
30400
  let createdId = "";
30263
30401
  if (locationHeader) {
30264
30402
  const idMatch = locationHeader.match(/webhook\/([a-f0-9-]+)$/i);
@@ -30504,4 +30642,4 @@ var allSliceNames = [...toolSliceNames, "other"];
30504
30642
 
30505
30643
 
30506
30644
  exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.UmbracoManagementClient = UmbracoManagementClient3; exports.setAllowFilePathUploads = setAllowFilePathUploads; exports.setUmbracoVersion = setUmbracoVersion; exports.availableCollections = availableCollections; exports.allModes = allModes; exports.allModeNames = allModeNames; exports.allSliceNames = allSliceNames;
30507
- //# sourceMappingURL=chunk-UML5C3AZ.cjs.map
30645
+ //# sourceMappingURL=chunk-FYAOUFDE.cjs.map