@pofky/asc-mcp 1.2.0 → 1.8.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.
Files changed (119) hide show
  1. package/LIMITATIONS.md +41 -0
  2. package/README.md +91 -10
  3. package/USER_GUIDE.md +185 -0
  4. package/dist/client.d.ts +5 -0
  5. package/dist/client.d.ts.map +1 -1
  6. package/dist/client.js +58 -1
  7. package/dist/client.js.map +1 -1
  8. package/dist/doctor.d.ts +28 -0
  9. package/dist/doctor.d.ts.map +1 -0
  10. package/dist/doctor.js +178 -0
  11. package/dist/doctor.js.map +1 -0
  12. package/dist/editable.d.ts +9 -0
  13. package/dist/editable.d.ts.map +1 -0
  14. package/dist/editable.js +20 -0
  15. package/dist/editable.js.map +1 -0
  16. package/dist/elicitation.d.ts +39 -0
  17. package/dist/elicitation.d.ts.map +1 -0
  18. package/dist/elicitation.js +63 -0
  19. package/dist/elicitation.js.map +1 -0
  20. package/dist/gate.d.ts +8 -0
  21. package/dist/gate.d.ts.map +1 -0
  22. package/dist/gate.js +17 -0
  23. package/dist/gate.js.map +1 -0
  24. package/dist/index.js +308 -16
  25. package/dist/index.js.map +1 -1
  26. package/dist/license.js +1 -1
  27. package/dist/prompts.d.ts.map +1 -1
  28. package/dist/prompts.js +101 -0
  29. package/dist/prompts.js.map +1 -1
  30. package/dist/sampling.d.ts +53 -0
  31. package/dist/sampling.d.ts.map +1 -0
  32. package/dist/sampling.js +109 -0
  33. package/dist/sampling.js.map +1 -0
  34. package/dist/setup.d.ts +19 -0
  35. package/dist/setup.d.ts.map +1 -0
  36. package/dist/setup.js +153 -0
  37. package/dist/setup.js.map +1 -0
  38. package/dist/tools/age-rating.d.ts +14 -0
  39. package/dist/tools/age-rating.d.ts.map +1 -0
  40. package/dist/tools/age-rating.js +125 -0
  41. package/dist/tools/age-rating.js.map +1 -0
  42. package/dist/tools/app-details.js +2 -2
  43. package/dist/tools/availability.d.ts +20 -0
  44. package/dist/tools/availability.d.ts.map +1 -0
  45. package/dist/tools/availability.js +96 -0
  46. package/dist/tools/availability.js.map +1 -0
  47. package/dist/tools/builds.d.ts +26 -0
  48. package/dist/tools/builds.d.ts.map +1 -0
  49. package/dist/tools/builds.js +108 -0
  50. package/dist/tools/builds.js.map +1 -0
  51. package/dist/tools/draft-review-response.d.ts +37 -0
  52. package/dist/tools/draft-review-response.d.ts.map +1 -0
  53. package/dist/tools/draft-review-response.js +236 -0
  54. package/dist/tools/draft-review-response.js.map +1 -0
  55. package/dist/tools/eu-trader.d.ts +12 -0
  56. package/dist/tools/eu-trader.d.ts.map +1 -0
  57. package/dist/tools/eu-trader.js +25 -0
  58. package/dist/tools/eu-trader.js.map +1 -0
  59. package/dist/tools/guide.d.ts +38 -0
  60. package/dist/tools/guide.d.ts.map +1 -0
  61. package/dist/tools/guide.js +273 -0
  62. package/dist/tools/guide.js.map +1 -0
  63. package/dist/tools/iap.d.ts +43 -0
  64. package/dist/tools/iap.d.ts.map +1 -0
  65. package/dist/tools/iap.js +360 -0
  66. package/dist/tools/iap.js.map +1 -0
  67. package/dist/tools/list-apps.js +1 -1
  68. package/dist/tools/list-reviews.js +2 -2
  69. package/dist/tools/local-build.d.ts +26 -0
  70. package/dist/tools/local-build.d.ts.map +1 -0
  71. package/dist/tools/local-build.js +100 -0
  72. package/dist/tools/local-build.js.map +1 -0
  73. package/dist/tools/privacy.d.ts +15 -0
  74. package/dist/tools/privacy.d.ts.map +1 -0
  75. package/dist/tools/privacy.js +32 -0
  76. package/dist/tools/privacy.js.map +1 -0
  77. package/dist/tools/release-control.d.ts +22 -0
  78. package/dist/tools/release-control.d.ts.map +1 -0
  79. package/dist/tools/release-control.js +85 -0
  80. package/dist/tools/release-control.js.map +1 -0
  81. package/dist/tools/release-preflight.d.ts.map +1 -1
  82. package/dist/tools/release-preflight.js +139 -0
  83. package/dist/tools/release-preflight.js.map +1 -1
  84. package/dist/tools/review-screenshot.d.ts +14 -0
  85. package/dist/tools/review-screenshot.d.ts.map +1 -0
  86. package/dist/tools/review-screenshot.js +72 -0
  87. package/dist/tools/review-screenshot.js.map +1 -0
  88. package/dist/tools/review-status.js +2 -2
  89. package/dist/tools/sales-report.js +3 -3
  90. package/dist/tools/sales-report.js.map +1 -1
  91. package/dist/tools/screenshots.d.ts +15 -0
  92. package/dist/tools/screenshots.d.ts.map +1 -0
  93. package/dist/tools/screenshots.js +106 -0
  94. package/dist/tools/screenshots.js.map +1 -0
  95. package/dist/tools/signing.d.ts +21 -0
  96. package/dist/tools/signing.d.ts.map +1 -0
  97. package/dist/tools/signing.js +101 -0
  98. package/dist/tools/signing.js.map +1 -0
  99. package/dist/tools/submission.d.ts +47 -0
  100. package/dist/tools/submission.d.ts.map +1 -0
  101. package/dist/tools/submission.js +199 -0
  102. package/dist/tools/submission.js.map +1 -0
  103. package/dist/tools/testflight.d.ts +20 -0
  104. package/dist/tools/testflight.d.ts.map +1 -0
  105. package/dist/tools/testflight.js +75 -0
  106. package/dist/tools/testflight.js.map +1 -0
  107. package/dist/tools/triage-reviews.d.ts +35 -0
  108. package/dist/tools/triage-reviews.d.ts.map +1 -0
  109. package/dist/tools/triage-reviews.js +194 -0
  110. package/dist/tools/triage-reviews.js.map +1 -0
  111. package/dist/tools/update-version-metadata.d.ts +17 -0
  112. package/dist/tools/update-version-metadata.d.ts.map +1 -0
  113. package/dist/tools/update-version-metadata.js +148 -0
  114. package/dist/tools/update-version-metadata.js.map +1 -0
  115. package/dist/tools/version-control.d.ts +21 -0
  116. package/dist/tools/version-control.d.ts.map +1 -0
  117. package/dist/tools/version-control.js +144 -0
  118. package/dist/tools/version-control.js.map +1 -0
  119. package/package.json +5 -2
