@fload-ai/mcp 0.7.0 → 0.9.0

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/bin.js CHANGED
@@ -468,7 +468,7 @@ var getMetricsSchema = z4.object({
468
468
  endDate: z4.string().optional().describe("End date (YYYY-MM-DD). Defaults to today."),
469
469
  granularity: z4.enum(["daily", "weekly", "monthly"]).default("daily").describe("Data granularity"),
470
470
  dimension: z4.string().optional().describe(
471
- 'Optional dimension to break down by (e.g., "storefront" for country, "platform" for device). Use discover_dimensions to see options.'
471
+ 'Optional dimension to break down by (e.g., "storefront" for country, "platform" for device). Use discover_dimensions to see options. Each metric then carries `breakdown`: the period value, share and change of every value, aggregated for the metric type (read its `basis`: "latest" is the last day, never a sum; "daily_average" is an average a day, never a period total). Answer per-country questions from `breakdown`, never by adding up `timeseries`, which keeps only the top values each day.'
472
472
  ),
473
473
  dimensionFilter: z4.string().optional().describe(
474
474
  'Filter to a specific dimension value (e.g., "US" when dimension is "storefront")'
@@ -682,7 +682,10 @@ async function getMetrics(input, client) {
682
682
  displayName: info[name]?.displayName || name,
683
683
  type: info[name]?.type || "count",
684
684
  summary: summaries[name],
685
- change: changes[name] || null
685
+ change: changes[name] || null,
686
+ ...input.dimension && {
687
+ breakdown: summaryResponse.breakdownTotals?.[name] ?? null
688
+ }
686
689
  })),
687
690
  timeseries: data,
688
691
  meta
@@ -1221,6 +1224,14 @@ var checkActionNowSchema = z8.object({
1221
1224
  'The inbox item ID to check now (from list_pending_actions with view "queued", or an approve_action result; its commands include check_now)'
1222
1225
  )
1223
1226
  });
1227
+ var renameCustomPageActionSchema = z8.object({
1228
+ actionId: z8.string().describe(
1229
+ 'The inbox item ID of the "Create custom product page" request (from list_pending_actions; it failed because App Store Connect already has a page of that name, or it waits for approval)'
1230
+ ),
1231
+ name: z8.string().trim().min(1).max(100).describe(
1232
+ "The new page name: at most 100 characters (UTF-16 units), not its current name, not a page the app already has"
1233
+ )
1234
+ });
1224
1235
  function commandFor(kind, intent) {
1225
1236
  if (kind === "notice")
1226
1237
  return intent === "approve" ? "acknowledge" : "dismiss";
@@ -1298,18 +1309,18 @@ async function approveAction(input, client) {
1298
1309
  input.actionId,
1299
1310
  "approve"
1300
1311
  );
1301
- const applied = result?.result === "applied" || result?.result === "replayed";
1312
+ const applied2 = result?.result === "applied" || result?.result === "replayed";
1302
1313
  return toolText(
1303
1314
  {
1304
- success: applied,
1315
+ success: applied2,
1305
1316
  actionId: input.actionId,
1306
1317
  command,
1307
1318
  result: result?.result ?? "unknown",
1308
1319
  ...result?.error ? { error: result.error } : {},
1309
- message: applied ? command === "acknowledge" ? "Acknowledged." : "Approved. Fload delivers it after a short undo window; the inbox shows where it is." : result?.error ?? "The approval could not be recorded.",
1320
+ message: applied2 ? command === "acknowledge" ? "Acknowledged." : "Approved. Fload delivers it after a short undo window; the inbox shows where it is." : result?.error ?? "The approval could not be recorded.",
1310
1321
  item: result?.item
1311
1322
  },
1312
- !applied
1323
+ !applied2
1313
1324
  );
1314
1325
  } catch (error) {
1315
1326
  return toolError(error);
@@ -1323,18 +1334,18 @@ async function rejectAction(input, client) {
1323
1334
  "reject",
1324
1335
  input.reason
1325
1336
  );
1326
- const applied = result?.result === "applied" || result?.result === "replayed";
1337
+ const applied2 = result?.result === "applied" || result?.result === "replayed";
1327
1338
  return toolText(
1328
1339
  {
1329
- success: applied,
1340
+ success: applied2,
1330
1341
  actionId: input.actionId,
1331
1342
  command,
1332
1343
  result: result?.result ?? "unknown",
1333
1344
  ...result?.error ? { error: result.error } : {},
1334
- message: applied ? command === "dismiss" ? "Dismissed." : "Rejected. Nothing was sent." : result?.error ?? "The rejection could not be recorded.",
1345
+ message: applied2 ? command === "dismiss" ? "Dismissed." : "Rejected. Nothing was sent." : result?.error ?? "The rejection could not be recorded.",
1335
1346
  item: result?.item
1336
1347
  },
1337
- !applied
1348
+ !applied2
1338
1349
  );
1339
1350
  } catch (error) {
1340
1351
  return toolError(error);
@@ -1351,19 +1362,104 @@ async function checkActionNow(input, client) {
1351
1362
  }
1352
1363
  );
1353
1364
  const result = answer.body?.results?.[0];
1354
- const applied = result?.result === "applied" || result?.result === "replayed";
1365
+ const applied2 = result?.result === "applied" || result?.result === "replayed";
1355
1366
  const error = result?.error ? publicMcpErrorMessage(result.error, "Fload could not check it now.") : void 0;
