@umbraco-cms/mcp-dev 17.3.7 → 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.
package/dist/index.js CHANGED
@@ -6,8 +6,10 @@ import {
6
6
  allModeNames,
7
7
  allModes,
8
8
  allSliceNames,
9
- availableCollections
10
- } from "./chunk-EONL3SEB.js";
9
+ availableCollections,
10
+ setAllowFilePathUploads,
11
+ setUmbracoVersion
12
+ } from "./chunk-XVBYRUFE.js";
11
13
 
12
14
  // node_modules/ajv/dist/compile/codegen/code.js
13
15
  var require_code = __commonJS({
@@ -3085,6 +3087,9 @@ var require_utils = __commonJS({
3085
3087
  "use strict";
3086
3088
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3087
3089
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3090
+ var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3091
+ var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3092
+ var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3088
3093
  function stringArrayToHexStripped(input) {
3089
3094
  let acc = "";
3090
3095
  let code = 0;
@@ -3277,27 +3282,77 @@ var require_utils = __commonJS({
3277
3282
  }
3278
3283
  return output.join("");
3279
3284
  }
3280
- function normalizeComponentEncoding(component, esc) {
3281
- const func = esc !== true ? escape : unescape;
3282
- if (component.scheme !== void 0) {
3283
- component.scheme = func(component.scheme);
3284
- }
3285
- if (component.userinfo !== void 0) {
3286
- component.userinfo = func(component.userinfo);
3287
- }
3288
- if (component.host !== void 0) {
3289
- component.host = func(component.host);
3285
+ var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
3286
+ var HOST_DELIM_RE = /[@/?#:]/g;
3287
+ var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
3288
+ function reescapeHostDelimiters(host, isIP) {
3289
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
3290
+ re.lastIndex = 0;
3291
+ return host.replace(re, (ch) => HOST_DELIMS[ch]);
3292
+ }
3293
+ function normalizePercentEncoding(input, decodeUnreserved = false) {
3294
+ if (input.indexOf("%") === -1) {
3295
+ return input;
3290
3296
  }
3291
- if (component.path !== void 0) {
3292
- component.path = func(component.path);
3297
+ let output = "";
3298
+ for (let i = 0; i < input.length; i++) {
3299
+ if (input[i] === "%" && i + 2 < input.length) {
3300
+ const hex = input.slice(i + 1, i + 3);
3301
+ if (isHexPair(hex)) {
3302
+ const normalizedHex = hex.toUpperCase();
3303
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3304
+ if (decodeUnreserved && isUnreserved(decoded)) {
3305
+ output += decoded;
3306
+ } else {
3307
+ output += "%" + normalizedHex;
3308
+ }
3309
+ i += 2;
3310
+ continue;
3311
+ }
3312
+ }
3313
+ output += input[i];
3293
3314
  }
3294
- if (component.query !== void 0) {
3295
- component.query = func(component.query);
3315
+ return output;
3316
+ }
3317
+ function normalizePathEncoding(input) {
3318
+ let output = "";
3319
+ for (let i = 0; i < input.length; i++) {
3320
+ if (input[i] === "%" && i + 2 < input.length) {
3321
+ const hex = input.slice(i + 1, i + 3);
3322
+ if (isHexPair(hex)) {
3323
+ const normalizedHex = hex.toUpperCase();
3324
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3325
+ if (decoded !== "." && isUnreserved(decoded)) {
3326
+ output += decoded;
3327
+ } else {
3328
+ output += "%" + normalizedHex;
3329
+ }
3330
+ i += 2;
3331
+ continue;
3332
+ }
3333
+ }
3334
+ if (isPathCharacter(input[i])) {
3335
+ output += input[i];
3336
+ } else {
3337
+ output += escape(input[i]);
3338
+ }
3296
3339
  }
3297
- if (component.fragment !== void 0) {
3298
- component.fragment = func(component.fragment);
3340
+ return output;
3341
+ }
3342
+ function escapePreservingEscapes(input) {
3343
+ let output = "";
3344
+ for (let i = 0; i < input.length; i++) {
3345
+ if (input[i] === "%" && i + 2 < input.length) {
3346
+ const hex = input.slice(i + 1, i + 3);
3347
+ if (isHexPair(hex)) {
3348
+ output += "%" + hex.toUpperCase();
3349
+ i += 2;
3350
+ continue;
3351
+ }
3352
+ }
3353
+ output += escape(input[i]);
3299
3354
  }
3300
- return component;
3355
+ return output;
3301
3356
  }
3302
3357
  function recomposeAuthority(component) {
3303
3358
  const uriTokens = [];
@@ -3312,7 +3367,7 @@ var require_utils = __commonJS({
3312
3367
  if (ipV6res.isIPV6 === true) {
3313
3368
  host = `[${ipV6res.escapedHost}]`;
3314
3369
  } else {
3315
- host = component.host;
3370
+ host = reescapeHostDelimiters(host, false);
3316
3371
  }
3317
3372
  }
3318
3373
  uriTokens.push(host);
@@ -3326,7 +3381,10 @@ var require_utils = __commonJS({
3326
3381
  module.exports = {
3327
3382
  nonSimpleDomain,
3328
3383
  recomposeAuthority,
3329
- normalizeComponentEncoding,
3384
+ reescapeHostDelimiters,
3385
+ normalizePercentEncoding,
3386
+ normalizePathEncoding,
3387
+ escapePreservingEscapes,
3330
3388
  removeDotSegments,
3331
3389
  isIPv4,
3332
3390
  isUUID,
@@ -3550,12 +3608,12 @@ var require_schemes = __commonJS({
3550
3608
  var require_fast_uri = __commonJS({
3551
3609
  "node_modules/fast-uri/index.js"(exports, module) {
3552
3610
  "use strict";
3553
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
3611
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3554
3612
  var { SCHEMES, getSchemeHandler } = require_schemes();
3555
3613
  function normalize(uri, options) {
3556
3614
  if (typeof uri === "string") {
3557
3615
  uri = /** @type {T} */
3558
- serialize(parse(uri, options), options);
3616
+ normalizeString(uri, options);
3559
3617
  } else if (typeof uri === "object") {
3560
3618
  uri = /** @type {T} */
3561
3619
  parse(serialize(uri, options), options);
@@ -3622,19 +3680,9 @@ var require_fast_uri = __commonJS({
3622
3680
  return target;
3623
3681
  }
3624
3682
  function equal(uriA, uriB, options) {
3625
- if (typeof uriA === "string") {
3626
- uriA = unescape(uriA);
3627
- uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), { ...options, skipEscape: true });
3628
- } else if (typeof uriA === "object") {
3629
- uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
3630
- }
3631
- if (typeof uriB === "string") {
3632
- uriB = unescape(uriB);
3633
- uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), { ...options, skipEscape: true });
3634
- } else if (typeof uriB === "object") {
3635
- uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
3636
- }
3637
- return uriA.toLowerCase() === uriB.toLowerCase();
3683
+ const normalizedA = normalizeComparableURI(uriA, options);
3684
+ const normalizedB = normalizeComparableURI(uriB, options);
3685
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
3638
3686
  }
3639
3687
  function serialize(cmpts, opts) {
3640
3688
  const component = {
@@ -3659,12 +3707,12 @@ var require_fast_uri = __commonJS({
3659
3707
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3660
3708
  if (component.path !== void 0) {
3661
3709
  if (!options.skipEscape) {
3662
- component.path = escape(component.path);
3710
+ component.path = escapePreservingEscapes(component.path);
3663
3711
  if (component.scheme !== void 0) {
3664
3712
  component.path = component.path.split("%3A").join(":");
3665
3713
  }
3666
3714
  } else {
3667
- component.path = unescape(component.path);
3715
+ component.path = normalizePercentEncoding(component.path);
3668
3716
  }
3669
3717
  }
3670
3718
  if (options.reference !== "suffix" && component.scheme) {
@@ -3699,7 +3747,16 @@ var require_fast_uri = __commonJS({
3699
3747
  return uriTokens.join("");
3700
3748
  }
3701
3749
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3702
- function parse(uri, opts) {
3750
+ function getParseError(parsed, matches) {
3751
+ if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
3752
+ return 'URI path must start with "/" when authority is present.';
3753
+ }
3754
+ if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
3755
+ return "URI port is malformed.";
3756
+ }
3757
+ return void 0;
3758
+ }
3759
+ function parseWithStatus(uri, opts) {
3703
3760
  const options = Object.assign({}, opts);
3704
3761
  const parsed = {
3705
3762
  scheme: void 0,
@@ -3710,6 +3767,7 @@ var require_fast_uri = __commonJS({
3710
3767
  query: void 0,
3711
3768
  fragment: void 0
3712
3769
  };
3770
+ let malformedAuthorityOrPort = false;
3713
3771
  let isIP = false;
3714
3772
  if (options.reference === "suffix") {
3715
3773
  if (options.scheme) {
@@ -3730,6 +3788,11 @@ var require_fast_uri = __commonJS({
3730
3788
  if (isNaN(parsed.port)) {
3731
3789
  parsed.port = matches[5];
3732
3790
  }
3791
+ const parseError = getParseError(parsed, matches);
3792
+ if (parseError !== void 0) {
3793
+ parsed.error = parsed.error || parseError;
3794
+ malformedAuthorityOrPort = true;
3795
+ }
3733
3796
  if (parsed.host) {
3734
3797
  const ipv4result = isIPv4(parsed.host);
3735
3798
  if (ipv4result === false) {
@@ -3768,14 +3831,18 @@ var require_fast_uri = __commonJS({
3768
3831
  parsed.scheme = unescape(parsed.scheme);
3769
3832
  }
3770
3833
  if (parsed.host !== void 0) {
3771
- parsed.host = unescape(parsed.host);
3834
+ parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
3772
3835
  }
3773
3836
  }
3774
3837
  if (parsed.path) {
3775
- parsed.path = escape(unescape(parsed.path));
3838
+ parsed.path = normalizePathEncoding(parsed.path);
3776
3839
  }
3777
3840
  if (parsed.fragment) {
3778
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3841
+ try {
3842
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3843
+ } catch {
3844
+ parsed.error = parsed.error || "URI malformed";
3845
+ }
3779
3846
  }
3780
3847
  }
3781
3848
  if (schemeHandler && schemeHandler.parse) {
@@ -3784,7 +3851,29 @@ var require_fast_uri = __commonJS({
3784
3851
  } else {
3785
3852
  parsed.error = parsed.error || "URI can not be parsed.";
3786
3853
  }
3787
- return parsed;
3854
+ return { parsed, malformedAuthorityOrPort };
3855
+ }
3856
+ function parse(uri, opts) {
3857
+ return parseWithStatus(uri, opts).parsed;
3858
+ }
3859
+ function normalizeString(uri, opts) {
3860
+ return normalizeStringWithStatus(uri, opts).normalized;
3861
+ }
3862
+ function normalizeStringWithStatus(uri, opts) {
3863
+ const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
3864
+ return {
3865
+ normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3866
+ malformedAuthorityOrPort
3867
+ };
3868
+ }
3869
+ function normalizeComparableURI(uri, opts) {
3870
+ if (typeof uri === "string") {
3871
+ const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3872
+ return malformedAuthorityOrPort ? void 0 : normalized;
3873
+ }
3874
+ if (typeof uri === "object") {
3875
+ return serialize(uri, opts);
3876
+ }
3788
3877
  }
3789
3878
  var fastUri = {
3790
3879
  SCHEMES,
@@ -12422,7 +12511,7 @@ var StdioServerTransport = class {
12422
12511
  // package.json
12423
12512
  var package_default = {
12424
12513
  name: "@umbraco-cms/mcp-dev",
12425
- version: "17.3.7",
12514
+ version: "17.4.1",
12426
12515
  type: "module",
12427
12516
  description: "A model context protocol (MCP) server for Umbraco CMS",
12428
12517
  main: "dist/index.js",
@@ -12490,8 +12579,8 @@ var package_default = {
12490
12579
  "@modelcontextprotocol/sdk": "^1.28.0",
12491
12580
  "@types/uuid": "^10.0.0",
12492
12581
  "@types/yargs": "^17.0.33",
12493
- "@umbraco-cms/mcp-hosted": "^17.0.0-beta.21",
12494
- "@umbraco-cms/mcp-server-sdk": "^17.0.0-beta.21",
12582
+ "@umbraco-cms/mcp-hosted": "^17.0.0-beta.25",
12583
+ "@umbraco-cms/mcp-server-sdk": "^17.0.0-beta.25",
12495
12584
  axios: "^1.8.4",
12496
12585
  dotenv: "^16.5.0",
12497
12586
  "form-data": "^4.0.4",
@@ -12693,6 +12782,7 @@ Readonly mode: Disabled ${filteredTools.length} write tools:`);
12693
12782
  // src/index.ts
12694
12783
  import { checkUmbracoVersion, configureApiClient, initializeUmbracoFetch, getServerConfig as getServerConfig2, handleCliCommands, createCollectionConfigLoader as createCollectionConfigLoader2 } from "@umbraco-cms/mcp-server-sdk";
12695
12784
  var main = async () => {
12785
+ setAllowFilePathUploads(true);
12696
12786
  clearConfigCache();
12697
12787
  const serverConfig = await loadServerConfig(true);
12698
12788
  const config = serverConfig.umbraco;
@@ -12719,9 +12809,11 @@ var main = async () => {
12719
12809
  filterConfig,
12720
12810
  serverConfig: config
12721
12811
  });
12812
+ const serverInfo = await client.getServerInformation();
12813
+ setUmbracoVersion(serverInfo.version);
12722
12814
  await checkUmbracoVersion({
12723
12815
  mcpVersion: package_default.version,
12724
- client: { getServerInformation: () => client.getServerInformation() }
12816
+ client: { getServerInformation: async () => serverInfo }
12725
12817
  });
12726
12818
  UmbracoToolFactory(server, user, config);
12727
12819
  const transport = new StdioServerTransport();