@@ -0,0 +1,53 @@
1
+ /**
2
+ * MCP Sampling helper.
3
+ *
4
+ * Calls `server.createMessage(...)` on the underlying MCP Server so the
5
+ * user's own client runs the LLM request. Zero cost to us (we do not pay
6
+ * for the user's Anthropic tokens).
7
+ *
8
+ * Capability detection: we check the client's declared capabilities at
9
+ * initialize time. If sampling is not advertised, the caller gets a
10
+ * structured `{ unsupported: true }` response and must degrade gracefully.
11
+ */
12
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
13
+ import type { ModelPreferences } from "@modelcontextprotocol/sdk/types.js";
14
+ export type SamplingResult = {
15
+ ok: true;
16
+ text: string;
17
+ model: string;
18
+ stopReason: string | undefined;
19
+ } | {
20
+ ok: false;
21
+ unsupported: true;
22
+ } | {
23
+ ok: false;
24
+ error: string;
25
+ };
26
+ export interface SamplingRequest {
27
+ system?: string;
28
+ user: string;
29
+ maxTokens: number;
30
+ temperature?: number;
31
+ modelPreferences?: ModelPreferences;
32
+ timeoutMs?: number;
33
+ }
34
+ export declare function clientSupportsSampling(server: McpServer): boolean;
35
+ export declare function sample(server: McpServer, req: SamplingRequest): Promise<SamplingResult>;
36
+ export declare const MODEL_HINTS: {
37
+ fast: {
38
+ speedPriority: number;
39
+ costPriority: number;
40
+ intelligencePriority: number;
41
+ };
42
+ balanced: {
43
+ speedPriority: number;
44
+ costPriority: number;
45
+ intelligencePriority: number;
46
+ };
47
+ smart: {
48
+ speedPriority: number;
49
+ costPriority: number;
50
+ intelligencePriority: number;
51
+ };
52
+ };
53
+ //# sourceMappingURL=sampling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampling.d.ts","sourceRoot":"","sources":["../src/sampling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,MAAM,cAAc,GACtB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACzE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,WAAW,EAAE,IAAI,CAAA;CAAE,GAChC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAOjE;AAED,wBAAsB,MAAM,CAC1B,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,cAAc,CAAC,CAuCzB;AAuCD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;CAgBvB,CAAC"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Sampling helper.
4
+ *
5
+ * Calls `server.createMessage(...)` on the underlying MCP Server so the
6
+ * user's own client runs the LLM request. Zero cost to us (we do not pay
7
+ * for the user's Anthropic tokens).
8
+ *
9
+ * Capability detection: we check the client's declared capabilities at
10
+ * initialize time. If sampling is not advertised, the caller gets a
11
+ * structured `{ unsupported: true }` response and must degrade gracefully.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.MODEL_HINTS = void 0;
15
+ exports.clientSupportsSampling = clientSupportsSampling;
16
+ exports.sample = sample;
17
+ const DEFAULT_TIMEOUT_MS = 30_000;
18
+ function clientSupportsSampling(server) {
19
+ try {
20
+ const caps = server.server.getClientCapabilities();
21
+ return Boolean(caps?.sampling);
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ }
27
+ async function sample(server, req) {
28
+ if (!clientSupportsSampling(server)) {
29
+ return { ok: false, unsupported: true };
30
+ }
31
+ const timeoutMs = req.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32
+ const messages = [
33
+ {
34
+ role: "user",
35
+ content: { type: "text", text: req.user },
36
+ },
37
+ ];
38
+ try {
39
+ const result = (await withTimeout(server.server.createMessage({
40
+ messages,
41
+ systemPrompt: req.system,
42
+ maxTokens: req.maxTokens,
43
+ temperature: req.temperature,
44
+ modelPreferences: req.modelPreferences,
45
+ }), timeoutMs));
46
+ const text = extractText(result);
47
+ if (!text) {
48
+ return { ok: false, error: "Sampling returned no text content." };
49
+ }
50
+ return {
51
+ ok: true,
52
+ text,
53
+ model: result.model ?? "unknown",
54
+ stopReason: result.stopReason,
55
+ };
56
+ }
57
+ catch (err) {
58
+ const msg = err instanceof Error ? err.message : String(err);
59
+ return { ok: false, error: msg };
60
+ }
61
+ }
62
+ function extractText(result) {
63
+ const content = result.content;
64
+ if (!content)
65
+ return "";
66
+ if (Array.isArray(content)) {
67
+ const textBlocks = content.filter((b) => typeof b === "object" && b !== null && b.type === "text");
68
+ return textBlocks.map((b) => b.text).join("\n").trim();
69
+ }
70
+ if (typeof content === "object" && content !== null) {
71
+ const maybeBlock = content;
72
+ if (maybeBlock.type === "text" && typeof maybeBlock.text === "string") {
73
+ return maybeBlock.text.trim();
74
+ }
75
+ }
76
+ return "";
77
+ }
78
+ function withTimeout(promise, ms) {
79
+ return new Promise((resolve, reject) => {
80
+ const timer = setTimeout(() => {
81
+ reject(new Error(`Sampling timed out after ${ms}ms`));
82
+ }, ms);
83
+ promise.then((v) => {
84
+ clearTimeout(timer);
85
+ resolve(v);
86
+ }, (e) => {
87
+ clearTimeout(timer);
88
+ reject(e);
89
+ });
90
+ });
91
+ }
92
+ exports.MODEL_HINTS = {
93
+ fast: {
94
+ speedPriority: 0.6,
95
+ costPriority: 0.3,
96
+ intelligencePriority: 0.1,
97
+ },
98
+ balanced: {
99
+ speedPriority: 0.4,
100
+ costPriority: 0.3,
101
+ intelligencePriority: 0.3,
102
+ },
103
+ smart: {
104
+ speedPriority: 0.2,
105
+ costPriority: 0.2,
106
+ intelligencePriority: 0.6,
107
+ },
108
+ };
109
+ //# sourceMappingURL=sampling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampling.js","sourceRoot":"","sources":["../src/sampling.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAwBH,wDAOC;AAED,wBA0CC;AArDD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,SAAgB,sBAAsB,CAAC,MAAiB;IACtD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACnD,OAAO,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,MAAM,CAC1B,MAAiB,EACjB,GAAoB;IAEpB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,kBAAkB,CAAC;IACtD,MAAM,QAAQ,GAAG;QACf;YACE,IAAI,EAAE,MAAe;YACrB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE;SACnD;KACF,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,MAAM,GAAwB,CAAC,MAAM,WAAW,CACpD,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;YAC1B,QAAQ;YACR,YAAY,EAAE,GAAG,CAAC,MAAM;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;SACvC,CAAC,EACF,SAAS,CACV,CAAwB,CAAC;QAE1B,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC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AC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtE,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAI,OAAmB,EAAE,EAAU;IACrD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAC,CAAC;QACxD,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,OAAO,CAAC,IAAI,CACV,CAAC,CAAC,EAAE,EAAE;YACJ,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,EACD,CAAC,CAAC,EAAE,EAAE;YACJ,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAEY,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE;QACJ,aAAa,EAAE,GAAG;QAClB,YAAY,EAAE,GAAG;QACjB,oBAAoB,EAAE,GAAG;KACC;IAC5B,QAAQ,EAAE;QACR,aAAa,EAAE,GAAG;QAClB,YAAY,EAAE,GAAG;QACjB,oBAAoB,EAAE,GAAG;KACC;IAC5B,KAAK,EAAE;QACL,aAAa,EAAE,GAAG;QAClB,YAAY,EAAE,GAAG;QACjB,oBAAoB,EAAE,GAAG;KACC;CAC7B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** Apple's standard, tool-agnostic location for the App Store Connect API key. */
2
+ export declare const STANDARD_KEY_DIR: string;
3
+ export interface DiscoveredKey {
4
+ path: string;
5
+ keyId: string;
6
+ }
7
+ /**
8
+ * Scan the standard ~/.appstoreconnect/private_keys directory for an
9
+ * AuthKey_XXXXXXXXXX.p8 file. The 10-char Key ID is encoded in the filename,
10
+ * so a single dropped file is enough to derive both the path and the Key ID.
11
+ */
12
+ export declare function discoverPrivateKey(dir?: string): DiscoveredKey | null;
13
+ /**
14
+ * Interactive `asc-mcp init`: auto-detect the .p8, ask for the Issuer ID
15
+ * (and optional license key), then print a paste-ready MCP server config.
16
+ * Writes nothing to disk; the user pastes the block into their client config.
17
+ */
18
+ export declare function runInit(write?: boolean): Promise<number>;
19
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAKA,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,QAAsD,CAAC;AAEpF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,SAAmB,GAAG,aAAa,GAAG,IAAI,CAY/E;AAiDD;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA0F5D"}
package/dist/setup.js ADDED
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STANDARD_KEY_DIR = void 0;
4
+ exports.discoverPrivateKey = discoverPrivateKey;
5
+ exports.runInit = runInit;
6
+ const node_fs_1 = require("node:fs");
7
+ const node_os_1 = require("node:os");
8
+ const node_path_1 = require("node:path");
9
+ const node_readline_1 = require("node:readline");
10
+ /** Apple's standard, tool-agnostic location for the App Store Connect API key. */
11
+ exports.STANDARD_KEY_DIR = (0, node_path_1.join)((0, node_os_1.homedir)(), ".appstoreconnect", "private_keys");
12
+ /**
13
+ * Scan the standard ~/.appstoreconnect/private_keys directory for an
14
+ * AuthKey_XXXXXXXXXX.p8 file. The 10-char Key ID is encoded in the filename,
15
+ * so a single dropped file is enough to derive both the path and the Key ID.
16
+ */
17
+ function discoverPrivateKey(dir = exports.STANDARD_KEY_DIR) {
18
+ if (!(0, node_fs_1.existsSync)(dir))
19
+ return null;
20
+ let files;
21
+ try {
22
+ files = (0, node_fs_1.readdirSync)(dir);
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ const match = files.find((f) => /^AuthKey_[A-Z0-9]{10}\.p8$/i.test(f));
28
+ if (!match)
29
+ return null;
30
+ const keyId = match.slice("AuthKey_".length, -".p8".length);
31
+ return { path: (0, node_path_1.join)(dir, match), keyId };
32
+ }
33
+ /** Known client MCP config files, in the order we offer them. */
34
+ function clientConfigCandidates() {
35
+ const home = (0, node_os_1.homedir)();
36
+ return [
37
+ {
38
+ label: "Claude Desktop",
39
+ path: (0, node_path_1.join)(home, "Library", "Application Support", "Claude", "claude_desktop_config.json"),
40
+ },
41
+ { label: "Claude Code (global)", path: (0, node_path_1.join)(home, ".claude.json") },
42
+ { label: "Project-local (.mcp.json in this folder)", path: (0, node_path_1.join)(process.cwd(), ".mcp.json") },
43
+ ];
44
+ }
45
+ /**
46
+ * Merge the asc-mcp server block into an existing client config file without
47
+ * clobbering other servers. Backs up the original to <path>.bak first. Returns a
48
+ * status line for the user.
49
+ */
50
+ function writeServerBlock(path, env) {
51
+ let existing = {};
52
+ if ((0, node_fs_1.existsSync)(path)) {
53
+ try {
54
+ existing = JSON.parse((0, node_fs_1.readFileSync)(path, "utf-8"));
55
+ }
56
+ catch {
57
+ return `Could not parse ${path} (not valid JSON). Left it untouched; paste the block manually.`;
58
+ }
59
+ (0, node_fs_1.copyFileSync)(path, `${path}.bak`);
60
+ }
61
+ const servers = existing.mcpServers ?? {};
62
+ servers["appstore-connect"] = { command: "asc-mcp", env };
63
+ existing.mcpServers = servers;
64
+ (0, node_fs_1.writeFileSync)(path, JSON.stringify(existing, null, 2) + "\n");
65
+ return (0, node_fs_1.existsSync)(`${path}.bak`)
66
+ ? `Wrote ${path} (backup at ${path}.bak). Restart the client.`
67
+ : `Created ${path}. Restart the client.`;
68
+ }
69
+ function prompt(question) {
70
+ const rl = (0, node_readline_1.createInterface)({ input: process.stdin, output: process.stdout });
71
+ return new Promise((resolve) => {
72
+ rl.question(question, (answer) => {
73
+ rl.close();
74
+ resolve(answer.trim());
75
+ });
76
+ });
77
+ }
78
+ /**
79
+ * Interactive `asc-mcp init`: auto-detect the .p8, ask for the Issuer ID
80
+ * (and optional license key), then print a paste-ready MCP server config.
81
+ * Writes nothing to disk; the user pastes the block into their client config.
82
+ */
83
+ async function runInit(write = false) {
84
+ process.stdout.write("\nApp Store Connect MCP setup\n");
85
+ process.stdout.write("─".repeat(40) + "\n\n");
86
+ const discovered = discoverPrivateKey();
87
+ if (discovered) {
88
+ process.stdout.write(`Found API key: ${discovered.path}\n`);
89
+ process.stdout.write(`Key ID: ${discovered.keyId}\n\n`);
90
+ }
91
+ else {
92
+ process.stdout.write("No .p8 found in the standard location.\n" +
93
+ ` 1. App Store Connect > Users and Access > Integrations > App Store Connect API\n` +
94
+ ` 2. Generate an API key with the App Manager role and Download the .p8 (one-time).\n` +
95
+ ` 3. Move it to: ${exports.STANDARD_KEY_DIR}/\n\n`);
96
+ }
97
+ if (!process.stdin.isTTY) {
98
+ process.stdout.write("Non-interactive shell. Set ASC_KEY_ID, ASC_ISSUER_ID, ASC_PRIVATE_KEY_PATH manually.\n");
99
+ return discovered ? 0 : 1;
100
+ }
101
+ const keyId = discovered?.keyId || (await prompt("Key ID (10 chars): "));
102
+ const privateKeyPath = discovered?.path || (await prompt("Path to .p8 file: "));
103
+ const issuerId = await prompt("Issuer ID (UUID at the top of the Integrations page): ");
104
+ const licenseKey = await prompt("Pro license key (optional, press Enter to skip): ");
105
+ const env = {
106
+ ASC_KEY_ID: keyId,
107
+ ASC_ISSUER_ID: issuerId,
108
+ ASC_PRIVATE_KEY_PATH: privateKeyPath,
109
+ };
110
+ if (licenseKey)
111
+ env.ASC_LICENSE_KEY = licenseKey;
112
+ const config = {
113
+ mcpServers: {
114
+ "appstore-connect": {
115
+ command: "asc-mcp",
116
+ env,
117
+ },
118
+ },
119
+ };
120
+ let wrote = false;
121
+ if (write) {
122
+ const candidates = clientConfigCandidates();
123
+ process.stdout.write("\nWhich client config should I write to?\n");
124
+ candidates.forEach((c, i) => {
125
+ const exists = (0, node_fs_1.existsSync)(c.path) ? " (exists)" : "";
126
+ process.stdout.write(` ${i + 1}. ${c.label}: ${c.path}${exists}\n`);
127
+ });
128
+ process.stdout.write(" 0. Skip (just print the block)\n");
129
+ const choice = await prompt("Choice [0]: ");
130
+ const idx = parseInt(choice, 10);
131
+ if (idx >= 1 && idx <= candidates.length) {
132
+ const status = writeServerBlock(candidates[idx - 1].path, env);
133
+ process.stdout.write(`\n${status}\n`);
134
+ wrote = true;
135
+ }
136
+ }
137
+ if (!wrote) {
138
+ process.stdout.write("\nDone. Paste this into your client's MCP config (e.g. Claude Desktop config, or ~/.claude.json):\n\n");
139
+ process.stdout.write(JSON.stringify(config, null, 2) + "\n\n");
140
+ }
141
+ process.stdout.write(licenseKey
142
+ ? "Pro license set, all control tools unlocked.\n"
143
+ : "Free tier (read-only). Add ASC_LICENSE_KEY later to unlock write/control tools.\n");
144
+ process.stdout.write("\nNext steps:\n" +
145
+ (wrote
146
+ ? " 1. Restart your MCP client.\n"
147
+ : " 1. Paste the block above, then restart your MCP client.\n") +
148
+ " 2. Ask your agent to run `asc_setup_check` (or `asc-mcp doctor`) to confirm everything is wired.\n" +
149
+ " 3. Then `list_apps`, and `asc_guide` (topic:overview) for the map of every flow.\n" +
150
+ " 4. Optional: `asc-mcp install-skill` adds the bundled review-triage Claude Skill.\n");
151
+ return 0;
152
+ }
153
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";;;AAkBA,gDAYC;AAsDD,0BA0FC;AA9KD,qCAA6F;AAC7F,qCAAkC;AAClC,yCAAiC;AACjC,iD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G,gBAAgB,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;YACtC,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;IACH,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,uGAAuG,CACxG,CAAC;QACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,UAAU;QACR,CAAC,CAAC,gDAAgD;QAClD,CAAC,CAAC,mFAAmF,CACxF,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,iBAAiB;QACf,CAAC,KAAK;YACJ,CAAC,CAAC,iCAAiC;YACnC,CAAC,CAAC,6DAA6D,CAAC;QAClE,sGAAsG;QACtG,sFAAsF;QACtF,uFAAuF,CAC1F,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ASCClient } from "../client.js";
2
+ import type { Tier } from "../types.js";
3
+ export interface AgeRatingArgs {
4
+ app_id: string;
5
+ /** Map of declaration key to value. Frequency keys take NONE/INFREQUENT_OR_MILD/FREQUENT_OR_INTENSE; boolean keys take true/false. */
6
+ declarations: Record<string, string | boolean>;
7
+ }
8
+ /**
9
+ * Set the app's age-rating declarations. Apple computes the final rating (4+,
10
+ * 9+, 12+, 17+) from these. Example for a wellness app that mentions health
11
+ * topics: { medicalOrTreatmentInformation: "INFREQUENT_OR_MILD" } -> 12+.
12
+ */
13
+ export declare function setAgeRating(client: ASCClient, args: AgeRatingArgs, tier: Tier): Promise<string>;
14
+ //# sourceMappingURL=age-rating.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"age-rating.d.ts","sourceRoot":"","sources":["../../src/tools/age-rating.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAsDxC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,sIAAsI;IACtI,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,MAAM,CAAC,CA0EjB"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setAgeRating = setAgeRating;
4
+ const gate_js_1 = require("../gate.js");
5
+ /**
6
+ * Content-frequency declarations (NONE | INFREQUENT_OR_MILD | FREQUENT_OR_INTENSE).
7
+ * These drive Apple's computed age rating. Anything you don't set keeps its
8
+ * current value, so a fresh app (all null) reads as the lowest rating.
9
+ */
10
+ const FREQUENCY_KEYS = new Set([
11
+ "alcoholTobaccoOrDrugUseOrReferences",
12
+ "contests",
13
+ "gamblingSimulated",
14
+ "horrorOrFearThemes",
15
+ "matureOrSuggestiveThemes",
16
+ "medicalOrTreatmentInformation",
17
+ "profanityOrCrudeHumor",
18
+ "sexualContentGraphicAndNudity",
19
+ "sexualContentOrNudity",
20
+ "violenceCartoonOrFantasy",
21
+ "violenceRealistic",
22
+ "violenceRealisticProlongedGraphicOrSadistic",
23
+ "gunsOrOtherWeapons",
24
+ ]);
25
+ /** Boolean capability declarations (V2 schema). */
26
+ const BOOLEAN_KEYS = new Set([
27
+ "gambling",
28
+ "unrestrictedWebAccess",
29
+ "messagingAndChat",
30
+ "userGeneratedContent",
31
+ "healthOrWellnessTopics",
32
+ "lootBox",
33
+ "advertising",
34
+ "parentalControls",
35
+ "ageAssurance",
36
+ ]);
37
+ /** Override/meta keys: never defaulted, kept at their current value. */
38
+ const KEEP_KEYS = new Set([
39
+ // ageRatingOverride (V1) is deprecated and conflicts with V2; never echo it.
40
+ "ageRatingOverrideV2",
41
+ "koreaAgeRatingOverride",
42
+ "kidsAgeBand",
43
+ "developerAgeRatingInfoUrl",
44
+ ]);
45
+ const FREQUENCY_VALUES = new Set([
46
+ "NONE",
47
+ "INFREQUENT_OR_MILD",
48
+ "FREQUENT_OR_INTENSE",
49
+ "INFREQUENT",
50
+ "FREQUENT",
51
+ ]);
52
+ /**
53
+ * Set the app's age-rating declarations. Apple computes the final rating (4+,
54
+ * 9+, 12+, 17+) from these. Example for a wellness app that mentions health
55
+ * topics: { medicalOrTreatmentInformation: "INFREQUENT_OR_MILD" } -> 12+.
56
+ */
57
+ async function setAgeRating(client, args, tier) {
58
+ const gate = (0, gate_js_1.requirePro)(tier, "Setting the age rating");
59
+ if (gate)
60
+ return gate;
61
+ // Validate keys + values before any write.
62
+ const attributes = {};
63
+ const bad = [];
64
+ for (const [key, value] of Object.entries(args.declarations ?? {})) {
65
+ if (FREQUENCY_KEYS.has(key)) {
66
+ const v = String(value).toUpperCase();
67
+ if (!FREQUENCY_VALUES.has(v)) {
68
+ bad.push(`${key}: "${value}" (use NONE, INFREQUENT_OR_MILD, or FREQUENT_OR_INTENSE; a few keys also accept INFREQUENT or FREQUENT)`);
69
+ continue;
70
+ }
71
+ attributes[key] = v;
72
+ }
73
+ else if (BOOLEAN_KEYS.has(key)) {
74
+ attributes[key] = value === true || value === "true";
75
+ }
76
+ else {
77
+ bad.push(`${key}: unknown declaration key`);
78
+ }
79
+ }
80
+ if (bad.length) {
81
+ return `Refusing to write, invalid age-rating declarations:\n- ${bad.join("\n- ")}`;
82
+ }
83
+ if (!Object.keys(attributes).length) {
84
+ return "No declarations provided. Pass at least one, e.g. { medicalOrTreatmentInformation: \"INFREQUENT_OR_MILD\" }.";
85
+ }
86
+ // The ageRatingDeclaration id + current attributes come from the app's
87
+ // appInfo with the declaration included.
88
+ const infoRes = await client.get(`/v1/apps/${args.app_id}/appInfos`, { include: "ageRatingDeclaration", limit: "1" });
89
+ const appInfo = Array.isArray(infoRes.data) ? infoRes.data[0] : infoRes.data;
90
+ const ardId = appInfo
91
+ ?.relationships?.ageRatingDeclaration?.data?.id;
92
+ if (!ardId) {
93
+ return "Could not resolve the app's age-rating declaration. Confirm the app_id is correct.";
94
+ }
95
+ const included = infoRes.included;
96
+ const current = included?.find((x) => x.type === "ageRatingDeclarations" && x.id === ardId)?.attributes ?? {};
97
+ // The V2 declaration is not a partial PATCH: Apple requires the full set of
98
+ // content declarations. Build a complete object (defaults for nulls), overlay
99
+ // the app's existing values, then the caller's changes on top.
100
+ const full = {};
101
+ for (const k of FREQUENCY_KEYS) {
102
+ const cur = current[k];
103
+ full[k] = typeof cur === "string" ? cur : "NONE";
104
+ }
105
+ for (const k of BOOLEAN_KEYS) {
106
+ const cur = current[k];
107
+ full[k] = typeof cur === "boolean" ? cur : false;
108
+ }
109
+ // Override/meta keys: only echo back ones the app already has set.
110
+ for (const k of KEEP_KEYS) {
111
+ if (current[k] !== undefined && current[k] !== null) {
112
+ full[k] = current[k];
113
+ }
114
+ }
115
+ Object.assign(full, attributes);
116
+ await client.patch(`/v1/ageRatingDeclarations/${ardId}`, {
117
+ data: { type: "ageRatingDeclarations", id: ardId, attributes: full },
118
+ });
119
+ const set = Object.entries(attributes).map(([k, v]) => `${k} = ${v}`);
120
+ return ("Age-rating declarations updated:\n" +
121
+ set.map((s) => `- ${s}`).join("\n") +
122
+ "\n\nApple recomputes the displayed rating (4+/9+/12+/17+) from these. " +
123
+ "Verify it in App Store Connect before submitting.");
124
+ }
125
+ //# sourceMappingURL=age-rating.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"age-rating.js","sourceRoot":"","sources":["../../src/tools/age-rating.ts"],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A6B,KAAK,EAAE,EAAE;QACvD,IAAI,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE;KACrE,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtE,OAAO,CACL,oCAAoC;QACpC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACnC,wEAAwE;QACxE,mDAAmD,CACpD,CAAC;AACJ,CAAC"}
@@ -40,9 +40,9 @@ async function appDetails(client, args) {
40
40
  result += `### Recent Versions\n\n`;
41
41
  for (const v of versions) {
42
42
  const state = formatState(v.attributes.appStoreState);
43
- result += `- **v${v.attributes.versionString}** (${v.attributes.platform}) — ${state}`;
43
+ result += `- **v${v.attributes.versionString}** (${v.attributes.platform}) - ${state}`;
44
44
  if (v.attributes.createdDate) {
45
- result += ` — created ${v.attributes.createdDate.split("T")[0]}`;
45
+ result += ` - created ${v.attributes.createdDate.split("T")[0]}`;
46
46
  }
47
47
  result += "\n";
48
48
  }
@@ -0,0 +1,20 @@
1
+ import { type ASCClient } from "../client.js";
2
+ import type { Tier } from "../types.js";
3
+ export interface AppAvailabilityArgs {
4
+ app_id: string;
5
+ /**
6
+ * Territory ids to make the app available in (e.g. ["USA","GBR"]). Omit to
7
+ * make it available in ALL App Store territories.
8
+ */
9
+ territories?: string[];
10
+ /** Auto-include future new territories. Defaults to true. */
11
+ available_in_new_territories?: boolean;
12
+ }
13
+ /**
14
+ * Set the app's country/region availability. By default makes the app available
15
+ * in every App Store territory and auto-includes future ones. App availability
16
+ * is a per-app singleton: if it already exists we flip the individual
17
+ * territoryAvailabilities; otherwise we create it inline.
18
+ */
19
+ export declare function setAppAvailability(client: ASCClient, args: AppAvailabilityArgs, tier: Tier): Promise<string>;
20
+ //# sourceMappingURL=availability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"availability.d.ts","sourceRoot":"","sources":["../../src/tools/availability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,6DAA6D;IAC7D,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC;AAMD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,MAAM,CAAC,CA2FjB"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setAppAvailability = setAppAvailability;
4
+ const client_js_1 = require("../client.js");
5
+ const gate_js_1 = require("../gate.js");
6
+ /**
7
+ * Set the app's country/region availability. By default makes the app available
8
+ * in every App Store territory and auto-includes future ones. App availability
9
+ * is a per-app singleton: if it already exists we flip the individual
10
+ * territoryAvailabilities; otherwise we create it inline.
11
+ */
12
+ async function setAppAvailability(client, args, tier) {
13
+ const gate = (0, gate_js_1.requirePro)(tier, "Setting app availability");
14
+ if (gate)
15
+ return gate;
16
+ const newTerr = args.available_in_new_territories ?? true;
17
+ // Resolve the target territory set (all, unless a subset was given).
18
+ const allTerrRes = await client.getAll("/v1/territories", { limit: "200" });
19
+ const allIds = (Array.isArray(allTerrRes.data) ? allTerrRes.data : [allTerrRes.data])
20
+ .filter(Boolean)
21
+ .map((t) => t.id);
22
+ const wanted = new Set(args.territories?.length ? args.territories : allIds);
23
+ // Does an availability already exist for this app?
24
+ let availId = null;
25
+ try {
26
+ const ex = await client.get(`/v1/apps/${args.app_id}/appAvailabilityV2`);
27
+ if (ex.data && !Array.isArray(ex.data))
28
+ availId = ex.data.id;
29
+ }
30
+ catch (err) {
31
+ if (!(err instanceof client_js_1.ASCAPIError && err.status === 404))
32
+ throw err;
33
+ }
34
+ // Create path: no availability yet, build it inline with the wanted set.
35
+ if (!availId) {
36
+ const ids = [...wanted];
37
+ const lid = (id) => "${ta-" + id + "}";
38
+ await client.post("/v2/appAvailabilities", {
39
+ data: {
40
+ type: "appAvailabilities",
41
+ attributes: { availableInNewTerritories: newTerr },
42
+ relationships: {
43
+ app: { data: { type: "apps", id: args.app_id } },
44
+ territoryAvailabilities: { data: ids.map((id) => ({ type: "territoryAvailabilities", id: lid(id) })) },
45
+ },
46
+ },
47
+ included: ids.map((id) => ({
48
+ type: "territoryAvailabilities",
49
+ id: lid(id),
50
+ attributes: { available: true },
51
+ relationships: { territory: { data: { type: "territories", id } } },
52
+ })),
53
+ });
54
+ return `App availability created: ${ids.length} territories on, new-territory auto-include ${newTerr}.`;
55
+ }
56
+ // Update path: flip each territoryAvailability to match the wanted set.
57
+ let url = `/v2/appAvailabilities/${availId}/territoryAvailabilities?include=territory&limit=50`;
58
+ const rows = [];
59
+ while (url) {
60
+ const r = await client.get(url.replace(/^https:\/\/api\.appstoreconnect\.apple\.com/, ""));
61
+ const items = (Array.isArray(r.data) ? r.data : [r.data]).filter(Boolean);
62
+ for (const t of items) {
63
+ const territory = t.relationships?.territory?.data?.id;
64
+ if (territory)
65
+ rows.push({ id: t.id, territory, on: Boolean(t.attributes?.available) });
66
+ }
67
+ url = r.links?.next ?? null;
68
+ }
69
+ let turnedOn = 0;
70
+ let turnedOff = 0;
71
+ for (const row of rows) {
72
+ const shouldBeOn = wanted.has(row.territory);
73
+ if (shouldBeOn === row.on)
74
+ continue;
75
+ await client.patch(`/v2/territoryAvailabilities/${row.id}`, {
76
+ data: { type: "territoryAvailabilities", id: row.id, attributes: { available: shouldBeOn } },
77
+ });
78
+ if (shouldBeOn)
79
+ turnedOn++;
80
+ else
81
+ turnedOff++;
82
+ }
83
+ // Sync the new-territory flag.
84
+ try {
85
+ await client.patch(`/v1/appAvailabilities/${availId}`, {
86
+ data: { type: "appAvailabilities", id: availId, attributes: { availableInNewTerritories: newTerr } },
87
+ });
88
+ }
89
+ catch {
90
+ // Some accounts reject this PATCH; the territory set is what matters.
91
+ }
92
+ const onTotal = rows.filter((r) => wanted.has(r.territory)).length;
93
+ return (`App availability updated: ${onTotal} territories on (+${turnedOn} enabled, -${turnedOff} disabled), ` +
94
+ `new-territory auto-include ${newTerr}.`);
95
+ }
96
+ //# sourceMappingURL=availability.js.map