1356
1367
  return toolText(
1357
1368
  {
1358
- success: applied,
1369
+ success: applied2,
1359
1370
  actionId: input.actionId,
1360
1371
  command: "check_now",
1361
1372
  result: result?.result ?? "unknown",
1362
1373
  ...error ? { error } : {},
1363
- message: applied ? "Fload is checking the store now; the item updates as soon as the store shows the change." : error ?? (answer.ok ? "Fload returned no result for the command." : "Fload rejected the request. Please check access and try again."),
1374
+ message: applied2 ? "Fload is checking the store now; the item updates as soon as the store shows the change." : error ?? (answer.ok ? "Fload returned no result for the command." : "Fload rejected the request. Please check access and try again."),
1364
1375
  item: result?.item
1365
1376
  },
1366
- !applied
1377
+ !applied2
1378
+ );
1379
+ } catch (error) {
1380
+ return toolError(error);
1381
+ }
1382
+ }
1383
+ var applied = (result) => result?.result === "applied" || result?.result === "replayed";
1384
+ async function sendItemCommand(client, body) {
1385
+ const { command, itemId, revisionId, ...extra } = body;
1386
+ const answer = await client.postForAnswer(
1387
+ "/api/actions/commands",
1388
+ {
1389
+ command,
1390
+ idempotencyKey: `mcp:${command}:${itemId}:${randomUUID()}`,
1391
+ targets: [{ itemId, ...revisionId ? { revisionId } : {} }],
1392
+ ...extra
1393
+ }
1394
+ );
1395
+ const result = answer.body?.results?.[0];
1396
+ if (applied(result)) return { result, refusal: null };
1397
+ const said = result?.error ?? answer.body?.message;
1398
+ return {
1399
+ result,
1400
+ refusal: publicMcpErrorMessage(
1401
+ said,
1402
+ answer.ok ? "Fload returned no result for the command." : "Fload rejected the request. Please check access and try again."
1403
+ )
1404
+ };
1405
+ }
1406
+ function renameAnswer(input, outcome, item) {
1407
+ const success = outcome.renamed && outcome.approved;
1408
+ return toolText(
1409
+ {
1410
+ success,
1411
+ actionId: input.actionId,
1412
+ ...outcome,
1413
+ ...item === void 0 ? {} : { item }
1414
+ },
1415
+ !success
1416
+ );
1417
+ }
1418
+ async function renameCustomPageAction(input, client) {
1419
+ try {
1420
+ const name = input.name.trim();
1421
+ const detail = await client.get(
1422
+ `/api/actions/items/${encodeURIComponent(input.actionId)}`
1423
+ );
1424
+ const item = detail.item;
1425
+ if (!item || item.kind !== "asc_custom_product_page" || !item.subjectKey?.startsWith("asc-cpp:"))
1426
+ return renameAnswer(input, {
1427
+ renamed: false,
1428
+ approved: false,
1429
+ message: "This item is not a request to create a custom product page."
1430
+ });
1431
+ const edit = await sendItemCommand(client, {
1432
+ command: "edit",
1433
+ itemId: item.id,
1434
+ revisionId: item.currentRevisionId,
1435
+ pageName: name
1436
+ });
1437
+ if (edit.refusal)
1438
+ return renameAnswer(input, {
1439
+ renamed: false,
1440
+ approved: false,
1441
+ message: edit.refusal
1442
+ });
1443
+ const renamed = edit.result?.item;
1444
+ const approve = await sendItemCommand(client, {
1445
+ command: "approve",
1446
+ itemId: item.id,
1447
+ revisionId: renamed?.currentRevisionId ?? null
1448
+ });
1449
+ return renameAnswer(
1450
+ input,
1451
+ approve.refusal ? {
1452
+ renamed: true,
1453
+ approved: false,
1454
+ // The server's own refusal, as it said it.
1455
+ message: approve.refusal,
1456
+ next: `The page is renamed to \u201C${name}\u201D and waits for approval (approve_action).`
1457
+ } : {
1458
+ renamed: true,
1459
+ approved: true,
1460
+ message: `Renamed to \u201C${name}\u201D and approved. Fload creates the page after a short undo window; the inbox shows where it is.`
1461
+ },
1462
+ approve.result?.item ?? renamed
1367
1463
  );
1368
1464
  } catch (error) {
1369
1465
  return toolError(error);
@@ -1978,6 +2074,14 @@ function registerTools(server, client, options = {}) {
1978
2074
  checkActionNow,
1979
2075
  { readOnlyHint: false, destructiveHint: false, openWorldHint: true }
1980
2076
  );
2077
+ tool(
2078
+ "rename_custom_page_action",
2079
+ "Rename a custom product page request and send it",
2080
+ 'For a "Create custom product page" inbox item (actionId from list_pending_actions) that App Store Connect refused because the app already has a page of that name, or one still waiting for approval: rename it (name: at most 100 characters, not its current name, not a page the app already has) and approve it again on the same item. Fload then creates the page under the new name after a short undo window. Treat as destructive: it creates a page in App Store Connect. If the approve is refused, the item keeps its new name and waits for approval.',
2081
+ renameCustomPageActionSchema,
2082
+ renameCustomPageAction,
2083
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: true }
2084
+ );
1981
2085
  tool(
1982
2086
  "get_aso_summary",
1983
2087
  "Get ASO summary",