@umbraco-cms/mcp-dev 17.4.0 → 17.4.1

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(); } } 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;
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;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -3002,28 +3002,28 @@ var getUmbracoManagementAPI = () => {
3002
3002
  options
3003
3003
  );
3004
3004
  };
3005
- const getPartialViewByPath = (path4, options) => {
3005
+ const getPartialViewByPath = (path3, options) => {
3006
3006
  return UmbracoManagementClient(
3007
3007
  {
3008
- url: `/umbraco/management/api/v1/partial-view/${path4}`,
3008
+ url: `/umbraco/management/api/v1/partial-view/${path3}`,
3009
3009
  method: "GET"
3010
3010
  },
3011
3011
  options
3012
3012
  );
3013
3013
  };
3014
- const deletePartialViewByPath = (path4, options) => {
3014
+ const deletePartialViewByPath = (path3, options) => {
3015
3015
  return UmbracoManagementClient(
3016
3016
  {
3017
- url: `/umbraco/management/api/v1/partial-view/${path4}`,
3017
+ url: `/umbraco/management/api/v1/partial-view/${path3}`,
3018
3018
  method: "DELETE"
3019
3019
  },
3020
3020
  options
3021
3021
  );
3022
3022
  };
3023
- const putPartialViewByPath = (path4, updatePartialViewRequestModel, options) => {
3023
+ const putPartialViewByPath = (path3, updatePartialViewRequestModel, options) => {
3024
3024
  return UmbracoManagementClient(
3025
3025
  {
3026
- url: `/umbraco/management/api/v1/partial-view/${path4}`,
3026
+ url: `/umbraco/management/api/v1/partial-view/${path3}`,
3027
3027
  method: "PUT",
3028
3028
  headers: { "Content-Type": "application/json" },
3029
3029
  data: updatePartialViewRequestModel
@@ -3031,10 +3031,10 @@ var getUmbracoManagementAPI = () => {
3031
3031
  options
3032
3032
  );
3033
3033
  };
3034
- const putPartialViewByPathRename = (path4, renamePartialViewRequestModel, options) => {
3034
+ const putPartialViewByPathRename = (path3, renamePartialViewRequestModel, options) => {
3035
3035
  return UmbracoManagementClient(
3036
3036
  {
3037
- url: `/umbraco/management/api/v1/partial-view/${path4}/rename`,
3037
+ url: `/umbraco/management/api/v1/partial-view/${path3}/rename`,
3038
3038
  method: "PUT",
3039
3039
  headers: { "Content-Type": "application/json" },
3040
3040
  data: renamePartialViewRequestModel
@@ -3053,19 +3053,19 @@ var getUmbracoManagementAPI = () => {
3053
3053
  options
3054
3054
  );
3055
3055
  };
3056
- const getPartialViewFolderByPath = (path4, options) => {
3056
+ const getPartialViewFolderByPath = (path3, options) => {
3057
3057
  return UmbracoManagementClient(
3058
3058
  {
3059
- url: `/umbraco/management/api/v1/partial-view/folder/${path4}`,
3059
+ url: `/umbraco/management/api/v1/partial-view/folder/${path3}`,
3060
3060
  method: "GET"
3061
3061
  },
3062
3062
  options
3063
3063
  );
3064
3064
  };
3065
- const deletePartialViewFolderByPath = (path4, options) => {
3065
+ const deletePartialViewFolderByPath = (path3, options) => {
3066
3066
  return UmbracoManagementClient(
3067
3067
  {
3068
- url: `/umbraco/management/api/v1/partial-view/folder/${path4}`,
3068
+ url: `/umbraco/management/api/v1/partial-view/folder/${path3}`,
3069
3069
  method: "DELETE"
3070
3070
  },
3071
3071
  options
@@ -3313,28 +3313,28 @@ var getUmbracoManagementAPI = () => {
3313
3313
  options
3314
3314
  );
3315
3315
  };
3316
- const getScriptByPath = (path4, options) => {
3316
+ const getScriptByPath = (path3, options) => {
3317
3317
  return UmbracoManagementClient(
3318
3318
  {
3319
- url: `/umbraco/management/api/v1/script/${path4}`,
3319
+ url: `/umbraco/management/api/v1/script/${path3}`,
3320
3320
  method: "GET"
3321
3321
  },
3322
3322
  options
3323
3323
  );
3324
3324
  };
3325
- const deleteScriptByPath = (path4, options) => {
3325
+ const deleteScriptByPath = (path3, options) => {
3326
3326
  return UmbracoManagementClient(
3327
3327
  {
3328
- url: `/umbraco/management/api/v1/script/${path4}`,
3328
+ url: `/umbraco/management/api/v1/script/${path3}`,
3329
3329
  method: "DELETE"
3330
3330
  },
3331
3331
  options
3332
3332
  );
3333
3333
  };
3334
- const putScriptByPath = (path4, updateScriptRequestModel, options) => {
3334
+ const putScriptByPath = (path3, updateScriptRequestModel, options) => {
3335
3335
  return UmbracoManagementClient(
3336
3336
  {
3337
- url: `/umbraco/management/api/v1/script/${path4}`,
3337
+ url: `/umbraco/management/api/v1/script/${path3}`,
3338
3338
  method: "PUT",
3339
3339
  headers: { "Content-Type": "application/json" },
3340
3340
  data: updateScriptRequestModel
@@ -3342,10 +3342,10 @@ var getUmbracoManagementAPI = () => {
3342
3342
  options
3343
3343
  );
3344
3344
  };
3345
- const putScriptByPathRename = (path4, renameScriptRequestModel, options) => {
3345
+ const putScriptByPathRename = (path3, renameScriptRequestModel, options) => {
3346
3346
  return UmbracoManagementClient(
3347
3347
  {
3348
- url: `/umbraco/management/api/v1/script/${path4}/rename`,
3348
+ url: `/umbraco/management/api/v1/script/${path3}/rename`,
3349
3349
  method: "PUT",
3350
3350
  headers: { "Content-Type": "application/json" },
3351
3351
  data: renameScriptRequestModel
@@ -3364,19 +3364,19 @@ var getUmbracoManagementAPI = () => {
3364
3364
  options
3365
3365
  );
3366
3366
  };
3367
- const getScriptFolderByPath = (path4, options) => {
3367
+ const getScriptFolderByPath = (path3, options) => {
3368
3368
  return UmbracoManagementClient(
3369
3369
  {
3370
- url: `/umbraco/management/api/v1/script/folder/${path4}`,
3370
+ url: `/umbraco/management/api/v1/script/folder/${path3}`,
3371
3371
  method: "GET"
3372
3372
  },
3373
3373
  options
3374
3374
  );
3375
3375
  };
3376
- const deleteScriptFolderByPath = (path4, options) => {
3376
+ const deleteScriptFolderByPath = (path3, options) => {
3377
3377
  return UmbracoManagementClient(
3378
3378
  {
3379
- url: `/umbraco/management/api/v1/script/folder/${path4}`,
3379
+ url: `/umbraco/management/api/v1/script/folder/${path3}`,
3380
3380
  method: "DELETE"
3381
3381
  },
3382
3382
  options
@@ -3600,28 +3600,28 @@ var getUmbracoManagementAPI = () => {
3600
3600
  options
3601
3601
  );
3602
3602
  };
3603
- const getStylesheetByPath = (path4, options) => {
3603
+ const getStylesheetByPath = (path3, options) => {
3604
3604
  return UmbracoManagementClient(
3605
3605
  {
3606
- url: `/umbraco/management/api/v1/stylesheet/${path4}`,
3606
+ url: `/umbraco/management/api/v1/stylesheet/${path3}`,
3607
3607
  method: "GET"
3608
3608
  },
3609
3609
  options
3610
3610
  );
3611
3611
  };
3612
- const deleteStylesheetByPath = (path4, options) => {
3612
+ const deleteStylesheetByPath = (path3, options) => {
3613
3613
  return UmbracoManagementClient(
3614
3614
  {
3615
- url: `/umbraco/management/api/v1/stylesheet/${path4}`,
3615
+ url: `/umbraco/management/api/v1/stylesheet/${path3}`,
3616
3616
  method: "DELETE"
3617
3617
  },
3618
3618
  options
3619
3619
  );
3620
3620
  };
3621
- const putStylesheetByPath = (path4, updateStylesheetRequestModel, options) => {
3621
+ const putStylesheetByPath = (path3, updateStylesheetRequestModel, options) => {
3622
3622
  return UmbracoManagementClient(
3623
3623
  {
3624
- url: `/umbraco/management/api/v1/stylesheet/${path4}`,
3624
+ url: `/umbraco/management/api/v1/stylesheet/${path3}`,
3625
3625
  method: "PUT",
3626
3626
  headers: { "Content-Type": "application/json" },
3627
3627
  data: updateStylesheetRequestModel
@@ -3629,10 +3629,10 @@ var getUmbracoManagementAPI = () => {
3629
3629
  options
3630
3630
  );
3631
3631
  };
3632
- const putStylesheetByPathRename = (path4, renameStylesheetRequestModel, options) => {
3632
+ const putStylesheetByPathRename = (path3, renameStylesheetRequestModel, options) => {
3633
3633
  return UmbracoManagementClient(
3634
3634
  {
3635
- url: `/umbraco/management/api/v1/stylesheet/${path4}/rename`,
3635
+ url: `/umbraco/management/api/v1/stylesheet/${path3}/rename`,
3636
3636
  method: "PUT",
3637
3637
  headers: { "Content-Type": "application/json" },
3638
3638
  data: renameStylesheetRequestModel
@@ -3651,19 +3651,19 @@ var getUmbracoManagementAPI = () => {
3651
3651
  options
3652
3652
  );
3653
3653
  };
3654
- const getStylesheetFolderByPath = (path4, options) => {
3654
+ const getStylesheetFolderByPath = (path3, options) => {
3655
3655
  return UmbracoManagementClient(
3656
3656
  {
3657
- url: `/umbraco/management/api/v1/stylesheet/folder/${path4}`,
3657
+ url: `/umbraco/management/api/v1/stylesheet/folder/${path3}`,
3658
3658
  method: "GET"
3659
3659
  },
3660
3660
  options
3661
3661
  );
3662
3662
  };
3663
- const deleteStylesheetFolderByPath = (path4, options) => {
3663
+ const deleteStylesheetFolderByPath = (path3, options) => {
3664
3664
  return UmbracoManagementClient(
3665
3665
  {
3666
- url: `/umbraco/management/api/v1/stylesheet/folder/${path4}`,
3666
+ url: `/umbraco/management/api/v1/stylesheet/folder/${path3}`,
3667
3667
  method: "DELETE"
3668
3668
  },
3669
3669
  options
@@ -4546,21 +4546,47 @@ var getUmbracoManagementAPI = () => {
4546
4546
 
4547
4547
  // src/umb-management-api/api/temporary-file/index.ts
4548
4548
 
4549
- var _formdata = require('form-data'); var _formdata2 = _interopRequireDefault(_formdata);
4549
+ async function readStreamToBuffer(stream) {
4550
+ const chunks = [];
4551
+ for await (const chunk of stream) {
4552
+ chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
4553
+ }
4554
+ return Buffer.concat(chunks);
4555
+ }
4550
4556
  var getTemporaryFileAPI = () => ({
4551
- postTemporaryFile: (postTemporaryFileBody2, options) => {
4552
- const formData = new (0, _formdata2.default)();
4557
+ postTemporaryFile: async (postTemporaryFileBody2, options) => {
4558
+ const formData = new FormData();
4553
4559
  formData.append("Id", postTemporaryFileBody2.Id);
4554
- formData.append("File", postTemporaryFileBody2.File);
4555
- const headers = {
4556
- ...formData.getHeaders(),
4557
- ..._optionalChain([options, 'optionalAccess', _ => _.headers])
4558
- };
4560
+ const file = postTemporaryFileBody2.File;
4561
+ console.log("[temp-file] incoming file:", {
4562
+ typeofFile: typeof file,
4563
+ isBuffer: Buffer.isBuffer(file),
4564
+ ctorName: _optionalChain([file, 'optionalAccess', _ => _.constructor, 'optionalAccess', _2 => _2.name]),
4565
+ hasByteLength: typeof _optionalChain([file, 'optionalAccess', _3 => _3.byteLength]),
4566
+ hasLength: typeof _optionalChain([file, 'optionalAccess', _4 => _4.length]),
4567
+ keys: file ? Object.keys(file).slice(0, 10) : []
4568
+ });
4569
+ const buffer = Buffer.isBuffer(file) ? file : await readStreamToBuffer(file);
4570
+ console.log("[temp-file] buffer:", { length: buffer.byteLength });
4571
+ const bytes = new Uint8Array(buffer.byteLength);
4572
+ bytes.set(buffer);
4573
+ const blob = new Blob([bytes]);
4574
+ console.log("[temp-file] blob:", { size: blob.size, type: blob.type, fileName: postTemporaryFileBody2.FileName });
4575
+ formData.append("File", blob, postTemporaryFileBody2.FileName);
4576
+ const entries = [];
4577
+ for (const [k, v] of formData.entries()) {
4578
+ entries.push({
4579
+ name: k,
4580
+ valueKind: typeof v === "string" ? "string" : _nullishCoalesce(_optionalChain([v, 'optionalAccess', _5 => _5.constructor, 'optionalAccess', _6 => _6.name]), () => ( typeof v)),
4581
+ valueSize: typeof v === "string" ? v.length : _nullishCoalesce(_optionalChain([v, 'optionalAccess', _7 => _7.size]), () => ( void 0))
4582
+ });
4583
+ }
4584
+ console.log("[temp-file] formData entries:", entries);
4559
4585
  return _mcpserversdk.UmbracoManagementClient.call(void 0,
4560
4586
  {
4561
4587
  url: `/umbraco/management/api/v1/temporary-file`,
4562
4588
  method: "POST",
4563
- headers,
4589
+ headers: _optionalChain([options, 'optionalAccess', _8 => _8.headers]),
4564
4590
  data: formData
4565
4591
  },
4566
4592
  options
@@ -4610,6 +4636,13 @@ var UmbracoManagementClient3 = (_class = class {
4610
4636
 
4611
4637
  // src/umb-management-api/runtime-context.ts
4612
4638
  var umbracoVersion = null;
4639
+ var allowFilePathUploads = false;
4640
+ function setAllowFilePathUploads(allow) {
4641
+ allowFilePathUploads = allow;
4642
+ }
4643
+ function isFilePathUploadAllowed() {
4644
+ return allowFilePathUploads;
4645
+ }
4613
4646
  function setUmbracoVersion(version) {
4614
4647
  umbracoVersion = _nullishCoalesce(version, () => ( null));
4615
4648
  }
@@ -12518,7 +12551,7 @@ async function synthesizeDataTypeSchema(id) {
12518
12551
  const client = UmbracoManagementClient3.getClient();
12519
12552
  const dataType = await client.getDataTypeById(id);
12520
12553
  const template = findTemplateByEditorAlias(dataType.editorAlias);
12521
- const valueTypeName = _nullishCoalesce(VALUE_TYPE_BY_EDITOR_ALIAS[dataType.editorAlias], () => ( (_optionalChain([template, 'optionalAccess', _2 => _2.value]) !== void 0 ? "JSON" : null)));
12554
+ const valueTypeName = _nullishCoalesce(VALUE_TYPE_BY_EDITOR_ALIAS[dataType.editorAlias], () => ( (_optionalChain([template, 'optionalAccess', _9 => _9.value]) !== void 0 ? "JSON" : null)));
12522
12555
  const jsonSchema = {
12523
12556
  $schema: "https://json-schema.org/draft/2020-12/schema",
12524
12557
  title: dataType.name,
@@ -12526,8 +12559,8 @@ async function synthesizeDataTypeSchema(id) {
12526
12559
  dataTypeId: dataType.id,
12527
12560
  editorAlias: dataType.editorAlias,
12528
12561
  editorUiAlias: dataType.editorUiAlias,
12529
- example: _optionalChain([template, 'optionalAccess', _3 => _3.value]),
12530
- notes: _optionalChain([template, 'optionalAccess', _4 => _4._notes])
12562
+ example: _optionalChain([template, 'optionalAccess', _10 => _10.value]),
12563
+ notes: _optionalChain([template, 'optionalAccess', _11 => _11._notes])
12531
12564
  };
12532
12565
  return { valueTypeName, jsonSchema };
12533
12566
  }
@@ -12648,7 +12681,7 @@ var CopyDataTypeTool = {
12648
12681
  validateStatus: () => true
12649
12682
  });
12650
12683
  if (response.status === 201) {
12651
- const location = _optionalChain([response, 'access', _5 => _5.headers, 'optionalAccess', _6 => _6.location]) || "";
12684
+ const location = _optionalChain([response, 'access', _12 => _12.headers, 'optionalAccess', _13 => _13.location]) || "";
12652
12685
  const newId = location.split("/").pop() || "";
12653
12686
  const output = {
12654
12687
  message: "Data type copied successfully",
@@ -13289,7 +13322,7 @@ var CreateDictionaryItemTool = {
13289
13322
  validateStatus: () => true
13290
13323
  });
13291
13324
  if (response.status === 201) {
13292
- const locationHeader = _optionalChain([response, 'access', _7 => _7.headers, 'optionalAccess', _8 => _8["location"]]) || _optionalChain([response, 'access', _9 => _9.headers, 'optionalAccess', _10 => _10["Location"]]);
13325
+ const locationHeader = _optionalChain([response, 'access', _14 => _14.headers, 'optionalAccess', _15 => _15["location"]]) || _optionalChain([response, 'access', _16 => _16.headers, 'optionalAccess', _17 => _17["Location"]]);
13293
13326
  let createdId = model.id || "";
13294
13327
  if (locationHeader) {
13295
13328
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -14246,8 +14279,8 @@ function buildPropertyEntry(prop, dataType, template) {
14246
14279
  editorAlias: dataType.editorAlias,
14247
14280
  dataTypeId: dataType.id,
14248
14281
  dataTypeName: dataType.name,
14249
- example: _optionalChain([template, 'optionalAccess', _11 => _11.value]),
14250
- notes: _optionalChain([template, 'optionalAccess', _12 => _12._notes])
14282
+ example: _optionalChain([template, 'optionalAccess', _18 => _18.value]),
14283
+ notes: _optionalChain([template, 'optionalAccess', _19 => _19._notes])
14251
14284
  };
14252
14285
  }
14253
14286
  async function synthesizeDocumentTypeSchema(id) {
@@ -14649,7 +14682,7 @@ var CopyDocumentTool = {
14649
14682
  validateStatus: () => true
14650
14683
  });
14651
14684
  if (response.status === 201) {
14652
- const location = _optionalChain([response, 'access', _13 => _13.headers, 'optionalAccess', _14 => _14.location]) || "";
14685
+ const location = _optionalChain([response, 'access', _20 => _20.headers, 'optionalAccess', _21 => _21.location]) || "";
14653
14686
  const newId = location.split("/").pop() || "";
14654
14687
  const output = { id: newId };
14655
14688
  return _mcpserversdk.createToolResult.call(void 0, output);
@@ -14793,7 +14826,7 @@ var CreateDocumentTool = {
14793
14826
  template = { id: model.templateId };
14794
14827
  } else {
14795
14828
  const docType = await client.getDocumentTypeById(model.documentTypeId);
14796
- template = _optionalChain([docType, 'access', _15 => _15.defaultTemplate, 'optionalAccess', _16 => _16.id]) ? { id: docType.defaultTemplate.id } : null;
14829
+ template = _optionalChain([docType, 'access', _22 => _22.defaultTemplate, 'optionalAccess', _23 => _23.id]) ? { id: docType.defaultTemplate.id } : null;
14797
14830
  }
14798
14831
  const payload = {
14799
14832
  id: documentId,
@@ -15572,7 +15605,7 @@ var UpdateDocumentPropertiesTool = {
15572
15605
  const docTypeProps = await getDocumentTypeProperties();
15573
15606
  const propsToValidate = allPropertiesToValidate.map((p) => {
15574
15607
  const def = docTypeProps.find((d) => d.alias === p.alias);
15575
- return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _17 => _17.dataTypeId]), () => ( "")) };
15608
+ return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _24 => _24.dataTypeId]), () => ( "")) };
15576
15609
  }).filter((p) => p.dataTypeId);
15577
15610
  if (propsToValidate.length > 0) {
15578
15611
  const valueValidation = await validatePropertiesBeforeSave(propsToValidate);
@@ -15675,13 +15708,13 @@ function isBlockStructure(value) {
15675
15708
  }
15676
15709
  return Array.isArray(value.contentData) && Array.isArray(value.settingsData);
15677
15710
  }
15678
- function discoverAllBlockArrays(value, path4 = "root") {
15711
+ function discoverAllBlockArrays(value, path3 = "root") {
15679
15712
  const results = [];
15680
15713
  if (!value || typeof value !== "object") {
15681
15714
  return results;
15682
15715
  }
15683
15716
  if (isRichTextValue(value)) {
15684
- const nestedResults = discoverAllBlockArrays(value.blocks, `${path4}.blocks`);
15717
+ const nestedResults = discoverAllBlockArrays(value.blocks, `${path3}.blocks`);
15685
15718
  results.push(...nestedResults);
15686
15719
  return results;
15687
15720
  }
@@ -15689,12 +15722,12 @@ function discoverAllBlockArrays(value, path4 = "root") {
15689
15722
  results.push({
15690
15723
  contentData: value.contentData,
15691
15724
  settingsData: value.settingsData,
15692
- path: path4
15725
+ path: path3
15693
15726
  });
15694
15727
  value.contentData.forEach((block, index) => {
15695
15728
  if (block.values && Array.isArray(block.values)) {
15696
15729
  block.values.forEach((prop, propIndex) => {
15697
- const propPath = `${path4}.contentData[${index}].values[${propIndex}](${prop.alias})`;
15730
+ const propPath = `${path3}.contentData[${index}].values[${propIndex}](${prop.alias})`;
15698
15731
  if (isRichTextValue(prop.value)) {
15699
15732
  const nestedResults = discoverAllBlockArrays(prop.value.blocks, `${propPath}.blocks`);
15700
15733
  results.push(...nestedResults);
@@ -15708,7 +15741,7 @@ function discoverAllBlockArrays(value, path4 = "root") {
15708
15741
  value.settingsData.forEach((block, index) => {
15709
15742
  if (block.values && Array.isArray(block.values)) {
15710
15743
  block.values.forEach((prop, propIndex) => {
15711
- const propPath = `${path4}.settingsData[${index}].values[${propIndex}](${prop.alias})`;
15744
+ const propPath = `${path3}.settingsData[${index}].values[${propIndex}](${prop.alias})`;
15712
15745
  if (isRichTextValue(prop.value)) {
15713
15746
  const nestedResults = discoverAllBlockArrays(prop.value.blocks, `${propPath}.blocks`);
15714
15747
  results.push(...nestedResults);
@@ -15865,7 +15898,7 @@ var UpdateBlockPropertyTool = {
15865
15898
  if (!isUmbracoAtLeast(17, 4) && elementTypeProperties.length > 0) {
15866
15899
  const propsToValidate = update.properties.map((p) => {
15867
15900
  const def = elementTypeProperties.find((d) => d.alias === p.alias);
15868
- return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _18 => _18.dataTypeId]), () => ( "")) };
15901
+ return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _25 => _25.dataTypeId]), () => ( "")) };
15869
15902
  }).filter((p) => p.dataTypeId);
15870
15903
  if (propsToValidate.length > 0) {
15871
15904
  const valueValidation = await validatePropertiesBeforeSave(propsToValidate);
@@ -16525,7 +16558,7 @@ var CopyDocumentTypeTool = {
16525
16558
  validateStatus: () => true
16526
16559
  });
16527
16560
  if (response.status === 201) {
16528
- const location = _optionalChain([response, 'access', _19 => _19.headers, 'optionalAccess', _20 => _20.location]) || "";
16561
+ const location = _optionalChain([response, 'access', _26 => _26.headers, 'optionalAccess', _27 => _27.location]) || "";
16529
16562
  const newId = location.split("/").pop() || "";
16530
16563
  const output = { id: newId };
16531
16564
  return _mcpserversdk.createToolResult.call(void 0, output);
@@ -18658,17 +18691,15 @@ var ManifestCollection = {
18658
18691
 
18659
18692
 
18660
18693
  // src/umb-management-api/tools/media/post/helpers/media-upload-helpers.ts
18661
- var _fs = require('fs'); var fs2 = _interopRequireWildcard(_fs); var fs = _interopRequireWildcard(_fs); var fs3 = _interopRequireWildcard(_fs);
18662
- var _os = require('os'); var os = _interopRequireWildcard(_os); var os2 = _interopRequireWildcard(_os);
18663
- var _path = require('path'); var path2 = _interopRequireWildcard(_path); var path = _interopRequireWildcard(_path); var path3 = _interopRequireWildcard(_path);
18694
+ var _fs = require('fs'); var fs2 = _interopRequireWildcard(_fs); var fs = _interopRequireWildcard(_fs);
18695
+ var _path = require('path'); var path2 = _interopRequireWildcard(_path); var path = _interopRequireWildcard(_path);
18664
18696
  var _mimetypes = require('mime-types'); var _mimetypes2 = _interopRequireDefault(_mimetypes);
18665
18697
 
18666
18698
  // src/umb-management-api/tools/media/post/helpers/validate-file-path.ts
18667
18699
 
18668
18700
 
18669
-
18670
18701
  async function validateFilePath(filePath, allowedPaths) {
18671
- const allowedMediaPaths = await _asyncNullishCoalesce(allowedPaths, async () => ( (await _mcpserversdk.getServerConfig.call(void 0, true)).config.allowedMediaPaths));
18702
+ const allowedMediaPaths = _nullishCoalesce(allowedPaths, () => ( (process.env.UMBRACO_ALLOWED_MEDIA_PATHS ? process.env.UMBRACO_ALLOWED_MEDIA_PATHS.split(",").map((p) => p.trim()).filter(Boolean) : void 0)));
18672
18703
  if (!allowedMediaPaths || allowedMediaPaths.length === 0) {
18673
18704
  throw new Error(
18674
18705
  'File path uploads are disabled. To enable, set UMBRACO_ALLOWED_MEDIA_PATHS environment variable with comma-separated allowed directory paths (e.g., UMBRACO_ALLOWED_MEDIA_PATHS="/tmp/uploads,/var/media")'
@@ -18676,8 +18707,13 @@ async function validateFilePath(filePath, allowedPaths) {
18676
18707
  }
18677
18708
  const normalizedPath = path.resolve(filePath);
18678
18709
  const isAllowed = allowedMediaPaths.some((allowedPath) => {
18679
- const realAllowedPath = fs.realpathSync(allowedPath);
18680
- return normalizedPath.startsWith(allowedPath) || normalizedPath.startsWith(realAllowedPath);
18710
+ if (normalizedPath.startsWith(allowedPath)) return true;
18711
+ try {
18712
+ const realAllowedPath = fs.realpathSync(allowedPath);
18713
+ return normalizedPath.startsWith(realAllowedPath);
18714
+ } catch (e) {
18715
+ return false;
18716
+ }
18681
18717
  });
18682
18718
  if (!isAllowed) {
18683
18719
  throw new Error(
@@ -18689,8 +18725,13 @@ async function validateFilePath(filePath, allowedPaths) {
18689
18725
  if (stats.isSymbolicLink()) {
18690
18726
  const realPath = fs.realpathSync(normalizedPath);
18691
18727
  const symlinkAllowed = allowedMediaPaths.some((allowedPath) => {
18692
- const realAllowedPath = fs.realpathSync(allowedPath);
18693
- return realPath.startsWith(allowedPath) || realPath.startsWith(realAllowedPath);
18728
+ if (realPath.startsWith(allowedPath)) return true;
18729
+ try {
18730
+ const realAllowedPath = fs.realpathSync(allowedPath);
18731
+ return realPath.startsWith(realAllowedPath);
18732
+ } catch (e2) {
18733
+ return false;
18734
+ }
18694
18735
  });
18695
18736
  if (!symlinkAllowed) {
18696
18737
  throw new Error(
@@ -18722,7 +18763,7 @@ function getExtensionFromMimeType(mimeType) {
18722
18763
  return extension ? `.${extension}` : void 0;
18723
18764
  }
18724
18765
  function validateMediaTypeForSvg(filePath, fileUrl, fileName, mediaTypeName) {
18725
- const isSvg = _optionalChain([filePath, 'optionalAccess', _21 => _21.toLowerCase, 'call', _22 => _22(), 'access', _23 => _23.endsWith, 'call', _24 => _24(".svg")]) || _optionalChain([fileUrl, 'optionalAccess', _25 => _25.toLowerCase, 'call', _26 => _26(), 'access', _27 => _27.endsWith, 'call', _28 => _28(".svg")]) || fileName.toLowerCase().endsWith(".svg");
18766
+ const isSvg = _optionalChain([filePath, 'optionalAccess', _28 => _28.toLowerCase, 'call', _29 => _29(), 'access', _30 => _30.endsWith, 'call', _31 => _31(".svg")]) || _optionalChain([fileUrl, 'optionalAccess', _32 => _32.toLowerCase, 'call', _33 => _33(), 'access', _34 => _34.endsWith, 'call', _35 => _35(".svg")]) || fileName.toLowerCase().endsWith(".svg");
18726
18767
  if (isSvg && mediaTypeName === _mcpserversdk.MEDIA_TYPE_IMAGE) {
18727
18768
  console.warn(`SVG detected - using ${_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS} media type instead of ${_mcpserversdk.MEDIA_TYPE_IMAGE}`);
18728
18769
  return _mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS;
@@ -18777,18 +18818,25 @@ function buildValueStructure(mediaTypeName, temporaryFileId) {
18777
18818
  value: { temporaryFileId }
18778
18819
  };
18779
18820
  }
18780
- async function createFileStream(sourceType, filePath, fileUrl, fileAsBase64, fileName) {
18781
- let tempFilePath = null;
18782
- let readStream;
18821
+ async function createFilePayload(sourceType, filePath, fileUrl, fileAsBase64, fileName) {
18783
18822
  switch (sourceType) {
18784
- case "filePath":
18823
+ case "filePath": {
18785
18824
  if (!filePath) {
18786
18825
  throw new Error("filePath is required when sourceType is 'filePath'");
18787
18826
  }
18827
+ if (typeof fs2.createReadStream !== "function") {
18828
+ throw new Error(
18829
+ "filePath source is not supported in this runtime (no filesystem). Use sourceType 'url' or 'base64' instead."
18830
+ );
18831
+ }
18788
18832
  const validatedPath = await validateFilePath(filePath);
18789
- readStream = fs2.createReadStream(validatedPath);
18790
- break;
18791
- case "url":
18833
+ const filename = fileName.includes(".") ? fileName : path2.basename(validatedPath);
18834
+ return {
18835
+ data: fs2.createReadStream(validatedPath),
18836
+ filename
18837
+ };
18838
+ }
18839
+ case "url": {
18792
18840
  if (!fileUrl) {
18793
18841
  throw new Error("fileUrl is required when sourceType is 'url'");
18794
18842
  }
@@ -18804,123 +18852,110 @@ async function createFileStream(sourceType, filePath, fileUrl, fileAsBase64, fil
18804
18852
  if (response.status >= 400) {
18805
18853
  throw new Error(`Failed to fetch file from URL: HTTP ${response.status} ${response.statusText}`);
18806
18854
  }
18807
- const arrayBuffer = await response.arrayBuffer();
18808
- let fileNameWithExtension2 = fileName;
18855
+ const buffer = Buffer.from(await response.arrayBuffer());
18856
+ let filename = fileName;
18809
18857
  if (!fileName.includes(".")) {
18810
18858
  const urlPath = new URL(fileUrl).pathname;
18811
18859
  const urlExtension = path2.extname(urlPath);
18812
18860
  if (urlExtension) {
18813
- fileNameWithExtension2 = `${fileName}${urlExtension}`;
18861
+ filename = `${fileName}${urlExtension}`;
18814
18862
  } else {
18815
18863
  const contentType = _nullishCoalesce(response.headers.get("content-type"), () => ( void 0));
18816
18864
  const extensionFromMime = getExtensionFromMimeType(contentType);
18817
- if (extensionFromMime) {
18818
- fileNameWithExtension2 = `${fileName}${extensionFromMime}`;
18819
- } else {
18820
- fileNameWithExtension2 = `${fileName}.bin`;
18821
- }
18865
+ filename = extensionFromMime ? `${fileName}${extensionFromMime}` : `${fileName}.bin`;
18822
18866
  }
18823
18867
  }
18824
- tempFilePath = path2.join(os.tmpdir(), fileNameWithExtension2);
18825
- fs2.writeFileSync(tempFilePath, Buffer.from(arrayBuffer));
18826
- readStream = fs2.createReadStream(tempFilePath);
18868
+ return { data: buffer, filename };
18827
18869
  } catch (error) {
18828
18870
  if (error.name === "AbortError") {
18829
18871
  throw new Error(`Request timeout after 30s fetching URL: ${fileUrl}`);
18830
18872
  }
18831
18873
  throw new Error(`Failed to fetch URL: ${fileUrl} - ${error.message}`);
18832
18874
  }
18833
- break;
18834
- case "base64":
18875
+ }
18876
+ case "base64": {
18835
18877
  if (!fileAsBase64) {
18836
18878
  throw new Error("fileAsBase64 is required when sourceType is 'base64'");
18837
18879
  }
18838
- const fileContent = Buffer.from(fileAsBase64, "base64");
18839
- let fileNameWithExtension = fileName;
18880
+ const buffer = Buffer.from(fileAsBase64, "base64");
18881
+ let filename = fileName;
18840
18882
  if (!fileName.includes(".")) {
18841
- const extension = _mcpserversdk.detectFileExtensionFromBuffer.call(void 0, fileContent);
18842
- fileNameWithExtension = `${fileName}${extension}`;
18883
+ const extension = _mcpserversdk.detectFileExtensionFromBuffer.call(void 0, buffer);
18884
+ filename = `${fileName}${extension}`;
18843
18885
  }
18844
- tempFilePath = path2.join(os.tmpdir(), fileNameWithExtension);
18845
- fs2.writeFileSync(tempFilePath, fileContent);
18846
- readStream = fs2.createReadStream(tempFilePath);
18847
- break;
18848
- }
18849
- return { readStream, tempFilePath };
18850
- }
18851
- function cleanupTempFile(tempFilePath) {
18852
- if (tempFilePath && fs2.existsSync(tempFilePath)) {
18853
- try {
18854
- fs2.unlinkSync(tempFilePath);
18855
- } catch (e) {
18856
- console.error("Failed to cleanup temp file:", e);
18886
+ return { data: buffer, filename };
18857
18887
  }
18858
18888
  }
18859
18889
  }
18860
18890
  async function uploadMediaFile(client, params) {
18861
- let tempFilePath = null;
18891
+ const validatedMediaTypeName = validateMediaTypeForSvg(
18892
+ params.filePath,
18893
+ params.fileUrl,
18894
+ params.name,
18895
+ params.mediaTypeName
18896
+ );
18897
+ const mediaTypeId = await fetchMediaTypeId(client, validatedMediaTypeName);
18898
+ const { data, filename } = await createFilePayload(
18899
+ params.sourceType,
18900
+ params.filePath,
18901
+ params.fileUrl,
18902
+ params.fileAsBase64,
18903
+ params.name
18904
+ );
18862
18905
  try {
18863
- const validatedMediaTypeName = validateMediaTypeForSvg(
18864
- params.filePath,
18865
- params.fileUrl,
18866
- params.name,
18867
- params.mediaTypeName
18868
- );
18869
- const mediaTypeId = await fetchMediaTypeId(client, validatedMediaTypeName);
18870
- const { readStream, tempFilePath: createdTempPath } = await createFileStream(
18871
- params.sourceType,
18872
- params.filePath,
18873
- params.fileUrl,
18874
- params.fileAsBase64,
18875
- params.name
18876
- );
18877
- tempFilePath = createdTempPath;
18878
- try {
18879
- await client.postTemporaryFile({
18880
- Id: params.temporaryFileId,
18881
- File: readStream
18882
- });
18883
- } catch (error) {
18884
- const err = error;
18885
- const errorData = _optionalChain([err, 'access', _29 => _29.response, 'optionalAccess', _30 => _30.data]) ? typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data) : err.message;
18886
- throw new Error(`Failed to upload temporary file: ${_optionalChain([err, 'access', _31 => _31.response, 'optionalAccess', _32 => _32.status]) || "Unknown error"} - ${errorData}`);
18887
- }
18888
- const valueStructure = buildValueStructure(validatedMediaTypeName, params.temporaryFileId);
18889
- let response;
18890
- try {
18891
- response = await client.postMedia({
18892
- mediaType: { id: mediaTypeId },
18893
- variants: [
18894
- {
18895
- culture: null,
18896
- segment: null,
18897
- name: params.name
18898
- // Use original name provided by user
18899
- }
18900
- ],
18901
- values: [valueStructure],
18902
- parent: params.parentId ? { id: params.parentId } : null
18903
- }, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE);
18904
- } catch (error) {
18905
- const err = error;
18906
- throw new Error(`Failed to create media item: ${_optionalChain([err, 'access', _33 => _33.response, 'optionalAccess', _34 => _34.status]) || "Unknown error"} - ${JSON.stringify(_optionalChain([err, 'access', _35 => _35.response, 'optionalAccess', _36 => _36.data])) || err.message}`);
18907
- }
18908
- if (response.status < 200 || response.status >= 300) {
18909
- throw new Error(`Request failed with status code ${response.status}`);
18910
- }
18911
- const locationHeader = _optionalChain([response, 'access', _37 => _37.headers, 'optionalAccess', _38 => _38.location]) || _optionalChain([response, 'access', _39 => _39.headers, 'optionalAccess', _40 => _40.Location]);
18912
- if (!locationHeader) {
18913
- throw new Error("No Location header in response - cannot determine created media ID");
18914
- }
18915
- const idMatch = locationHeader.match(/\/([a-f0-9-]{36})$/i);
18916
- if (!idMatch) {
18917
- throw new Error(`Could not extract ID from Location header: ${locationHeader}`);
18918
- }
18919
- const mediaId = idMatch[1];
18920
- return { name: params.name, id: mediaId };
18921
- } finally {
18922
- cleanupTempFile(tempFilePath);
18906
+ await client.postTemporaryFile({
18907
+ Id: params.temporaryFileId,
18908
+ File: data,
18909
+ FileName: filename
18910
+ });
18911
+ } catch (error) {
18912
+ const err = error;
18913
+ const errorData = _optionalChain([err, 'access', _36 => _36.response, 'optionalAccess', _37 => _37.data]) ? typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data) : err.message;
18914
+ throw new Error(`Failed to upload temporary file: ${_optionalChain([err, 'access', _38 => _38.response, 'optionalAccess', _39 => _39.status]) || "Unknown error"} - ${errorData}`);
18915
+ }
18916
+ const valueStructure = buildValueStructure(validatedMediaTypeName, params.temporaryFileId);
18917
+ let response;
18918
+ try {
18919
+ response = await client.postMedia({
18920
+ mediaType: { id: mediaTypeId },
18921
+ variants: [
18922
+ {
18923
+ culture: null,
18924
+ segment: null,
18925
+ name: params.name
18926
+ // Use original name provided by user
18927
+ }
18928
+ ],
18929
+ values: [valueStructure],
18930
+ parent: params.parentId ? { id: params.parentId } : null
18931
+ }, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE);
18932
+ } catch (error) {
18933
+ const err = error;
18934
+ throw new Error(`Failed to create media item: ${_optionalChain([err, 'access', _40 => _40.response, 'optionalAccess', _41 => _41.status]) || "Unknown error"} - ${JSON.stringify(_optionalChain([err, 'access', _42 => _42.response, 'optionalAccess', _43 => _43.data])) || err.message}`);
18935
+ }
18936
+ if (response.status < 200 || response.status >= 300) {
18937
+ throw new Error(`Request failed with status code ${response.status}`);
18938
+ }
18939
+ const locationHeader = _optionalChain([response, 'access', _44 => _44.headers, 'optionalAccess', _45 => _45.location]) || _optionalChain([response, 'access', _46 => _46.headers, 'optionalAccess', _47 => _47.Location]);
18940
+ if (!locationHeader) {
18941
+ throw new Error("No Location header in response - cannot determine created media ID");
18942
+ }
18943
+ const idMatch = locationHeader.match(/\/([a-f0-9-]{36})$/i);
18944
+ if (!idMatch) {
18945
+ throw new Error(`Could not extract ID from Location header: ${locationHeader}`);
18923
18946
  }
18947
+ const mediaId = idMatch[1];
18948
+ return { name: params.name, id: mediaId };
18949
+ }
18950
+
18951
+ // src/umb-management-api/tools/media/post/helpers/source-type-helpers.ts
18952
+ var FILE_PATH_ENTRY = `filePath - Most efficient for local files, works with any size
18953
+ SECURITY: Requires UMBRACO_ALLOWED_MEDIA_PATHS environment variable
18954
+ to be configured with comma-separated allowed directories.
18955
+ Example: UMBRACO_ALLOWED_MEDIA_PATHS="/tmp/uploads,/var/media"`;
18956
+ function buildSourceTypeSection(allowFilePath, otherSources) {
18957
+ const sources = allowFilePath ? [FILE_PATH_ENTRY, ...otherSources] : otherSources;
18958
+ return sources.map((s, i) => ` ${i + 1}. ${s}`).join("\n");
18924
18959
  }
18925
18960
 
18926
18961
  // src/umb-management-api/tools/media/post/create-media.ts
@@ -18935,23 +18970,30 @@ async function uploadMediaFile(client, params) {
18935
18970
 
18936
18971
 
18937
18972
 
18938
- var createMediaSchema = _zod.z.object({
18939
- sourceType: _zod.z.enum(["filePath", "url", "base64"]).describe("Media source type: 'filePath' for local files (most efficient), 'url' for web files, 'base64' for embedded data (small files only)"),
18940
- name: _zod.z.string().describe("The name of the media item"),
18941
- mediaTypeName: _zod.z.string().describe(`Media type: '${_mcpserversdk.MEDIA_TYPE_IMAGE}', '${_mcpserversdk.MEDIA_TYPE_ARTICLE}', '${_mcpserversdk.MEDIA_TYPE_AUDIO}', '${_mcpserversdk.MEDIA_TYPE_VIDEO}', '${_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS}', '${_mcpserversdk.MEDIA_TYPE_FILE}', or custom media type name`),
18942
- filePath: _zod.z.string().optional().describe("Absolute path to the file (required if sourceType is 'filePath')"),
18943
- fileUrl: _zod.z.string().url().optional().describe("[raw] URL to fetch the file from (required if sourceType is 'url')"),
18944
- fileAsBase64: _zod.z.string().optional().describe("Base64 encoded file data (required if sourceType is 'base64')"),
18945
- parentId: _zod.z.string().uuid().optional().describe("Parent folder ID (defaults to root)")
18946
- });
18947
18973
  var createMediaOutputSchema = _zod.z.object({
18948
18974
  message: _zod.z.string(),
18949
18975
  name: _zod.z.string(),
18950
18976
  id: _zod.z.string().guid()
18951
18977
  });
18952
- var CreateMediaTool = {
18953
- name: "create-media",
18954
- description: `Upload any media file to Umbraco (images, documents, audio, video, SVG, or custom types).
18978
+ function createCreateMediaTool(options) {
18979
+ const sourceTypeValues = options.allowFilePath ? ["filePath", "url", "base64"] : ["url", "base64"];
18980
+ const sourceTypeDescription = options.allowFilePath ? "Media source type: 'filePath' for local files (most efficient), 'url' for web files, 'base64' for embedded data (small files only)" : "Media source type: 'url' for web files, 'base64' for embedded data (small files only)";
18981
+ const schema = _zod.z.object({
18982
+ sourceType: _zod.z.enum(sourceTypeValues).describe(sourceTypeDescription),
18983
+ name: _zod.z.string().describe("The name of the media item"),
18984
+ mediaTypeName: _zod.z.string().describe(`Media type: '${_mcpserversdk.MEDIA_TYPE_IMAGE}', '${_mcpserversdk.MEDIA_TYPE_ARTICLE}', '${_mcpserversdk.MEDIA_TYPE_AUDIO}', '${_mcpserversdk.MEDIA_TYPE_VIDEO}', '${_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS}', '${_mcpserversdk.MEDIA_TYPE_FILE}', or custom media type name`),
18985
+ filePath: _zod.z.string().optional().describe("Absolute path to the file (required if sourceType is 'filePath')"),
18986
+ fileUrl: _zod.z.string().url().optional().describe("[raw] URL to fetch the file from (required if sourceType is 'url')"),
18987
+ fileAsBase64: _zod.z.string().optional().describe("Base64 encoded file data (required if sourceType is 'base64')"),
18988
+ parentId: _zod.z.string().uuid().optional().describe("Parent folder ID (defaults to root)")
18989
+ });
18990
+ const filePathSection = buildSourceTypeSection(options.allowFilePath, [
18991
+ "url - Fetch from web URL",
18992
+ "base64 - Only for small files (<10KB) due to token usage"
18993
+ ]);
18994
+ const tool = {
18995
+ name: "create-media",
18996
+ description: `Upload any media file to Umbraco (images, documents, audio, video, SVG, or custom types).
18955
18997
 
18956
18998
  Media Types:
18957
18999
  - ${_mcpserversdk.MEDIA_TYPE_IMAGE}: jpg, png, gif, webp, etc. (supports cropping)
@@ -18963,48 +19005,45 @@ var CreateMediaTool = {
18963
19005
  - Custom: any custom media type created in Umbraco
18964
19006
 
18965
19007
  Source Types:
18966
- 1. filePath - Most efficient for local files, works with any size
18967
- SECURITY: Requires UMBRACO_ALLOWED_MEDIA_PATHS environment variable
18968
- to be configured with comma-separated allowed directories.
18969
- Example: UMBRACO_ALLOWED_MEDIA_PATHS="/tmp/uploads,/var/media"
18970
- 2. url - Fetch from web URL
18971
- 3. base64 - Only for small files (<10KB) due to token usage
19008
+ ${filePathSection}
18972
19009
 
18973
19010
  The tool automatically:
18974
19011
  - Creates temporary files
18975
19012
  - Detects and validates media types (auto-corrects SVG vs Image)
18976
19013
  - Configures correct property editors (ImageCropper vs UploadField)
18977
19014
  - Cleans up temporary files`,
18978
- inputSchema: createMediaSchema.shape,
18979
- outputSchema: createMediaOutputSchema.shape,
18980
- slices: ["create"],
18981
- handler: (async (model) => {
18982
- try {
18983
- const client = UmbracoManagementClient3.getClient();
18984
- const temporaryFileId = _uuid.v4.call(void 0, );
18985
- const { name: actualName, id } = await uploadMediaFile(client, {
18986
- sourceType: model.sourceType,
18987
- name: model.name,
18988
- mediaTypeName: model.mediaTypeName,
18989
- filePath: model.filePath,
18990
- fileUrl: model.fileUrl,
18991
- fileAsBase64: model.fileAsBase64,
18992
- parentId: model.parentId,
18993
- temporaryFileId
18994
- });
18995
- return _mcpserversdk.createToolResult.call(void 0, {
18996
- message: `Media "${actualName}" created successfully`,
18997
- name: actualName,
18998
- id
18999
- });
19000
- } catch (error) {
19001
- return _mcpserversdk.createToolResultError.call(void 0, {
19002
- detail: `Error creating media: ${error.message}`
19003
- });
19004
- }
19005
- })
19006
- };
19007
- var create_media_default = _mcpserversdk.withStandardDecorators.call(void 0, CreateMediaTool);
19015
+ inputSchema: schema.shape,
19016
+ outputSchema: createMediaOutputSchema.shape,
19017
+ slices: ["create"],
19018
+ handler: (async (model) => {
19019
+ try {
19020
+ const client = UmbracoManagementClient3.getClient();
19021
+ const temporaryFileId = _uuid.v4.call(void 0, );
19022
+ const { name: actualName, id } = await uploadMediaFile(client, {
19023
+ sourceType: model.sourceType,
19024
+ name: model.name,
19025
+ mediaTypeName: model.mediaTypeName,
19026
+ filePath: model.filePath,
19027
+ fileUrl: model.fileUrl,
19028
+ fileAsBase64: model.fileAsBase64,
19029
+ parentId: model.parentId,
19030
+ temporaryFileId
19031
+ });
19032
+ return _mcpserversdk.createToolResult.call(void 0, {
19033
+ message: `Media "${actualName}" created successfully`,
19034
+ name: actualName,
19035
+ id
19036
+ });
19037
+ } catch (error) {
19038
+ return _mcpserversdk.createToolResultError.call(void 0, {
19039
+ detail: `Error creating media: ${error.message}`
19040
+ });
19041
+ }
19042
+ })
19043
+ };
19044
+ return _mcpserversdk.withStandardDecorators.call(void 0, tool);
19045
+ }
19046
+ var create_media_default = createCreateMediaTool({ allowFilePath: true });
19008
19047
 
19009
19048
  // src/umb-management-api/tools/media/post/create-media-multiple.ts
19010
19049
 
@@ -19020,16 +19059,6 @@ var create_media_default = _mcpserversdk.withStandardDecorators.call(void 0, Cre
19020
19059
 
19021
19060
 
19022
19061
 
19023
- var createMediaMultipleSchema = _zod.z.object({
19024
- sourceType: _zod.z.enum(["filePath", "url"]).describe("Media source type: 'filePath' for local files (most efficient), 'url' for web files. Base64 not supported for batch uploads due to token usage."),
19025
- files: _zod.z.array(_zod.z.object({
19026
- name: _zod.z.string().describe("The name of the media item"),
19027
- filePath: _zod.z.string().optional().describe("Absolute path to the file (required if sourceType is 'filePath')"),
19028
- fileUrl: _zod.z.string().url().optional().describe("URL to fetch the file from (required if sourceType is 'url')"),
19029
- mediaTypeName: _zod.z.string().optional().describe(`Optional override: '${_mcpserversdk.MEDIA_TYPE_IMAGE}', '${_mcpserversdk.MEDIA_TYPE_ARTICLE}', '${_mcpserversdk.MEDIA_TYPE_AUDIO}', '${_mcpserversdk.MEDIA_TYPE_VIDEO}', '${_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS}', '${_mcpserversdk.MEDIA_TYPE_FILE}', or custom media type name. If not specified, defaults to '${_mcpserversdk.MEDIA_TYPE_FILE}'`)
19030
- })).describe("Array of files to upload (maximum 20 files per batch)"),
19031
- parentId: _zod.z.string().uuid().optional().describe("Parent folder ID (defaults to root)")
19032
- });
19033
19062
  var createMediaMultipleOutputSchema = _zod.z.object({
19034
19063
  summary: _zod.z.string(),
19035
19064
  results: _zod.z.array(_zod.z.object({
@@ -19039,70 +19068,84 @@ var createMediaMultipleOutputSchema = _zod.z.object({
19039
19068
  error: _zod.z.string().optional()
19040
19069
  }))
19041
19070
  });
19042
- var CreateMediaMultipleTool = {
19043
- name: "create-media-multiple",
19044
- description: `Batch upload multiple media files to Umbraco (maximum 20 files per batch).
19071
+ function createCreateMediaMultipleTool(options) {
19072
+ const sourceTypeValues = options.allowFilePath ? ["filePath", "url"] : ["url"];
19073
+ const sourceTypeDescription = options.allowFilePath ? "Media source type: 'filePath' for local files (most efficient), 'url' for web files. Base64 not supported for batch uploads due to token usage." : "Media source type: 'url' for web files. Base64 not supported for batch uploads due to token usage.";
19074
+ const schema = _zod.z.object({
19075
+ sourceType: _zod.z.enum(sourceTypeValues).describe(sourceTypeDescription),
19076
+ files: _zod.z.array(_zod.z.object({
19077
+ name: _zod.z.string().describe("The name of the media item"),
19078
+ filePath: _zod.z.string().optional().describe("Absolute path to the file (required if sourceType is 'filePath')"),
19079
+ fileUrl: _zod.z.string().url().optional().describe("URL to fetch the file from (required if sourceType is 'url')"),
19080
+ mediaTypeName: _zod.z.string().optional().describe(`Optional override: '${_mcpserversdk.MEDIA_TYPE_IMAGE}', '${_mcpserversdk.MEDIA_TYPE_ARTICLE}', '${_mcpserversdk.MEDIA_TYPE_AUDIO}', '${_mcpserversdk.MEDIA_TYPE_VIDEO}', '${_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS}', '${_mcpserversdk.MEDIA_TYPE_FILE}', or custom media type name. If not specified, defaults to '${_mcpserversdk.MEDIA_TYPE_FILE}'`)
19081
+ })).describe("Array of files to upload (maximum 20 files per batch)"),
19082
+ parentId: _zod.z.string().uuid().optional().describe("Parent folder ID (defaults to root)")
19083
+ });
19084
+ const filePathSection = buildSourceTypeSection(options.allowFilePath, [
19085
+ "url - Fetch from web URL"
19086
+ ]);
19087
+ const tool = {
19088
+ name: "create-media-multiple",
19089
+ description: `Batch upload multiple media files to Umbraco (maximum 20 files per batch).
19045
19090
 
19046
19091
  Supports any file type: images, documents, audio, video, SVG, or custom types.
19047
19092
 
19048
19093
  Source Types:
19049
- 1. filePath - Most efficient for local files, works with any size
19050
- SECURITY: Requires UMBRACO_ALLOWED_MEDIA_PATHS environment variable
19051
- to be configured with comma-separated allowed directories.
19052
- Example: UMBRACO_ALLOWED_MEDIA_PATHS="/tmp/uploads,/var/media"
19053
- 2. url - Fetch from web URL
19094
+ ${filePathSection}
19054
19095
 
19055
19096
  Note: base64 is not supported for batch uploads due to token usage.
19056
19097
 
19057
19098
  The tool processes files sequentially and returns detailed results for each file.
19058
19099
  If some files fail, others will continue processing (continue-on-error strategy).`,
19059
- inputSchema: createMediaMultipleSchema.shape,
19060
- outputSchema: createMediaMultipleOutputSchema.shape,
19061
- slices: ["create"],
19062
- handler: (async (model) => {
19063
- if (model.files.length > 20) {
19064
- return _mcpserversdk.createToolResultError.call(void 0, {
19065
- detail: `Batch upload limited to 20 files per call. You provided ${model.files.length} files. Please split into multiple batches.`
19066
- });
19067
- }
19068
- const results = [];
19069
- const client = UmbracoManagementClient3.getClient();
19070
- for (const file of model.files) {
19071
- try {
19072
- const temporaryFileId = _uuid.v4.call(void 0, );
19073
- const defaultMediaType = file.mediaTypeName || _mcpserversdk.MEDIA_TYPE_FILE;
19074
- const { name: actualName, id: mediaId } = await uploadMediaFile(client, {
19075
- sourceType: model.sourceType,
19076
- name: file.name,
19077
- mediaTypeName: defaultMediaType,
19078
- filePath: file.filePath,
19079
- fileUrl: file.fileUrl,
19080
- fileAsBase64: void 0,
19081
- parentId: model.parentId,
19082
- temporaryFileId
19083
- });
19084
- results.push({
19085
- success: true,
19086
- name: actualName,
19087
- id: mediaId
19088
- });
19089
- } catch (error) {
19090
- results.push({
19091
- success: false,
19092
- name: file.name,
19093
- error: error.message
19100
+ inputSchema: schema.shape,
19101
+ outputSchema: createMediaMultipleOutputSchema.shape,
19102
+ slices: ["create"],
19103
+ handler: (async (model) => {
19104
+ if (model.files.length > 20) {
19105
+ return _mcpserversdk.createToolResultError.call(void 0, {
19106
+ detail: `Batch upload limited to 20 files per call. You provided ${model.files.length} files. Please split into multiple batches.`
19094
19107
  });
19095
19108
  }
19096
- }
19097
- const successCount = results.filter((r) => r.success).length;
19098
- const failureCount = results.filter((r) => !r.success).length;
19099
- return _mcpserversdk.createToolResult.call(void 0, {
19100
- summary: `Processed ${model.files.length} files: ${successCount} succeeded, ${failureCount} failed`,
19101
- results
19102
- });
19103
- })
19104
- };
19105
- var create_media_multiple_default = _mcpserversdk.withStandardDecorators.call(void 0, CreateMediaMultipleTool);
19109
+ const results = [];
19110
+ const client = UmbracoManagementClient3.getClient();
19111
+ for (const file of model.files) {
19112
+ try {
19113
+ const temporaryFileId = _uuid.v4.call(void 0, );
19114
+ const defaultMediaType = file.mediaTypeName || _mcpserversdk.MEDIA_TYPE_FILE;
19115
+ const { name: actualName, id: mediaId } = await uploadMediaFile(client, {
19116
+ sourceType: model.sourceType,
19117
+ name: file.name,
19118
+ mediaTypeName: defaultMediaType,
19119
+ filePath: file.filePath,
19120
+ fileUrl: file.fileUrl,
19121
+ fileAsBase64: void 0,
19122
+ parentId: model.parentId,
19123
+ temporaryFileId
19124
+ });
19125
+ results.push({
19126
+ success: true,
19127
+ name: actualName,
19128
+ id: mediaId
19129
+ });
19130
+ } catch (error) {
19131
+ results.push({
19132
+ success: false,
19133
+ name: file.name,
19134
+ error: error.message
19135
+ });
19136
+ }
19137
+ }
19138
+ const successCount = results.filter((r) => r.success).length;
19139
+ const failureCount = results.filter((r) => !r.success).length;
19140
+ return _mcpserversdk.createToolResult.call(void 0, {
19141
+ summary: `Processed ${model.files.length} files: ${successCount} succeeded, ${failureCount} failed`,
19142
+ results
19143
+ });
19144
+ })
19145
+ };
19146
+ return _mcpserversdk.withStandardDecorators.call(void 0, tool);
19147
+ }
19148
+ var create_media_multiple_default = createCreateMediaMultipleTool({ allowFilePath: true });
19106
19149
 
19107
19150
  // src/umb-management-api/tools/media/post/create-media-folder.ts
19108
19151
 
@@ -19146,7 +19189,7 @@ var CreateMediaFolderTool = {
19146
19189
  if (response.status < 200 || response.status >= 300) {
19147
19190
  throw new Error(`Request failed with status code ${response.status}`);
19148
19191
  }
19149
- const locationHeader = _optionalChain([response, 'access', _41 => _41.headers, 'optionalAccess', _42 => _42.location]) || _optionalChain([response, 'access', _43 => _43.headers, 'optionalAccess', _44 => _44.Location]);
19192
+ const locationHeader = _optionalChain([response, 'access', _48 => _48.headers, 'optionalAccess', _49 => _49.location]) || _optionalChain([response, 'access', _50 => _50.headers, 'optionalAccess', _51 => _51.Location]);
19150
19193
  if (!locationHeader) {
19151
19194
  throw new Error("No Location header in response - cannot determine created folder ID");
19152
19195
  }
@@ -19921,8 +19964,9 @@ var MediaCollection = {
19921
19964
  tools.push(get_root_default6);
19922
19965
  }
19923
19966
  if (AuthorizationPolicies.SectionAccessMedia(user)) {
19924
- tools.push(create_media_default);
19925
- tools.push(create_media_multiple_default);
19967
+ const allowFilePath = isFilePathUploadAllowed();
19968
+ tools.push(createCreateMediaTool({ allowFilePath }));
19969
+ tools.push(createCreateMediaMultipleTool({ allowFilePath }));
19926
19970
  tools.push(create_media_folder_default);
19927
19971
  tools.push(delete_media_default);
19928
19972
  tools.push(update_media_default);
@@ -20382,7 +20426,7 @@ var CreateMediaTypeFolderTool = {
20382
20426
  validateStatus: () => true
20383
20427
  });
20384
20428
  if (response.status === 201) {
20385
- const locationHeader = _optionalChain([response, 'access', _45 => _45.headers, 'optionalAccess', _46 => _46["location"]]) || _optionalChain([response, 'access', _47 => _47.headers, 'optionalAccess', _48 => _48["Location"]]);
20429
+ const locationHeader = _optionalChain([response, 'access', _52 => _52.headers, 'optionalAccess', _53 => _53["location"]]) || _optionalChain([response, 'access', _54 => _54.headers, 'optionalAccess', _55 => _55["Location"]]);
20386
20430
  let createdId = model.id || "";
20387
20431
  if (locationHeader) {
20388
20432
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -20516,7 +20560,7 @@ var CreateMediaTypeTool = {
20516
20560
  validateStatus: () => true
20517
20561
  });
20518
20562
  if (response.status === 201) {
20519
- const locationHeader = _optionalChain([response, 'access', _49 => _49.headers, 'optionalAccess', _50 => _50["location"]]) || _optionalChain([response, 'access', _51 => _51.headers, 'optionalAccess', _52 => _52["Location"]]);
20563
+ const locationHeader = _optionalChain([response, 'access', _56 => _56.headers, 'optionalAccess', _57 => _57["location"]]) || _optionalChain([response, 'access', _58 => _58.headers, 'optionalAccess', _59 => _59["Location"]]);
20520
20564
  let createdId = model.id || "";
20521
20565
  if (locationHeader) {
20522
20566
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -20567,7 +20611,7 @@ var CopyMediaTypeTool = {
20567
20611
  validateStatus: () => true
20568
20612
  });
20569
20613
  if (response.status === 201) {
20570
- const locationHeader = _optionalChain([response, 'access', _53 => _53.headers, 'optionalAccess', _54 => _54["location"]]) || _optionalChain([response, 'access', _55 => _55.headers, 'optionalAccess', _56 => _56["Location"]]);
20614
+ const locationHeader = _optionalChain([response, 'access', _60 => _60.headers, 'optionalAccess', _61 => _61["location"]]) || _optionalChain([response, 'access', _62 => _62.headers, 'optionalAccess', _63 => _63["Location"]]);
20571
20615
  let createdId = "";
20572
20616
  if (locationHeader) {
20573
20617
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -20777,7 +20821,7 @@ var CreateMemberTool = {
20777
20821
  validateStatus: () => true
20778
20822
  });
20779
20823
  if (response.status === 201) {
20780
- const locationHeader = _optionalChain([response, 'access', _57 => _57.headers, 'optionalAccess', _58 => _58["location"]]) || _optionalChain([response, 'access', _59 => _59.headers, 'optionalAccess', _60 => _60["Location"]]);
20824
+ const locationHeader = _optionalChain([response, 'access', _64 => _64.headers, 'optionalAccess', _65 => _65["location"]]) || _optionalChain([response, 'access', _66 => _66.headers, 'optionalAccess', _67 => _67["Location"]]);
20781
20825
  let createdId = model.id || "";
20782
20826
  if (locationHeader) {
20783
20827
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21328,7 +21372,7 @@ var CreateMemberTypeTool = {
21328
21372
  validateStatus: () => true
21329
21373
  });
21330
21374
  if (response.status === 201) {
21331
- const locationHeader = _optionalChain([response, 'access', _61 => _61.headers, 'optionalAccess', _62 => _62["location"]]) || _optionalChain([response, 'access', _63 => _63.headers, 'optionalAccess', _64 => _64["Location"]]);
21375
+ const locationHeader = _optionalChain([response, 'access', _68 => _68.headers, 'optionalAccess', _69 => _69["location"]]) || _optionalChain([response, 'access', _70 => _70.headers, 'optionalAccess', _71 => _71["Location"]]);
21332
21376
  let createdId = model.id || "";
21333
21377
  if (locationHeader) {
21334
21378
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21498,7 +21542,7 @@ var CopyMemberTypeTool = {
21498
21542
  validateStatus: () => true
21499
21543
  });
21500
21544
  if (response.status === 201) {
21501
- const locationHeader = _optionalChain([response, 'access', _65 => _65.headers, 'optionalAccess', _66 => _66["location"]]) || _optionalChain([response, 'access', _67 => _67.headers, 'optionalAccess', _68 => _68["Location"]]);
21545
+ const locationHeader = _optionalChain([response, 'access', _72 => _72.headers, 'optionalAccess', _73 => _73["location"]]) || _optionalChain([response, 'access', _74 => _74.headers, 'optionalAccess', _75 => _75["Location"]]);
21502
21546
  let createdId = "";
21503
21547
  if (locationHeader) {
21504
21548
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21858,7 +21902,7 @@ var CreatePartialViewTool = {
21858
21902
  validateStatus: () => true
21859
21903
  });
21860
21904
  if (response.status === 201) {
21861
- const locationHeader = _optionalChain([response, 'access', _69 => _69.headers, 'optionalAccess', _70 => _70["location"]]) || _optionalChain([response, 'access', _71 => _71.headers, 'optionalAccess', _72 => _72["Location"]]);
21905
+ const locationHeader = _optionalChain([response, 'access', _76 => _76.headers, 'optionalAccess', _77 => _77["location"]]) || _optionalChain([response, 'access', _78 => _78.headers, 'optionalAccess', _79 => _79["Location"]]);
21862
21906
  let createdPath = "";
21863
21907
  if (locationHeader) {
21864
21908
  const pathMatch = locationHeader.match(/partial-view\/(.+)$/);
@@ -21905,7 +21949,7 @@ var CreatePartialViewFolderTool = {
21905
21949
  validateStatus: () => true
21906
21950
  });
21907
21951
  if (response.status === 201) {
21908
- const locationHeader = _optionalChain([response, 'access', _73 => _73.headers, 'optionalAccess', _74 => _74["location"]]) || _optionalChain([response, 'access', _75 => _75.headers, 'optionalAccess', _76 => _76["Location"]]);
21952
+ const locationHeader = _optionalChain([response, 'access', _80 => _80.headers, 'optionalAccess', _81 => _81["location"]]) || _optionalChain([response, 'access', _82 => _82.headers, 'optionalAccess', _83 => _83["Location"]]);
21909
21953
  let createdPath = "";
21910
21954
  if (locationHeader) {
21911
21955
  const pathMatch = locationHeader.match(/partial-view\/folder\/(.+)$/);
@@ -21941,9 +21985,9 @@ var GetPartialViewByPathTool = {
21941
21985
  outputSchema: getPartialViewByPathResponse.shape,
21942
21986
  annotations: { readOnlyHint: true },
21943
21987
  slices: ["read"],
21944
- handler: (async ({ path: path4 }) => {
21988
+ handler: (async ({ path: path3 }) => {
21945
21989
  return _mcpserversdk.executeGetApiCall.call(void 0,
21946
- (client) => client.getPartialViewByPath(path4, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
21990
+ (client) => client.getPartialViewByPath(path3, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
21947
21991
  );
21948
21992
  })
21949
21993
  };
@@ -21962,9 +22006,9 @@ var GetPartialViewFolderByPathTool = {
21962
22006
  outputSchema: getPartialViewFolderByPathResponse.shape,
21963
22007
  annotations: { readOnlyHint: true },
21964
22008
  slices: ["read", "folders"],
21965
- handler: (async ({ path: path4 }) => {
22009
+ handler: (async ({ path: path3 }) => {
21966
22010
  return _mcpserversdk.executeGetApiCall.call(void 0,
21967
- (client) => client.getPartialViewFolderByPath(path4, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22011
+ (client) => client.getPartialViewFolderByPath(path3, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
21968
22012
  );
21969
22013
  })
21970
22014
  };
@@ -22039,9 +22083,9 @@ var DeletePartialViewTool = {
22039
22083
  destructiveHint: true
22040
22084
  },
22041
22085
  slices: ["delete"],
22042
- handler: (async ({ path: path4 }) => {
22086
+ handler: (async ({ path: path3 }) => {
22043
22087
  return _mcpserversdk.executeVoidApiCall.call(void 0,
22044
- (client) => client.deletePartialViewByPath(path4, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22088
+ (client) => client.deletePartialViewByPath(path3, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22045
22089
  );
22046
22090
  })
22047
22091
  };
@@ -22061,9 +22105,9 @@ var DeletePartialViewFolderTool = {
22061
22105
  destructiveHint: true
22062
22106
  },
22063
22107
  slices: ["delete", "folders"],
22064
- handler: (async ({ path: path4 }) => {
22108
+ handler: (async ({ path: path3 }) => {
22065
22109
  return _mcpserversdk.executeVoidApiCall.call(void 0,
22066
- (client) => client.deletePartialViewFolderByPath(path4, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22110
+ (client) => client.deletePartialViewFolderByPath(path3, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22067
22111
  );
22068
22112
  })
22069
22113
  };
@@ -22549,9 +22593,9 @@ var GetScriptByPathTool = {
22549
22593
  outputSchema: getScriptByPathResponse.shape,
22550
22594
  annotations: { readOnlyHint: true },
22551
22595
  slices: ["read"],
22552
- handler: (async ({ path: path4 }) => {
22596
+ handler: (async ({ path: path3 }) => {
22553
22597
  return _mcpserversdk.executeGetApiCall.call(void 0,
22554
- (client) => client.getScriptByPath(path4, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22598
+ (client) => client.getScriptByPath(path3, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22555
22599
  );
22556
22600
  })
22557
22601
  };
@@ -22570,9 +22614,9 @@ var GetScriptFolderByPathTool = {
22570
22614
  outputSchema: getScriptFolderByPathResponse.shape,
22571
22615
  annotations: { readOnlyHint: true },
22572
22616
  slices: ["read", "folders"],
22573
- handler: (async ({ path: path4 }) => {
22617
+ handler: (async ({ path: path3 }) => {
22574
22618
  return _mcpserversdk.executeGetApiCall.call(void 0,
22575
- (client) => client.getScriptFolderByPath(path4, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22619
+ (client) => client.getScriptFolderByPath(path3, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22576
22620
  );
22577
22621
  })
22578
22622
  };
@@ -22727,7 +22771,7 @@ var CreateScriptTool = {
22727
22771
  validateStatus: () => true
22728
22772
  });
22729
22773
  if (response.status === 201) {
22730
- const locationHeader = _optionalChain([response, 'access', _77 => _77.headers, 'optionalAccess', _78 => _78["location"]]) || _optionalChain([response, 'access', _79 => _79.headers, 'optionalAccess', _80 => _80["Location"]]);
22774
+ const locationHeader = _optionalChain([response, 'access', _84 => _84.headers, 'optionalAccess', _85 => _85["location"]]) || _optionalChain([response, 'access', _86 => _86.headers, 'optionalAccess', _87 => _87["Location"]]);
22731
22775
  let createdPath = "";
22732
22776
  if (locationHeader) {
22733
22777
  const pathMatch = locationHeader.match(/script\/(.+)$/);
@@ -22774,7 +22818,7 @@ var CreateScriptFolderTool = {
22774
22818
  validateStatus: () => true
22775
22819
  });
22776
22820
  if (response.status === 201) {
22777
- const locationHeader = _optionalChain([response, 'access', _81 => _81.headers, 'optionalAccess', _82 => _82["location"]]) || _optionalChain([response, 'access', _83 => _83.headers, 'optionalAccess', _84 => _84["Location"]]);
22821
+ const locationHeader = _optionalChain([response, 'access', _88 => _88.headers, 'optionalAccess', _89 => _89["location"]]) || _optionalChain([response, 'access', _90 => _90.headers, 'optionalAccess', _91 => _91["Location"]]);
22778
22822
  let createdPath = "";
22779
22823
  if (locationHeader) {
22780
22824
  const pathMatch = locationHeader.match(/script\/folder\/(.+)$/);
@@ -22870,9 +22914,9 @@ var DeleteScriptTool = {
22870
22914
  destructiveHint: true
22871
22915
  },
22872
22916
  slices: ["delete"],
22873
- handler: (async ({ path: path4 }) => {
22917
+ handler: (async ({ path: path3 }) => {
22874
22918
  return _mcpserversdk.executeVoidApiCall.call(void 0,
22875
- (client) => client.deleteScriptByPath(path4, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22919
+ (client) => client.deleteScriptByPath(path3, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22876
22920
  );
22877
22921
  })
22878
22922
  };
@@ -22892,9 +22936,9 @@ var DeleteScriptFolderTool = {
22892
22936
  destructiveHint: true
22893
22937
  },
22894
22938
  slices: ["delete", "folders"],
22895
- handler: (async ({ path: path4 }) => {
22939
+ handler: (async ({ path: path3 }) => {
22896
22940
  return _mcpserversdk.executeVoidApiCall.call(void 0,
22897
- (client) => client.deleteScriptFolderByPath(path4, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22941
+ (client) => client.deleteScriptFolderByPath(path3, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
22898
22942
  );
22899
22943
  })
22900
22944
  };
@@ -23371,7 +23415,7 @@ var CreateStylesheetTool = {
23371
23415
  validateStatus: () => true
23372
23416
  });
23373
23417
  if (response.status === 201) {
23374
- const locationHeader = _optionalChain([response, 'access', _85 => _85.headers, 'optionalAccess', _86 => _86["location"]]) || _optionalChain([response, 'access', _87 => _87.headers, 'optionalAccess', _88 => _88["Location"]]);
23418
+ const locationHeader = _optionalChain([response, 'access', _92 => _92.headers, 'optionalAccess', _93 => _93["location"]]) || _optionalChain([response, 'access', _94 => _94.headers, 'optionalAccess', _95 => _95["Location"]]);
23375
23419
  let createdPath = "";
23376
23420
  if (locationHeader) {
23377
23421
  const pathMatch = locationHeader.match(/stylesheet\/(.+)$/);
@@ -23418,7 +23462,7 @@ var CreateStylesheetFolderTool = {
23418
23462
  validateStatus: () => true
23419
23463
  });
23420
23464
  if (response.status === 201) {
23421
- const locationHeader = _optionalChain([response, 'access', _89 => _89.headers, 'optionalAccess', _90 => _90["location"]]) || _optionalChain([response, 'access', _91 => _91.headers, 'optionalAccess', _92 => _92["Location"]]);
23465
+ const locationHeader = _optionalChain([response, 'access', _96 => _96.headers, 'optionalAccess', _97 => _97["location"]]) || _optionalChain([response, 'access', _98 => _98.headers, 'optionalAccess', _99 => _99["Location"]]);
23422
23466
  let createdPath = "";
23423
23467
  if (locationHeader) {
23424
23468
  const pathMatch = locationHeader.match(/stylesheet\/folder\/(.+)$/);
@@ -23502,9 +23546,9 @@ var UpdateStylesheetTool = {
23502
23546
  annotations: { idempotentHint: true },
23503
23547
  slices: ["update"],
23504
23548
  handler: (async (model) => {
23505
- const { path: path4, ...updateModel } = model;
23549
+ const { path: path3, ...updateModel } = model;
23506
23550
  return _mcpserversdk.executeVoidApiCall.call(void 0,
23507
- (client) => client.putStylesheetByPath(path4, updateModel, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
23551
+ (client) => client.putStylesheetByPath(path3, updateModel, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
23508
23552
  );
23509
23553
  })
23510
23554
  };
@@ -23528,8 +23572,8 @@ var RenameStylesheetTool = {
23528
23572
  annotations: { idempotentHint: true },
23529
23573
  slices: ["rename"],
23530
23574
  handler: (async (model) => {
23531
- const { path: path4, ...renameModel } = model;
23532
- const normalizedPath = encodeURIComponent(path4);
23575
+ const { path: path3, ...renameModel } = model;
23576
+ const normalizedPath = encodeURIComponent(path3);
23533
23577
  return _mcpserversdk.executeVoidApiCall.call(void 0,
23534
23578
  (client) => client.putStylesheetByPathRename(normalizedPath, renameModel, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE)
23535
23579
  );
@@ -23782,7 +23826,7 @@ var CreateTemplateTool = {
23782
23826
  validateStatus: () => true
23783
23827
  });
23784
23828
  if (response.status === 201) {
23785
- const locationHeader = _optionalChain([response, 'access', _93 => _93.headers, 'optionalAccess', _94 => _94["location"]]) || _optionalChain([response, 'access', _95 => _95.headers, 'optionalAccess', _96 => _96["Location"]]);
23829
+ const locationHeader = _optionalChain([response, 'access', _100 => _100.headers, 'optionalAccess', _101 => _101["location"]]) || _optionalChain([response, 'access', _102 => _102.headers, 'optionalAccess', _103 => _103["Location"]]);
23786
23830
  let createdId = "";
23787
23831
  if (locationHeader) {
23788
23832
  const idMatch = locationHeader.match(/template\/([a-f0-9-]+)$/i);
@@ -24146,9 +24190,6 @@ var TemplateCollection = {
24146
24190
 
24147
24191
 
24148
24192
 
24149
-
24150
-
24151
-
24152
24193
  var createTemporaryFileSchema = _zod.z.object({
24153
24194
  id: _zod.z.string().uuid().describe("Unique identifier for the temporary file"),
24154
24195
  fileName: _zod.z.string().describe("Name of the file"),
@@ -24171,7 +24212,6 @@ var CreateTemporaryFileTool = {
24171
24212
  outputSchema: createTemporaryFileOutputSchema.shape,
24172
24213
  slices: ["create"],
24173
24214
  handler: (async (model) => {
24174
- let tempFilePath = null;
24175
24215
  try {
24176
24216
  const fileContent = Buffer.from(model.fileAsBase64, "base64");
24177
24217
  let fileName = model.fileName;
@@ -24179,13 +24219,11 @@ var CreateTemporaryFileTool = {
24179
24219
  const extension = _mcpserversdk.detectFileExtensionFromBuffer.call(void 0, fileContent);
24180
24220
  fileName = `${fileName}${extension}`;
24181
24221
  }
24182
- tempFilePath = path3.join(os2.tmpdir(), `umbraco-upload-${model.id}-${fileName}`);
24183
- fs3.writeFileSync(tempFilePath, fileContent);
24184
- const readStream = fs3.createReadStream(tempFilePath);
24185
24222
  const client = UmbracoManagementClient3.getClient();
24186
24223
  await client.postTemporaryFile({
24187
24224
  Id: model.id,
24188
- File: readStream
24225
+ File: fileContent,
24226
+ FileName: fileName
24189
24227
  });
24190
24228
  return _mcpserversdk.createToolResult.call(void 0, {
24191
24229
  message: "Temporary file created successfully",
@@ -24195,14 +24233,6 @@ var CreateTemporaryFileTool = {
24195
24233
  return _mcpserversdk.createToolResultError.call(void 0, {
24196
24234
  detail: `Error creating temporary file: ${error.message}`
24197
24235
  });
24198
- } finally {
24199
- if (tempFilePath && fs3.existsSync(tempFilePath)) {
24200
- try {
24201
- fs3.unlinkSync(tempFilePath);
24202
- } catch (e) {
24203
- console.error("Failed to cleanup temp file:", e);
24204
- }
24205
- }
24206
24236
  }
24207
24237
  })
24208
24238
  };
@@ -24213,14 +24243,15 @@ var create_temporary_file_default = _mcpserversdk.withStandardDecorators.call(vo
24213
24243
 
24214
24244
  var postTemporaryFileBody = _zod.z.object({
24215
24245
  Id: _zod.z.string().uuid(),
24216
- File: _zod.z.instanceof(_fs.ReadStream)
24246
+ File: _zod.z.union([_zod.z.instanceof(Buffer), _zod.z.instanceof(_fs.ReadStream)]),
24247
+ FileName: _zod.z.string().min(1)
24217
24248
  });
24218
24249
  var getTemporaryFileByIdParams = _zod.z.object({
24219
24250
  id: _zod.z.string().uuid()
24220
24251
  });
24221
24252
  var getTemporaryFileByIdResponse = _zod.z.object({
24222
24253
  id: _zod.z.string().guid(),
24223
- availableUntil: _zod.z.string().datetime({ local: true }).nullish(),
24254
+ availableUntil: _zod.z.string().datetime({ local: true, offset: true }).nullish(),
24224
24255
  fileName: _zod.z.string().min(1)
24225
24256
  });
24226
24257
  var deleteTemporaryFileByIdParams = _zod.z.object({
@@ -24705,7 +24736,7 @@ var CreateUserDataTool = {
24705
24736
  validateStatus: () => true
24706
24737
  });
24707
24738
  if (response.status === 201) {
24708
- const locationHeader = _optionalChain([response, 'access', _97 => _97.headers, 'optionalAccess', _98 => _98["location"]]) || _optionalChain([response, 'access', _99 => _99.headers, 'optionalAccess', _100 => _100["Location"]]);
24739
+ const locationHeader = _optionalChain([response, 'access', _104 => _104.headers, 'optionalAccess', _105 => _105["location"]]) || _optionalChain([response, 'access', _106 => _106.headers, 'optionalAccess', _107 => _107["Location"]]);
24709
24740
  let createdId = "";
24710
24741
  if (locationHeader) {
24711
24742
  const idMatch = locationHeader.match(/user-data\/([a-f0-9-]+)$/i);
@@ -24943,7 +24974,7 @@ var CreateUserGroupTool = {
24943
24974
  validateStatus: () => true
24944
24975
  });
24945
24976
  if (response.status === 201) {
24946
- const locationHeader = _optionalChain([response, 'access', _101 => _101.headers, 'optionalAccess', _102 => _102["location"]]) || _optionalChain([response, 'access', _103 => _103.headers, 'optionalAccess', _104 => _104["Location"]]);
24977
+ const locationHeader = _optionalChain([response, 'access', _108 => _108.headers, 'optionalAccess', _109 => _109["location"]]) || _optionalChain([response, 'access', _110 => _110.headers, 'optionalAccess', _111 => _111["Location"]]);
24947
24978
  let createdId = "";
24948
24979
  if (locationHeader) {
24949
24980
  const idMatch = locationHeader.match(/user-group\/([a-f0-9-]+)$/i);
@@ -25241,7 +25272,7 @@ var CreateWebhookTool = {
25241
25272
  validateStatus: () => true
25242
25273
  });
25243
25274
  if (response.status === 201) {
25244
- const locationHeader = _optionalChain([response, 'access', _105 => _105.headers, 'optionalAccess', _106 => _106["location"]]) || _optionalChain([response, 'access', _107 => _107.headers, 'optionalAccess', _108 => _108["Location"]]);
25275
+ const locationHeader = _optionalChain([response, 'access', _112 => _112.headers, 'optionalAccess', _113 => _113["location"]]) || _optionalChain([response, 'access', _114 => _114.headers, 'optionalAccess', _115 => _115["Location"]]);
25245
25276
  let createdId = "";
25246
25277
  if (locationHeader) {
25247
25278
  const idMatch = locationHeader.match(/webhook\/([a-f0-9-]+)$/i);
@@ -25475,5 +25506,6 @@ var allSliceNames = [...toolSliceNames, "other"];
25475
25506
 
25476
25507
 
25477
25508
 
25478
- exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.UmbracoManagementClient = UmbracoManagementClient3; exports.setUmbracoVersion = setUmbracoVersion; exports.availableCollections = availableCollections; exports.allModes = allModes; exports.allModeNames = allModeNames; exports.allSliceNames = allSliceNames;
25479
- //# sourceMappingURL=chunk-OBOSCZYR.cjs.map
25509
+
25510
+ 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;
25511
+ //# sourceMappingURL=chunk-H5ZIS43M.cjs.map