@fload-ai/mcp 0.8.0 → 0.10.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/index.js CHANGED
@@ -548,7 +548,7 @@ var getMetricsSchema = z3.object({
548
548
  endDate: z3.string().optional().describe("End date (YYYY-MM-DD). Defaults to today."),
549
549
  granularity: z3.enum(["daily", "weekly", "monthly"]).default("daily").describe("Data granularity"),
550
550
  dimension: z3.string().optional().describe(
551
- 'Optional dimension to break down by (e.g., "storefront" for country, "platform" for device). Use discover_dimensions to see options.'
551
+ '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.'
552
552
  ),
553
553
  dimensionFilter: z3.string().optional().describe(
554
554
  'Filter to a specific dimension value (e.g., "US" when dimension is "storefront")'
@@ -762,7 +762,10 @@ async function getMetrics(input, client) {
762
762
  displayName: info[name]?.displayName || name,
763
763
  type: info[name]?.type || "count",
764
764
  summary: summaries[name],
765
- change: changes[name] || null
765
+ change: changes[name] || null,
766
+ ...input.dimension && {
767
+ breakdown: summaryResponse.breakdownTotals?.[name] ?? null
768
+ }
766
769
  })),
767
770
  timeseries: data,
768
771
  meta
@@ -826,8 +829,58 @@ async function discoverDimensions(input, client) {
826
829
  }
827
830
  }
828
831
 
829
- // src/tools/agents.ts
832
+ // src/tools/download-impact.ts
830
833
  import { z as z4 } from "zod";
834
+ var Day = z4.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional();
835
+ var getDownloadImpactSchema = z4.object({
836
+ assetId: z4.string().uuid().describe("App UUID (App Store apps)"),
837
+ from: Day.describe(
838
+ "First day drawn (YYYY-MM-DD); default 20 weeks before `to`"
839
+ ),
840
+ to: Day.describe(
841
+ "Last day drawn (YYYY-MM-DD); default the newest day with data"
842
+ ),
843
+ beforeFrom: Day.describe(
844
+ 'Start of the "before" window compared (needs beforeTo; all windows within 400 days of each other)'
845
+ ),
846
+ beforeTo: Day.describe('End of the "before" window compared'),
847
+ afterFrom: Day.describe(
848
+ 'Start of the "after" window compared (needs afterTo)'
849
+ ),
850
+ afterTo: Day.describe('End of the "after" window compared'),
851
+ country: z4.string().regex(/^[a-zA-Z]{2}$/).optional().describe(
852
+ 'One storefront, two-letter code (e.g. "us"): narrows countries and keywords'
853
+ ),
854
+ includeDays: z4.boolean().optional().describe("Also return every day (long). Weeks carry the same downloads.")
855
+ });
856
+ async function getDownloadImpact(input, client) {
857
+ try {
858
+ const { assetId, includeDays, ...query } = input;
859
+ const impact = await client.get(
860
+ `/api/assets/${assetId}/metrics/download-impact`,
861
+ query
862
+ );
863
+ const { days, lastYearDays, ...rest } = impact;
864
+ return {
865
+ content: [
866
+ {
867
+ type: "text",
868
+ text: formatAsJson(
869
+ includeDays ? { ...rest, days, lastYearDays } : rest
870
+ )
871
+ }
872
+ ]
873
+ };
874
+ } catch (error) {
875
+ return {
876
+ content: [{ type: "text", text: formatError(error) }],
877
+ isError: true
878
+ };
879
+ }
880
+ }
881
+
882
+ // src/tools/agents.ts
883
+ import { z as z5 } from "zod";
831
884
  function asRecord(value) {
832
885
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
833
886
  }
@@ -836,28 +889,28 @@ var AGENT_DESCRIPTIONS = {
836
889
  review: "AI-powered review management \u2014 drafts and sends replies to app store reviews",
837
890
  aso: "App Store Optimization \u2014 listing optimization suggestions for better visibility"
838
891
  };
