@ampless/mcp-server 1.0.0-beta.58 → 1.0.0-beta.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +90 -58
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -452,7 +452,23 @@ var uploadMediaSchema = {
452
452
  }
453
453
  }
454
454
  };
455
+ var MIME_TYPE_RE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/i;
456
+ var BLOCKED_MIME_TYPES = /* @__PURE__ */ new Set([
457
+ "text/html",
458
+ "application/xhtml+xml",
459
+ "application/javascript",
460
+ "text/javascript"
461
+ ]);
462
+ function assertSafeMimeType(mimeType) {
463
+ if (!MIME_TYPE_RE.test(mimeType)) {
464
+ throw new Error(`upload_media: invalid mimeType: ${JSON.stringify(mimeType)}`);
465
+ }
466
+ if (BLOCKED_MIME_TYPES.has(mimeType.toLowerCase())) {
467
+ throw new Error(`upload_media: mimeType not allowed for public media: ${mimeType}`);
468
+ }
469
+ }
455
470
  async function uploadMedia(graphql, storage, args) {
471
+ assertSafeMimeType(args.mimeType);
456
472
  const body = Buffer.from(args.base64Data, "base64");
457
473
  const key = buildMediaKey(args.filename);
458
474
  const putResult = await storage.putObject(key, body, args.mimeType);
@@ -645,13 +661,16 @@ var GET_BY_ID2 = (
645
661
  }
646
662
  `
647
663
  );
648
- var GET_BY_SRC = (
664
+ var FIND_BY_SRC = (
649
665
  /* GraphQL */
650
666
  `
651
- query GetMediaBySrc($src: String!) {
652
- getMediaBySrc(src: $src) {
653
- mediaId
654
- src
667
+ query FindMediaBySrc($filter: ModelMediaFilterInput!, $nextToken: String) {
668
+ listMedia(filter: $filter, limit: 100, nextToken: $nextToken) {
669
+ items {
670
+ mediaId
671
+ src
672
+ }
673
+ nextToken
655
674
  }
656
675
  }
657
676
  `
@@ -720,12 +739,18 @@ async function deleteMedia(graphql, storage, args) {
720
739
  assertMediaPrefix(src);
721
740
  }
722
741
  } else {
723
- const data = await graphql.query(GET_BY_SRC, { src: args.src });
724
- if (data.getMediaBySrc) {
725
- mediaId = data.getMediaBySrc.mediaId;
726
- src = data.getMediaBySrc.src;
727
- assertMediaPrefix(src);
728
- }
742
+ let cursor;
743
+ do {
744
+ const data = await graphql.query(FIND_BY_SRC, { filter: { src: { eq: args.src } }, nextToken: cursor });
745
+ const row = data.listMedia.items[0];
746
+ if (row) {
747
+ mediaId = row.mediaId;
748
+ src = row.src;
749
+ assertMediaPrefix(src);
750
+ break;
751
+ }
752
+ cursor = data.listMedia.nextToken ?? void 0;
753
+ } while (cursor);
729
754
  }
730
755
  if (!mediaId) {
731
756
  if (args.src) {
@@ -782,7 +807,12 @@ function getSchema() {
782
807
  slug: { type: "string", required: true, description: "URL slug, unique" },
783
808
  title: { type: "string", required: true },
784
809
  excerpt: { type: "string" },
785
- format: { type: "enum", values: ["tiptap", "markdown", "html"], required: true },
810
+ format: {
811
+ type: "enum",
812
+ values: ["tiptap", "markdown", "html", "static"],
813
+ required: true,
814
+ description: "`static` is read-only here \u2014 get_post / list_posts can return it, but it is created/edited only via the static-bundle tools (upload_static_bundle, upload_static_file, delete_static_file, commit_static_post), NOT create_post / update_post. See notes.staticFormat."
815
+ },
786
816
  body: {
787
817
  type: "json",
788
818
  description: "tiptap node JSON when format=tiptap; markdown source string when format=markdown; raw HTML string when format=html"
@@ -821,7 +851,7 @@ function getSchema() {
821
851
  }
822
852
  }
823
853
  ],
824
- formats: ["tiptap", "markdown", "html"],
854
+ formats: ["tiptap", "markdown", "html", "static"],
825
855
  notes: {
826
856
  editorTrust: 'editor stores arbitrary HTML/JS verbatim \u2014 same trust shape as WordPress unfiltered_html capability. See docs/architecture/04-access-layer-mcp.md \xA7"editor \u306E\u4FE1\u983C\u30E2\u30C7\u30EB".',
827
857
  tiptapBody: 'When format=tiptap, body is the tiptap document JSON: { type: "doc", content: [...] }. The renderer expects this shape.',
@@ -927,13 +957,13 @@ var fdeb = new u8([
927
957
  var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
928
958
  var freb = function(eb, start) {
929
959
  var b = new u16(31);
930
- for (var i = 0; i < 31; ++i) {
931
- b[i] = start += 1 << eb[i - 1];
960
+ for (var i2 = 0; i2 < 31; ++i2) {
961
+ b[i2] = start += 1 << eb[i2 - 1];
932
962
  }
933
963
  var r = new i32(b[30]);
934
- for (var i = 1; i < 30; ++i) {
935
- for (var j = b[i]; j < b[i + 1]; ++j) {
936
- r[j] = j - b[i] << 5 | i;
964
+ for (var i2 = 1; i2 < 30; ++i2) {
965
+ for (var j = b[i2]; j < b[i2 + 1]; ++j) {
966
+ r[j] = j - b[i2] << 5 | i2;
937
967
  }
938
968
  }
939
969
  return { b, r };
@@ -956,25 +986,25 @@ var x;
956
986
  var i;
957
987
  var hMap = (function(cd, mb, r) {
958
988
  var s = cd.length;
959
- var i = 0;
989
+ var i2 = 0;
960
990
  var l = new u16(mb);
961
- for (; i < s; ++i) {
962
- if (cd[i])
963
- ++l[cd[i] - 1];
991
+ for (; i2 < s; ++i2) {
992
+ if (cd[i2])
993
+ ++l[cd[i2] - 1];
964
994
  }
965
995
  var le = new u16(mb);
966
- for (i = 1; i < mb; ++i) {
967
- le[i] = le[i - 1] + l[i - 1] << 1;
996
+ for (i2 = 1; i2 < mb; ++i2) {
997
+ le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
968
998
  }
969
999
  var co;
970
1000
  if (r) {
971
1001
  co = new u16(1 << mb);
972
1002
  var rvb = 15 - mb;
973
- for (i = 0; i < s; ++i) {
974
- if (cd[i]) {
975
- var sv = i << 4 | cd[i];
976
- var r_1 = mb - cd[i];
977
- var v = le[cd[i] - 1]++ << r_1;
1003
+ for (i2 = 0; i2 < s; ++i2) {
1004
+ if (cd[i2]) {
1005
+ var sv = i2 << 4 | cd[i2];
1006
+ var r_1 = mb - cd[i2];
1007
+ var v = le[cd[i2] - 1]++ << r_1;
978
1008
  for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
979
1009
  co[rev[v] >> rvb] = sv;
980
1010
  }
@@ -982,9 +1012,9 @@ var hMap = (function(cd, mb, r) {
982
1012
  }
983
1013
  } else {
984
1014
  co = new u16(s);
985
- for (i = 0; i < s; ++i) {
986
- if (cd[i]) {
987
- co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
1015
+ for (i2 = 0; i2 < s; ++i2) {
1016
+ if (cd[i2]) {
1017
+ co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
988
1018
  }
989
1019
  }
990
1020
  }
@@ -1011,9 +1041,9 @@ var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
1011
1041
  var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
1012
1042
  var max = function(a) {
1013
1043
  var m = a[0];
1014
- for (var i = 1; i < a.length; ++i) {
1015
- if (a[i] > m)
1016
- m = a[i];
1044
+ for (var i2 = 1; i2 < a.length; ++i2) {
1045
+ if (a[i2] > m)
1046
+ m = a[i2];
1017
1047
  }
1018
1048
  return m;
1019
1049
  };
@@ -1106,28 +1136,28 @@ var inflt = function(dat, st, buf, dict) {
1106
1136
  pos += 14;
1107
1137
  var ldt = new u8(tl);
1108
1138
  var clt = new u8(19);
1109
- for (var i = 0; i < hcLen; ++i) {
1110
- clt[clim[i]] = bits(dat, pos + i * 3, 7);
1139
+ for (var i2 = 0; i2 < hcLen; ++i2) {
1140
+ clt[clim[i2]] = bits(dat, pos + i2 * 3, 7);
1111
1141
  }
1112
1142
  pos += hcLen * 3;
1113
1143
  var clb = max(clt), clbmsk = (1 << clb) - 1;
1114
1144
  var clm = hMap(clt, clb, 1);
1115
- for (var i = 0; i < tl; ) {
1145
+ for (var i2 = 0; i2 < tl; ) {
1116
1146
  var r = clm[bits(dat, pos, clbmsk)];
1117
1147
  pos += r & 15;
1118
1148
  var s = r >> 4;
1119
1149
  if (s < 16) {
1120
- ldt[i++] = s;
1150
+ ldt[i2++] = s;
1121
1151
  } else {
1122
1152
  var c = 0, n = 0;
1123
1153
  if (s == 16)
1124
- n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
1154
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i2 - 1];
1125
1155
  else if (s == 17)
1126
1156
  n = 3 + bits(dat, pos, 7), pos += 3;
1127
1157
  else if (s == 18)
1128
1158
  n = 11 + bits(dat, pos, 127), pos += 7;
1129
1159
  while (n--)
1130
- ldt[i++] = c;
1160
+ ldt[i2++] = c;
1131
1161
  }
1132
1162
  }
1133
1163
  var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
@@ -1165,8 +1195,8 @@ var inflt = function(dat, st, buf, dict) {
1165
1195
  } else {
1166
1196
  var add = sym - 254;
1167
1197
  if (sym > 264) {
1168
- var i = sym - 257, b = fleb[i];
1169
- add = bits(dat, pos, (1 << b) - 1) + fl[i];
1198
+ var i2 = sym - 257, b = fleb[i2];
1199
+ add = bits(dat, pos, (1 << b) - 1) + fl[i2];
1170
1200
  pos += b;
1171
1201
  }
1172
1202
  var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
@@ -1224,26 +1254,26 @@ try {
1224
1254
  } catch (e) {
1225
1255
  }
1226
1256
  var dutf8 = function(d) {
1227
- for (var r = "", i = 0; ; ) {
1228
- var c = d[i++];
1257
+ for (var r = "", i2 = 0; ; ) {
1258
+ var c = d[i2++];
1229
1259
  var eb = (c > 127) + (c > 223) + (c > 239);
1230
- if (i + eb > d.length)
1231
- return { s: r, r: slc(d, i - 1) };
1260
+ if (i2 + eb > d.length)
1261
+ return { s: r, r: slc(d, i2 - 1) };
1232
1262
  if (!eb)
1233
1263
  r += String.fromCharCode(c);
1234
1264
  else if (eb == 3) {
1235
- c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | d[i++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
1265
+ c = ((c & 15) << 18 | (d[i2++] & 63) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
1236
1266
  } else if (eb & 1)
1237
- r += String.fromCharCode((c & 31) << 6 | d[i++] & 63);
1267
+ r += String.fromCharCode((c & 31) << 6 | d[i2++] & 63);
1238
1268
  else
1239
- r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | d[i++] & 63);
1269
+ r += String.fromCharCode((c & 15) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63);
1240
1270
  }
1241
1271
  };
1242
1272
  function strFromU8(dat, latin1) {
1243
1273
  if (latin1) {
1244
1274
  var r = "";
1245
- for (var i = 0; i < dat.length; i += 16384)
1246
- r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
1275
+ for (var i2 = 0; i2 < dat.length; i2 += 16384)
1276
+ r += String.fromCharCode.apply(null, dat.subarray(i2, i2 + 16384));
1247
1277
  return r;
1248
1278
  } else if (td) {
1249
1279
  return td.decode(dat);
@@ -1303,7 +1333,7 @@ function unzipSync(data, opts) {
1303
1333
  }
1304
1334
  }
1305
1335
  var fltr = opts && opts.filter;
1306
- for (var i = 0; i < c; ++i) {
1336
+ for (var i2 = 0; i2 < c; ++i2) {
1307
1337
  var _a2 = zh(data, o, z), c_2 = _a2[0], sc = _a2[1], su = _a2[2], fn = _a2[3], no = _a2[4], off = _a2[5], b = slzh(data, off);
1308
1338
  o = no;
1309
1339
  if (!fltr || fltr({
@@ -1473,7 +1503,7 @@ async function uploadStaticBundle(graphql, storage, args) {
1473
1503
  const { files, issues } = extractZipFromBuffer(zipBytes);
1474
1504
  if (issues.length > 0) {
1475
1505
  throw new Error(
1476
- `upload_static_bundle: rejected bundle path(s): ${issues.map((i) => `${i.path} (${i.reason})`).join("; ")}`
1506
+ `upload_static_bundle: rejected bundle path(s): ${issues.map((i2) => `${i2.path} (${i2.reason})`).join("; ")}`
1477
1507
  );
1478
1508
  }
1479
1509
  if (files.length === 0) {
@@ -1482,7 +1512,7 @@ async function uploadStaticBundle(graphql, storage, args) {
1482
1512
  const contentIssues = validateBundle(files);
1483
1513
  if (contentIssues.length > 0) {
1484
1514
  throw new Error(
1485
- `upload_static_bundle: bundle contains absolute / protocol-relative refs: ${contentIssues.map((i) => `${i.path}: ${i.reason}`).join("; ")}`
1515
+ `upload_static_bundle: bundle contains absolute / protocol-relative refs: ${contentIssues.map((i2) => `${i2.path}: ${i2.reason}`).join("; ")}`
1486
1516
  );
1487
1517
  }
1488
1518
  const entrypoint = args.entrypoint ?? pickDefaultEntrypoint(files);
@@ -1493,8 +1523,10 @@ async function uploadStaticBundle(graphql, storage, args) {
1493
1523
  }
1494
1524
  const prefix = bundlePrefix(slug);
1495
1525
  const existing = await storage.listObjects(prefix).catch((err2) => {
1496
- console.error("[upload_static_bundle] listObjects failed (proceeding)", err2);
1497
- return [];
1526
+ console.error("[upload_static_bundle] listObjects failed", err2);
1527
+ throw new Error(
1528
+ `upload_static_bundle: failed to list existing bundle objects for full-prefix wipe: ${err2 instanceof Error ? err2.message : String(err2)}`
1529
+ );
1498
1530
  });
1499
1531
  for (const obj of existing) {
1500
1532
  await storage.deleteObject(obj.key);
@@ -1571,7 +1603,7 @@ async function uploadStaticFile(storage, args) {
1571
1603
  const issues = findAbsolutePathRefs(filename, text);
1572
1604
  if (issues.length > 0) {
1573
1605
  throw new Error(
1574
- `upload_static_file: ${filename} contains absolute / protocol-relative refs: ${issues.map((i) => i.reason).join("; ")}`
1606
+ `upload_static_file: ${filename} contains absolute / protocol-relative refs: ${issues.map((i2) => i2.reason).join("; ")}`
1575
1607
  );
1576
1608
  }
1577
1609
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampless/mcp-server",
3
- "version": "1.0.0-beta.58",
3
+ "version": "1.0.0-beta.60",
4
4
  "description": "MCP tool registry shared by @ampless/backend mcp-handler Lambda. Installed transitively via @ampless/admin / @ampless/backend; no direct install needed.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,7 +26,7 @@
26
26
  "bugs": "https://github.com/heavymoons/ampless/issues",
27
27
  "dependencies": {
28
28
  "fflate": "^0.8.3",
29
- "ampless": "1.0.0-beta.52"
29
+ "ampless": "1.0.0-beta.54"
30
30
  },
31
31
  "keywords": [
32
32
  "ampless",