839
- var listAgentsSchema = z4.object({});
840
- var getAgentDetailsSchema = z4.object({
841
- agentType: z4.enum(AGENT_TYPES).describe("The type of agent to get details for"),
842
- assetId: z4.string().uuid().optional().describe("App UUID to get agent config for (when agent is per-asset)")
892
+ var listAgentsSchema = z5.object({});
893
+ var getAgentDetailsSchema = z5.object({
894
+ agentType: z5.enum(AGENT_TYPES).describe("The type of agent to get details for"),
895
+ assetId: z5.string().uuid().optional().describe("App UUID to get agent config for (when agent is per-asset)")
843
896
  });
844
- var getAgentRunHistorySchema = z4.object({
845
- agentType: z4.enum(AGENT_TYPES).describe("The type of agent to get run history for"),
846
- assetId: z4.string().uuid().optional().describe("App UUID to filter runs"),
847
- limit: z4.number().int().min(1).max(100).default(20).describe("Maximum number of runs to return")
897
+ var getAgentRunHistorySchema = z5.object({
898
+ agentType: z5.enum(AGENT_TYPES).describe("The type of agent to get run history for"),
899
+ assetId: z5.string().uuid().optional().describe("App UUID to filter runs"),
900
+ limit: z5.number().int().min(1).max(100).default(20).describe("Maximum number of runs to return")
848
901
  });
849
- var triggerAgentRunSchema = z4.object({
850
- agentId: z4.string().describe("The agent ID to trigger a run for (the `id` from list_agents)"),
851
- assetId: z4.string().uuid().optional().describe("Optional app UUID to run the agent against")
902
+ var triggerAgentRunSchema = z5.object({
903
+ agentId: z5.string().describe("The agent ID to trigger a run for (the `id` from list_agents)"),
904
+ assetId: z5.string().uuid().optional().describe("Optional app UUID to run the agent against")
852
905
  });
853
- var pauseAgentSchema = z4.object({
854
- agentId: z4.string().describe("The agent ID to pause (the `id` from list_agents)")
906
+ var pauseAgentSchema = z5.object({
907
+ agentId: z5.string().describe("The agent ID to pause (the `id` from list_agents)")
855
908
  });
856
- var resumeAgentSchema = z4.object({
857
- agentId: z4.string().describe("The agent ID to resume (the `id` from list_agents)")
909
+ var resumeAgentSchema = z5.object({
910
+ agentId: z5.string().describe("The agent ID to resume (the `id` from list_agents)")
858
911
  });
859
- var getAgentActivitySchema = z4.object({
860
- agentId: z4.string().describe("The agent ID to get activity for (the `id` from list_agents)")
912
+ var getAgentActivitySchema = z5.object({
913
+ agentId: z5.string().describe("The agent ID to get activity for (the `id` from list_agents)")
861
914
  });
862
915
  async function listAgents(_input, client) {
863
916
  try {
@@ -1115,13 +1168,13 @@ async function getAgentActivity(input, client) {
1115
1168
  }
1116
1169
 
1117
1170
  // src/tools/ads.ts
1118
- import { z as z5 } from "zod";
1119
- var getAdsPerformanceSchema = z5.object({
1120
- assetId: z5.string().uuid().optional().describe("Filter by app UUID"),
1121
- platform: z5.enum(["apple_search_ads", "google_ads", "meta_ads", "tiktok_ads"]).optional().describe("Filter by ad platform"),
1122
- fromDate: z5.string().optional().describe("Start date for performance data (YYYY-MM-DD)"),
1123
- toDate: z5.string().optional().describe("End date for performance data (YYYY-MM-DD)"),
1124
- limit: z5.number().int().min(1).max(100).default(50).describe("Maximum number of campaigns to return")
1171
+ import { z as z6 } from "zod";
1172
+ var getAdsPerformanceSchema = z6.object({
1173
+ assetId: z6.string().uuid().optional().describe("Filter by app UUID"),
1174
+ platform: z6.enum(["apple_search_ads", "google_ads", "meta_ads", "tiktok_ads"]).optional().describe("Filter by ad platform"),
1175
+ fromDate: z6.string().optional().describe("Start date for performance data (YYYY-MM-DD)"),
1176
+ toDate: z6.string().optional().describe("End date for performance data (YYYY-MM-DD)"),
1177
+ limit: z6.number().int().min(1).max(100).default(50).describe("Maximum number of campaigns to return")
1125
1178
  });
1126
1179
  async function getAdsPerformance(input, client) {
1127
1180
  try {
@@ -1187,7 +1240,7 @@ async function getAdsPerformance(input, client) {
1187
1240
  }
1188
1241
 
1189
1242
  // src/tools/dashboard.ts
1190
- import { z as z6 } from "zod";
1243
+ import { z as z7 } from "zod";
1191
1244
  function parseDashboardNumber(value) {
1192
1245
  if (value === null || value === void 0 || value === "") return null;
1193
1246
  const parsed = typeof value === "number" ? value : Number.parseFloat(value);
@@ -1198,7 +1251,7 @@ function getSidebarAssets(response) {
1198
1251
  if (Array.isArray(response)) return response;
1199
1252
  return response.data ?? [];
1200
1253
  }
1201
- var getDashboardOverviewSchema = z6.object({});
1254
+ var getDashboardOverviewSchema = z7.object({});
1202
1255
  async function getDashboardOverview(_input, client) {
1203
1256
  try {
1204
1257
  const overviewPromise = client.get("/api/dashboard/overview-metrics").catch(() => null);
@@ -1254,33 +1307,33 @@ async function getDashboardOverview(_input, client) {
1254
1307
 
1255
1308
  // src/tools/actions.ts
1256
1309
  import { randomUUID } from "node:crypto";
1257
- import { z as z7 } from "zod";
1258
- var listPendingActionsSchema = z7.object({
1259
- assetId: z7.string().uuid().optional().describe("Filter by app UUID"),
1260
- view: z7.enum(["open", "queued"]).default("open").describe(
1310
+ import { z as z8 } from "zod";
1311
+ var listPendingActionsSchema = z8.object({
1312
+ assetId: z8.string().uuid().optional().describe("Filter by app UUID"),
1313
+ view: z8.enum(["open", "queued"]).default("open").describe(
1261
1314
  "open (default): items waiting on the user. queued: approved work Fload is sending or checking in the store (an item being checked offers check_now)."
1262
1315
  ),
1263
- limit: z7.number().int().min(1).max(100).default(50).describe("Maximum number of actions to return")
1316
+ limit: z8.number().int().min(1).max(100).default(50).describe("Maximum number of actions to return")
1264
1317
  });
1265
- var approveActionSchema = z7.object({
1266
- actionId: z7.string().describe("The inbox item ID to approve (from list_pending_actions)")
1318
+ var approveActionSchema = z8.object({
1319
+ actionId: z8.string().describe("The inbox item ID to approve (from list_pending_actions)")
1267
1320
  });
1268
- var rejectActionSchema = z7.object({
1269
- actionId: z7.string().describe("The inbox item ID to reject (from list_pending_actions)"),
1270
- reason: z7.string().trim().min(1).max(1e3).optional().describe(
1321
+ var rejectActionSchema = z8.object({
1322
+ actionId: z8.string().describe("The inbox item ID to reject (from list_pending_actions)"),
1323
+ reason: z8.string().trim().min(1).max(1e3).optional().describe(
1271
1324
  "Why, in the user's words. Kept with the rejection so the agents do not propose the same thing again."
1272
1325
  )
1273
1326
  });
1274
- var checkActionNowSchema = z7.object({
1275
- actionId: z7.string().describe(
1327
+ var checkActionNowSchema = z8.object({
1328
+ actionId: z8.string().describe(
1276
1329
  'The inbox item ID to check now (from list_pending_actions with view "queued", or an approve_action result; its commands include check_now)'
1277
1330
  )
1278
1331
  });
1279
- var renameCustomPageActionSchema = z7.object({
1280
- actionId: z7.string().describe(
1332
+ var renameCustomPageActionSchema = z8.object({
1333
+ actionId: z8.string().describe(
1281
1334
  '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)'
1282
1335
  ),
1283
- name: z7.string().trim().min(1).max(100).describe(
1336
+ name: z8.string().trim().min(1).max(100).describe(
1284
1337
  "The new page name: at most 100 characters (UTF-16 units), not its current name, not a page the app already has"
1285
1338
  )
1286
1339
  });
@@ -1354,6 +1407,11 @@ async function commandItem(client, itemId, intent, reason) {
1354
1407
  }
1355
1408
  };
1356
1409
  }
1410
+ function refusedMessage(result) {
1411
+ const said = result?.error ?? "The approval could not be recorded.";
1412
+ const check = result?.policyRefusal?.check;
1413
+ return check ? `Stopped by the ${check}: ${said}` : said;
1414
+ }
1357
1415
  async function approveAction(input, client) {
1358
1416
  try {
1359
1417
  const { command, result } = await commandItem(
@@ -1369,7 +1427,7 @@ async function approveAction(input, client) {
1369
1427
  command,
1370
1428
  result: result?.result ?? "unknown",
1371
1429
  ...result?.error ? { error: result.error } : {},
1372
- 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.",
1430
+ message: applied2 ? command === "acknowledge" ? "Acknowledged." : "Approved. Fload delivers it after a short undo window; the inbox shows where it is." : refusedMessage(result),
1373
1431
  item: result?.item
1374
1432
  },
1375
1433
  !applied2
@@ -1519,22 +1577,22 @@ async function renameCustomPageAction(input, client) {
1519
1577
  }
1520
1578
 
1521
1579
  // src/tools/aso.ts
1522
- import { z as z8 } from "zod";
1523
- var getAsoSummarySchema = z8.object({
1524
- assetId: z8.string().uuid().describe("App UUID to get ASO summary for")
1580
+ import { z as z9 } from "zod";
1581
+ var getAsoSummarySchema = z9.object({
1582
+ assetId: z9.string().uuid().describe("App UUID to get ASO summary for")
1525
1583
  });
1526
- var getAsoRecommendationsSchema = z8.object({
1527
- assetId: z8.string().uuid().describe("App UUID to get ASO recommendations for")
1584
+ var getAsoRecommendationsSchema = z9.object({
1585
+ assetId: z9.string().uuid().describe("App UUID to get ASO recommendations for")
1528
1586
  });
1529
- var getAsoKeywordsSchema = z8.object({
1530
- assetId: z8.string().uuid().describe("App UUID to get keyword intelligence for"),
1531
- locale: z8.string().optional().describe(
1587
+ var getAsoKeywordsSchema = z9.object({
1588
+ assetId: z9.string().uuid().describe("App UUID to get keyword intelligence for"),
1589
+ locale: z9.string().optional().describe(
1532
1590
  'Locale code to filter keywords (e.g., "en-US", "de-DE"). Returns all locales if omitted.'
1533
1591
  )
1534
1592
  });
1535
- var getAsoExperimentsSchema = z8.object({
1536
- assetId: z8.string().uuid().describe("App UUID to list ASO experiments for"),
1537
- status: z8.enum([
1593
+ var getAsoExperimentsSchema = z9.object({
1594
+ assetId: z9.string().uuid().describe("App UUID to list ASO experiments for"),
1595
+ status: z9.enum([
1538
1596
  "proposed",
1539
1597
  "approved",
1540
1598
  "applied",
@@ -1542,22 +1600,22 @@ var getAsoExperimentsSchema = z8.object({
1542
1600
  "completed",
1543
1601
  "reverted"
1544
1602
  ]).optional().describe("Filter experiments by status"),
1545
- limit: z8.number().int().min(1).max(100).default(20).describe("Maximum number of experiments to return"),
1546
- cursor: z8.string().optional().describe("Pagination cursor from a previous response (meta.nextCursor)")
1603
+ limit: z9.number().int().min(1).max(100).default(20).describe("Maximum number of experiments to return"),
1604
+ cursor: z9.string().optional().describe("Pagination cursor from a previous response (meta.nextCursor)")
1547
1605
  });
1548
- var getAsoLocaleSnapshotsSchema = z8.object({
1549
- assetId: z8.string().uuid().describe("App UUID to get locale snapshots for"),
1550
- store: z8.enum(["ios", "android"]).default("ios").describe("Which store listing to read"),
1551
- locale: z8.string().optional().describe(
1606
+ var getAsoLocaleSnapshotsSchema = z9.object({
1607
+ assetId: z9.string().uuid().describe("App UUID to get locale snapshots for"),
1608
+ store: z9.enum(["ios", "android"]).default("ios").describe("Which store listing to read"),
1609
+ locale: z9.string().optional().describe(
1552
1610
  'Filter to a single locale (e.g. "en-US"). Returns all locales if omitted.'
1553
1611
  ),
1554
- view: z8.enum(["latest", "history"]).default("latest").describe(
1612
+ view: z9.enum(["latest", "history"]).default("latest").describe(
1555
1613
  '"latest" (default) = newest snapshot per (locale, type); "history" = raw revisions newest first'
1556
1614
  ),
1557
- limit: z8.number().int().min(1).max(500).optional().describe("Maximum snapshot rows to return (newest first)")
1615
+ limit: z9.number().int().min(1).max(500).optional().describe("Maximum snapshot rows to return (newest first)")
1558
1616
  });
1559
- var triggerAsoAnalysisSchema = z8.object({
1560
- assetId: z8.string().uuid().describe("App UUID to trigger ASO analysis for")
1617
+ var triggerAsoAnalysisSchema = z9.object({
1618
+ assetId: z9.string().uuid().describe("App UUID to trigger ASO analysis for")
1561
1619
  });
1562
1620
  async function getAsoSummary(input, client) {
1563
1621
  try {
@@ -1725,7 +1783,7 @@ async function triggerAsoAnalysis(input, client) {
1725
1783
  };
1726
1784
  }
1727
1785
  }
1728
- var getAsoEvidenceSchema = z8.object({ assetId: z8.string().uuid() });
1786
+ var getAsoEvidenceSchema = z9.object({ assetId: z9.string().uuid() });
1729
1787
  async function getAsoEvidence(input, client) {
1730
1788
  try {
1731
1789
  const response = await client.get(
@@ -1744,19 +1802,19 @@ async function getAsoEvidence(input, client) {
1744
1802
 
1745
1803
  // src/tools/chat.ts
1746
1804
  import { randomUUID as randomUUID2 } from "node:crypto";
1747
- import { z as z9 } from "zod";
1748
- var listConversationsSchema = z9.object({
1749
- limit: z9.number().int().min(1).max(100).default(20).describe("Maximum number of conversations to return")
1805
+ import { z as z10 } from "zod";
1806
+ var listConversationsSchema = z10.object({
1807
+ limit: z10.number().int().min(1).max(100).default(20).describe("Maximum number of conversations to return")
1750
1808
  });
1751
- var getConversationMessagesSchema = z9.object({
1752
- conversationId: z9.string().uuid().describe("The conversation UUID to get messages for")
1809
+ var getConversationMessagesSchema = z10.object({
1810
+ conversationId: z10.string().uuid().describe("The conversation UUID to get messages for")
1753
1811
  });
1754
- var sendChatMessageSchema = z9.object({
1755
- message: z9.string().describe("The message to send to the AI chat"),
1756
- conversationId: z9.string().uuid().optional().describe(
1812
+ var sendChatMessageSchema = z10.object({
1813
+ message: z10.string().describe("The message to send to the AI chat"),
1814
+ conversationId: z10.string().uuid().optional().describe(
1757
1815
  "Existing conversation UUID to continue. Starts a new conversation if omitted."
1758
1816
  ),
1759
- agentType: z9.string().optional().describe(
1817
+ agentType: z10.string().optional().describe(
1760
1818
  "Agent type to use for the conversation (e.g., review, monitoring)"
1761
1819
  )
1762
1820
  });
@@ -2012,6 +2070,14 @@ function registerTools(server, client, options = {}) {
2012
2070
  discoverDimensions,
2013
2071
  { readOnlyHint: true, openWorldHint: false }
2014
2072
  );
2073
+ tool(
2074
+ "get_download_impact",
2075
+ "Get what Fload changed on downloads",
2076
+ "Did Fload's listing changes move downloads, overall or in one country? For an App Store app: downloads by source a week (organicSearch = App Store search minus Apple Ads, appleAds, browse, appReferrer, webReferrer, other, total) with the same days last year (364 days back) and an index of each year to its own first four weeks; markers for releases, each Fload listing change on the day written and the day live (with the storefronts that read its locales) and the iOS launch week; the 21 days before Fload's first change against the latest 21 days; storefronts by role (changed: a changed localization is its own language; reads_changed: it also reads one, e.g. the US reads es-MX; control: reads nothing changed) with organic downloads a day before and after, this year and last; and each touched keyword's median rank before and after. Listing changes can only move organic App Store search: judge them on organicSearch against last year, never on total, paid or browse. Null means unknown, never 0.",
2077
+ getDownloadImpactSchema,
2078
+ getDownloadImpact,
2079
+ { readOnlyHint: true, openWorldHint: false }
2080
+ );
2015
2081
  tool(
2016
2082
  "list_agents",
2017
2083
  "List agents",
@@ -2232,10 +2298,10 @@ async function createMcpServer(_config, client) {
2232
2298
  import { readFileSync, existsSync } from "fs";
2233
2299
  import { homedir } from "os";
2234
2300
  import { join } from "path";
2235
- import { z as z10 } from "zod";
2236
- var ConfigFileSchema = z10.object({
2237
- apiKey: z10.string().optional().catch(void 0),
2238
- apiUrl: z10.string().optional().catch(void 0)
2301
+ import { z as z11 } from "zod";
2302
+ var ConfigFileSchema = z11.object({
2303
+ apiKey: z11.string().optional().catch(void 0),
2304
+ apiUrl: z11.string().optional().catch(void 0)
2239
2305
  });
2240
2306
  function loadConfig(env = process.env) {
2241
2307
  const apiKey = env.FLOAD_API_KEY;