@pofky/asc-mcp 1.9.12 → 1.9.14

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/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  npx @pofky/asc-mcp init --write # finds your .p8, asks for your Issuer ID, writes your MCP config
13
13
  ```
14
14
 
15
- Then ask your agent: **"start my asc-mcp trial, my email is you@example.com"**. All 41 tools unlock for 7 days, no card and nothing to cancel, and the trial activates in the session you are already in, so whatever you were blocked on works on the very next call. After that Pro is $9 a month. Six tools stay free, and three of those need nothing but Node.
15
+ Then ask your agent: **"start my asc-mcp trial, my email is you@example.com"**. All 41 tools unlock for 7 days, no card and nothing to cancel, and the trial activates in the session you are already in, so whatever you were blocked on works on the very next call. After that Pro is $9 a month. Six tools stay free, and two of those (the setup check and the playbook) need nothing but Node. The Pro tools that only read (reviews, sales, builds, TestFlight groups, preflight, briefing, keywords, competitors, metadata diff, release notes) also work 5 times in total on your machine with no licence, as a preview.
16
16
 
17
17
  | You say | What happens |
18
18
  |---------|-------------|
@@ -96,7 +96,7 @@ With the `.p8` in `~/.appstoreconnect/private_keys/`, `ASC_ISSUER_ID` is the onl
96
96
 
97
97
  **Step 3.** Ask your agent: "List my App Store Connect apps"
98
98
 
99
- **Step 4, to try the paid half.** Ask your agent: "start my asc-mcp trial, my email is you@example.com". It calls `asc_start_trial`, which unlocks all 41 tools for 7 days with no card and nothing to cancel. The key activates in the running session, so whatever you were blocked on works on the very next call, and it is written into your MCP config so it survives a restart. One trial per Apple developer account.
99
+ **Step 4, to try the paid half.** Ask your agent: "start my asc-mcp trial, my email is you@example.com". It calls `asc_start_trial`, which unlocks all 41 tools for 7 days with no card and nothing to cancel. The key activates in the running session, so whatever you were blocked on works on the very next call, and it is saved on your machine, in `~/.asc-mcp/license.json` and in any MCP client config that already has an asc-mcp entry, so it survives a restart. One trial per Apple developer account.
100
100
 
101
101
  Works with **Claude Code**, **Cursor**, **Windsurf**, **Cline**, and any MCP-compatible client.
102
102
 
@@ -286,7 +286,7 @@ Lead with the most impactful change. Keep under 4000 chars.
286
286
  | **Git-aware release notes** | No | Yes, reads your project's commit history |
287
287
  | **Smart review summaries** | No | Yes, theme clustering, action items |
288
288
  | **Setup** | Build from source (Swift or Node) | One command, `init --write` writes your config |
289
- | **Free tier** | Some | Yes, 6 tools, no signup. Three of them need nothing but Node |
289
+ | **Free tier** | Some | Yes, 6 tools, no signup. Two of them need nothing but Node |
290
290
  | **Try the paid half** | n/a | 7 days, no card, started from inside your agent |
291
291
 
292
292
  Raw wrappers give you endpoints. This gives you answers.
@@ -298,6 +298,8 @@ Your `.p8` private key never leaves your machine:
298
298
  - The `.p8` private key is read locally. JWT tokens are generated on your computer, and name your Key ID and Issuer ID to Apple, as Apple's API requires.
299
299
  - API calls go directly from your machine to `api.appstoreconnect.apple.com`.
300
300
  - The license server is sent your license key string when one is set and, if you start a trial, your email address, a one-way hash of your Issuer ID and the name of the tool you started from. No Apple data and no credentials.
301
+ - `~/.asc-mcp/preview.json` holds one number, how many of the 5 free preview calls have been used on this machine. It is never sent anywhere.
302
+ - Starting a trial, or fetching a paid key with `asc_start_trial`, saves the license key in plain text in `~/.asc-mcp/license.json` (owner-only permissions on macOS and Linux) and adds it as `ASC_LICENSE_KEY` to every asc-mcp entry found in your Claude Desktop, Claude Code (`~/.claude.json`, including per-project entries), `./.mcp.json`, Cursor, Windsurf and Cline configs. Nothing else in those files is changed, and each edited file gets a one-time `.bak` copy beside it, which holds whatever the file held. `~/.asc-mcp/last-verdict.json` holds the last license check and a hash of the key. Delete the file and the `ASC_LICENSE_KEY` lines to remove the key.
301
303
  - Fully open source. [Read the code.](https://github.com/pofky/asc-mcp)
302
304
 
303
305
  ## Works With
package/USER_GUIDE.md CHANGED
@@ -35,7 +35,7 @@ Steps:
35
35
 
36
36
  Manual interruptions you must do yourself:
37
37
  - MANUAL: generating the API key and downloading the .p8 is a one-time App Store Connect website action. The .p8 cannot be re-downloaded; if lost, revoke and make a new one.
38
- - Free tier is read/intelligence only. To unlock every write/control tool, call `asc_start_trial` with the user's email: 7 days, no card, and it takes effect in the running session with no restart. After that it is $9/month (ASC_LICENSE_KEY).
38
+ - The free tier is three read tools (list_apps, app_details, review_status); the write, control and intelligence tools need Pro. To unlock all of them, call `asc_start_trial` with the user's email: 7 days, no card, and it takes effect in the running session with no restart. After that it is $9/month (ASC_LICENSE_KEY).
39
39
 
40
40
  ---
41
41
 
package/dist/doctor.js CHANGED
@@ -163,7 +163,7 @@ async function runDoctor() {
163
163
  checks.push({
164
164
  name: "License",
165
165
  status: "warn",
166
- detail: "Free tier: the read tools (list_apps, app_details, review_status) work. The write, control and intelligence tools need Pro.",
166
+ detail: "Free tier: the read tools (list_apps, app_details, review_status) work. The write, control and intelligence tools need Pro; most of the ones that only read work 5 times in total on this machine as a free preview.",
167
167
  fix: credentialsPresent
168
168
  ? "Run `asc_start_trial` for 7 days of everything, no card. It unlocks write/control " +
169
169
  "(metadata, screenshots, builds, submit, IAP/subs) in this session, no restart. " +
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAiCH,sCAKC;AAcD,8BAmNC;AAKD,oCAaC;AAvRD,qCAAmD;AACnD,yCAAoC;AACpC,qCAAkC;AAClC,uCAAsD;AACtD,6CAAmF;AACnF,yCAAgD;AAChD,uCAAwC;AAiBxC;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,OAA2B,EAAE,GAAG,GAAG,IAAI,IAAI,EAAE;IACzE,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;IACxC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,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AAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CACR,MAAM,CAAC,OAAO;QACZ,CAAC,CAAC,8EAA8E;QAChF,CAAC,CAAC,iEAAiE,CACtE,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/dist/gate.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
1
2
  import type { Tier } from "./types.js";
2
3
  /**
3
4
  * The direct Polar checkout link. Kept in the package even though the normal
@@ -17,14 +18,50 @@ export declare const CHECKOUT_URL = "https://buy.polar.sh/polar_cl_y86PS4ruc848P
17
18
  export declare function upgradeUrl(tool?: string): string;
18
19
  /** Back-compat export: the generic buy link, no tool attribution. */
19
20
  export declare const UPGRADE_URL: string;
21
+ /**
22
+ * How many Pro calls work on this machine with no licence, as a preview.
23
+ *
24
+ * Until 1.9.14 the gate came down on the second useful call: reviews, sales and
25
+ * build status were all locked, so nobody on the free tier saw the product do
26
+ * the thing it is for before being asked for an email. Five is the owner's
27
+ * choice (9 October 2026): enough to read a real app's reviews, sales and a
28
+ * preflight, short enough that the price comes up in the same sitting.
29
+ */
30
+ export declare const PREVIEW_CALLS = 5;
31
+ /**
32
+ * One tool call, and the preview the gate granted during it, if any.
33
+ *
34
+ * Scoped to the call rather than kept in a shared list, because an agent runs
35
+ * tool calls side by side. With one list, whichever call finished first took
36
+ * the notice: a free tool's reply announced the preview count, the previewed
37
+ * reply said nothing, and a failed call's refund went to a different call.
38
+ */
39
+ export declare const previewScope: AsyncLocalStorage<{
40
+ grant: {
41
+ tool: string;
42
+ left: number;
43
+ } | null;
44
+ }>;
45
+ /**
46
+ * What to tell the user about the preview call that just ran, and a way to give
47
+ * it back. The tool wrapper appends `footer` to a successful reply and calls
48
+ * `refund` when the call failed, so an Apple outage or a typo in an app id does
49
+ * not spend someone's preview. Null for every call that was not a preview,
50
+ * which is every call a Pro user ever makes.
51
+ */
52
+ export declare function takePreviewNotice(): {
53
+ footer: string;
54
+ refund: () => void;
55
+ } | null;
20
56
  /**
21
57
  * Returns an upgrade message when the tier is not Pro, otherwise null. Write and
22
58
  * control tools call this first and early-return the message.
23
59
  *
24
- * The message leads with the trial, not the price. This fires at the moment a
25
- * user has just asked their agent to do something real to their app, which is
26
- * the worst possible moment to send them to a browser to enter a card for a
27
- * product they have not yet seen work.
60
+ * A read tool gets through `PREVIEW_CALLS` times first. After that, and for
61
+ * anything that writes, the message leads with the price and offers the trial
62
+ * second: the owner's call (9 October 2026), on the reasoning that someone who
63
+ * has just watched it work on their own app is being asked for $9, not for a
64
+ * leap of faith.
28
65
  */
29
66
  export declare function requirePro(tier: Tier, capability: string, tool?: string): string | null;
30
67
  //# sourceMappingURL=gate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,8EACoD,CAAC;AAE9E;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED,qEAAqE;AACrE,eAAO,MAAM,WAAW,QAAe,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,GAAG,IAAI,CAgCf"}
1
+ {"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,8EACoD,CAAC;AAE9E;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED,qEAAqE;AACrE,eAAO,MAAM,WAAW,QAAe,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AA+C/B;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;WAAkC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;EAAK,CAAC;AAEtG;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,IAAI,CAqBjF;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,GAAG,IAAI,CAmDf"}
package/dist/gate.js CHANGED
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UPGRADE_URL = exports.CHECKOUT_URL = void 0;
3
+ exports.previewScope = exports.PREVIEW_CALLS = exports.UPGRADE_URL = exports.CHECKOUT_URL = void 0;
4
4
  exports.upgradeUrl = upgradeUrl;
5
+ exports.takePreviewNotice = takePreviewNotice;
5
6
  exports.requirePro = requirePro;
7
+ const node_async_hooks_1 = require("node:async_hooks");
8
+ const node_fs_1 = require("node:fs");
9
+ const node_os_1 = require("node:os");
10
+ const node_path_1 = require("node:path");
6
11
  const license_js_1 = require("./license.js");
12
+ const tool_meta_js_1 = require("./tool-meta.js");
7
13
  /**
8
14
  * The direct Polar checkout link. Kept in the package even though the normal
9
15
  * path is the counted redirect below, so a licence-server outage costs us
@@ -25,16 +31,109 @@ function upgradeUrl(tool) {
25
31
  }
26
32
  /** Back-compat export: the generic buy link, no tool attribution. */
27
33
  exports.UPGRADE_URL = upgradeUrl();
34
+ /**
35
+ * How many Pro calls work on this machine with no licence, as a preview.
36
+ *
37
+ * Until 1.9.14 the gate came down on the second useful call: reviews, sales and
38
+ * build status were all locked, so nobody on the free tier saw the product do
39
+ * the thing it is for before being asked for an email. Five is the owner's
40
+ * choice (9 October 2026): enough to read a real app's reviews, sales and a
41
+ * preflight, short enough that the price comes up in the same sitting.
42
+ */
43
+ exports.PREVIEW_CALLS = 5;
44
+ /**
45
+ * Pro tools that read but are not part of the preview. The first two work
46
+ * through the client's own model (MCP sampling) and report a missing licence
47
+ * inside a structured result rather than by returning the gate. The next two
48
+ * return Apple's manual steps for a submission; they show nothing of the
49
+ * product, and spending a preview call on a checklist would be a poor trade.
50
+ * `wait_for_build` polls for up to an hour, which is a job, not a look.
51
+ */
52
+ const NOT_PREVIEWED = new Set([
53
+ "triage_reviews",
54
+ "draft_review_response",
55
+ "set_privacy_nutrition",
56
+ "set_eu_trader_status",
57
+ "wait_for_build",
58
+ ]);
59
+ /** Whether a locked tool may be previewed: it reads, and never changes anything. */
60
+ function previewable(tool) {
61
+ return Boolean(tool) && (0, tool_meta_js_1.isReadTool)(tool) && !NOT_PREVIEWED.has(tool);
62
+ }
63
+ function previewPath() {
64
+ return (0, node_path_1.join)((0, node_os_1.homedir)(), ".asc-mcp", "preview.json");
65
+ }
66
+ function previewUsed() {
67
+ try {
68
+ const used = JSON.parse((0, node_fs_1.readFileSync)(previewPath(), "utf-8")).used;
69
+ return typeof used === "number" && used >= 0 ? Math.floor(used) : 0;
70
+ }
71
+ catch {
72
+ return 0;
73
+ }
74
+ }
75
+ /** False when the count could not be kept, in which case no preview is given. */
76
+ function setPreviewUsed(used) {
77
+ try {
78
+ (0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(previewPath()), { recursive: true, mode: 0o700 });
79
+ (0, node_fs_1.writeFileSync)(previewPath(), JSON.stringify({ used }) + "\n");
80
+ return true;
81
+ }
82
+ catch {
83
+ return false;
84
+ }
85
+ }
86
+ /**
87
+ * One tool call, and the preview the gate granted during it, if any.
88
+ *
89
+ * Scoped to the call rather than kept in a shared list, because an agent runs
90
+ * tool calls side by side. With one list, whichever call finished first took
91
+ * the notice: a free tool's reply announced the preview count, the previewed
92
+ * reply said nothing, and a failed call's refund went to a different call.
93
+ */
94
+ exports.previewScope = new node_async_hooks_1.AsyncLocalStorage();
95
+ /**
96
+ * What to tell the user about the preview call that just ran, and a way to give
97
+ * it back. The tool wrapper appends `footer` to a successful reply and calls
98
+ * `refund` when the call failed, so an Apple outage or a typo in an app id does
99
+ * not spend someone's preview. Null for every call that was not a preview,
100
+ * which is every call a Pro user ever makes.
101
+ */
102
+ function takePreviewNotice() {
103
+ const call = exports.previewScope.getStore();
104
+ const preview = call?.grant;
105
+ if (!call || !preview)
106
+ return null;
107
+ call.grant = null;
108
+ const price = `Pro is $9/month, cancel any time: ${upgradeUrl(preview.tool)}`;
109
+ return {
110
+ footer: "\n\n---\n" +
111
+ // The count on every preview reply; the price on the first and the
112
+ // last only. Five replies in a row each ending in a price and a link
113
+ // would be an advert stapled to a working tool.
114
+ (preview.left > 0
115
+ ? `Free preview: ${preview.left} of ${exports.PREVIEW_CALLS} Pro calls left on this machine.` +
116
+ (preview.left === exports.PREVIEW_CALLS - 1 ? ` ${price}` : "")
117
+ : `That was the last of your ${exports.PREVIEW_CALLS} free Pro calls. ${price}\n` +
118
+ "Or try everything free for 7 days, no card: call `asc_start_trial` with the user's email."),
119
+ refund: () => {
120
+ setPreviewUsed(Math.max(0, previewUsed() - 1));
121
+ },
122
+ };
123
+ }
28
124
  /**
29
125
  * Returns an upgrade message when the tier is not Pro, otherwise null. Write and
30
126
  * control tools call this first and early-return the message.
31
127
  *
32
- * The message leads with the trial, not the price. This fires at the moment a
33
- * user has just asked their agent to do something real to their app, which is
34
- * the worst possible moment to send them to a browser to enter a card for a
35
- * product they have not yet seen work.
128
+ * A read tool gets through `PREVIEW_CALLS` times first. After that, and for
129
+ * anything that writes, the message leads with the price and offers the trial
130
+ * second: the owner's call (9 October 2026), on the reasoning that someone who
131
+ * has just watched it work on their own app is being asked for $9, not for a
132
+ * leap of faith.
36
133
  */
37
134
  function requirePro(tier, capability, tool) {
135
+ // First, and before anything else in this function: a Pro user, paying or on
136
+ // a trial, is never counted, never shown a footer and never touches the disk.
38
137
  if (tier === "pro")
39
138
  return null;
40
139
  // Someone whose trial has already run out must not be told to start one. They
@@ -47,6 +146,20 @@ function requirePro(tier, capability, tool) {
47
146
  // to pay. They get the same wording as a spent trial: the price and the link.
48
147
  const reason = (0, license_js_1.lastLicenseStatus)()?.reason;
49
148
  const lapsedPaid = reason === "revoked" || reason === "canceled" || reason === "inactive";
149
+ // The preview is for someone who has not seen the product yet. A spent trial
150
+ // or a lapsed subscription has, and gets the price.
151
+ let previewSpent = false;
152
+ // Only inside a call the wrapper is tracking: a preview that could not be
153
+ // reported back, or refunded on failure, is not granted.
154
+ const call = exports.previewScope.getStore();
155
+ if (call && !spent && !lapsedPaid && previewable(tool)) {
156
+ const used = previewUsed();
157
+ if (used < exports.PREVIEW_CALLS && setPreviewUsed(used + 1)) {
158
+ call.grant = { tool, left: exports.PREVIEW_CALLS - used - 1 };
159
+ return null;
160
+ }
161
+ previewSpent = used >= exports.PREVIEW_CALLS;
162
+ }
50
163
  return (`${capability} requires Pro.\n\n` +
51
164
  (spent || lapsedPaid
52
165
  ? (spent
@@ -56,11 +169,13 @@ function requirePro(tier, capability, tool) {
56
169
  ` ${upgradeUrl(tool)}\n` +
57
170
  ` (direct link: ${exports.CHECKOUT_URL})\n\n` +
58
171
  "If you already subscribed, call `asc_start_trial` with the same email and it will fetch " +
59
- "your paid key and put it in your config.\n"
60
- : "Free for 7 days, no card: call the `asc_start_trial` tool with the user's email. " +
61
- "It unlocks all 41 tools in this session immediately, no restart.\n\n" +
62
- `Or subscribe now, $9/month: ${upgradeUrl(tool)}\n` +
63
- `(direct link: ${exports.CHECKOUT_URL})\n`) +
172
+ "your paid key and save it on this machine.\n"
173
+ : (previewSpent ? `You have used the ${exports.PREVIEW_CALLS} free Pro calls on this machine. ` : "") +
174
+ "Pro is $9/month, cancel any time:\n" +
175
+ ` ${upgradeUrl(tool)}\n` +
176
+ ` (direct link: ${exports.CHECKOUT_URL})\n\n` +
177
+ "Or free for 7 days, no card: call the `asc_start_trial` tool with the user's email. " +
178
+ "It unlocks all 41 tools in this session immediately, no restart.\n") +
64
179
  `\n${keyAdvice()}`);
65
180
  }
66
181
  /**
package/dist/gate.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"gate.js","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":";;;AAoBA,gCAGC;AAcD,gCAoCC;AAxED,6CAAkE;AAElE;;;;;;;GAOG;AACU,QAAA,YAAY,GACvB,2EAA2E,CAAC;AAE9E;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAa;IACtC,MAAM,IAAI,GAAG,GAAG,4BAAe,KAAK,CAAC;IACrC,OAAO,IAAI,IAAI,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAChF,CAAC;AAED,qEAAqE;AACxD,QAAA,WAAW,GAAG,UAAU,EAAE,CAAC;AAExC;;;;;;;;GAQG;AACH,SAAgB,UAAU,CACxB,IAAU,EACV,UAAkB,EAClB,IAAa;IAEb,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAEhC,8EAA8E;IAC9E,+EAA+E;IAC/E,8EAA8E;IAC9E,MAAM,KAAK,GAAG,IAAA,8BAAiB,GAAE,EAAE,MAAM,KAAK,eAAe,CAAC;IAE9D,6EAA6E;IAC7E,2EAA2E;IAC3E,6EAA6E;IAC7E,8EAA8E;IAC9E,MAAM,MAAM,GAAG,IAAA,8BAAiB,GAAE,EAAE,MAAM,CAAC;IAC3C,MAAM,UAAU,GAAG,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,UAAU,IAAI,MAAM,KAAK,UAAU,CAAC;IA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UAAU,oBAAoB;QACjC,CAAC,KAAK,IAAI,UAAU;YAClB,CAAC,CAAC,CAAC,KAAK;gBACJ,CAAC,CAAC,8BAA8B;gBAChC,CAAC,CAAC,gFAAgF,CAAC;gBACrF,qCAAqC;gBACrC,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI;gBACzB,mBAAmB,oBAAY,OAAO;gBACtC,0FAA0F;gBAC1F,8CAA8C;YAChD,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,qBAAqB,qBAAa,mCAAmC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3F,qCAAqC;gBACrC,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI;gBACzB,mBAAmB,oBAAY,OAAO;gBACtC,sFAAsF;gBACtF,oEAAoE,CAAC;QACzE,KAAK,SAAS,EAAE,EAAE,CACnB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,SAAS;IAChB,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACpD,IAAI,MAAM,IAAI,IAAA,8BAAiB,GAAE,KAAK,IAAI,EAAE,CAAC;QAC3C,OAAO,CACL,qFAAqF;YACrF,iFAAiF;YACjF,GAAG,4BAAe,SAAS,CAC5B,CAAC;IACJ,CAAC;IACD,wEAAwE;IACxE,8EAA8E;IAC9E,2EAA2E;IAC3E,2EAA2E;IAC3E,qDAAqD;IACrD,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM;QACvC,CAAC,CAAC,gHAAgH;QAClH,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,QAAQ;YACpC,CAAC,CAAC,wFAAwF;YAC1F,CAAC,CAAC,oEAAoE,CAAC;AAC7E,CAAC"}
package/dist/index.js CHANGED
@@ -75,6 +75,22 @@ for (const name of Object.keys(process.env)) {
75
75
  if (!value.trim() || value.includes("${"))
76
76
  delete process.env[name];
77
77
  }
78
+ // The key the client itself handed over, before a saved one can stand in for
79
+ // it. `asc_start_trial` needs to know the difference: a key set in the client's
80
+ // own settings is the one that will be used after a restart, whatever this
81
+ // server saves, so a subscriber who fetches a paid key while an old one is
82
+ // still set there has to be told to replace it.
83
+ const licenseKeyFromClient = process.env.ASC_LICENSE_KEY;
84
+ // A key this server saved on this machine stands in when the client config
85
+ // carries none. The config always wins, so someone who sets a paid key by hand
86
+ // is never overruled by an older trial key on disk. Not for `init`: that
87
+ // writes whatever key it is given into a client config and announces Pro, and
88
+ // it should only do that with a key the person supplied on this run.
89
+ if (!process.env.ASC_LICENSE_KEY && process.argv[2] !== "init") {
90
+ const saved = (0, license_js_1.savedLicenseKey)();
91
+ if (saved)
92
+ process.env.ASC_LICENSE_KEY = saved;
93
+ }
78
94
  /**
79
95
  * Register a tool with the title and read/write hints tool-meta.ts holds for
80
96
  * it. The name is typed, so a tool with no row there does not compile.
@@ -172,15 +188,34 @@ async function main() {
172
188
  const tool = annotated(server);
173
189
  /** Wrap a tool handler so API errors return messages instead of crashing. */
174
190
  function safe(fn) {
175
- return async (...a) => {
191
+ // Each call runs in its own preview scope, so a preview the gate grants
192
+ // inside it is reported on this reply and no other.
193
+ return (...a) => gate_js_1.previewScope.run({ grant: null }, async () => {
176
194
  try {
177
- return { content: [{ type: "text", text: await fn(...a) }] };
195
+ const body = await fn(...a);
196
+ // Only ever non-null for a free-tier call the gate let through as a
197
+ // preview. A Pro reply is returned exactly as the tool produced it.
198
+ const preview = (0, gate_js_1.takePreviewNotice)();
199
+ // Tools report a bad argument or a failed fetch as an "Error ..."
200
+ // reply, not a throw. That is not a look at the product either, so
201
+ // it is given back too.
202
+ // The two other prefixes are failure replies whose wording is left
203
+ // as it is, so nothing a Pro user reads changes.
204
+ const failed = /^(Error\b|Invalid vendor number|Could not fetch |No app with id )/.test(body);
205
+ if (preview && failed)
206
+ preview.refund();
207
+ return {
208
+ content: [{ type: "text", text: preview && !failed ? body + preview.footer : body }],
209
+ };
178
210
  }
179
211
  catch (err) {
212
+ // A preview call that failed is given back: a wrong app id or an
213
+ // Apple outage should not spend it.
214
+ (0, gate_js_1.takePreviewNotice)()?.refund();
180
215
  const msg = err instanceof Error ? err.message : String(err);
181
216
  return { content: [{ type: "text", text: `Error: ${msg}` }] };
182
217
  }
183
- };
218
+ });
184
219
  }
185
220
  tool("asc_guide", "START HERE. Returns the exact end-to-end playbook for an App Store task, with every manual ASC-website/Xcode step that no API can do flagged inline. Call with topic to orient before any multi-step flow. Free.", {
186
221
  topic: zod_1.z
@@ -207,7 +242,7 @@ async function main() {
207
242
  inputSchema: {
208
243
  email: zod_1.z
209
244
  .string()
210
- .describe("The user's email address. Required: the trial key is sent there so they still have it later. Ask the user for it; never invent one. Tell them what the request stores: this address, a one-way hash of their Issuer ID, the trial key with its start and end dates, and which tool they started from. Tell them the address gets the key, one reminder shortly before the trial ends and one note after it, and that each has an unsubscribe link or they can reply stop. All of it is deletable at https://asc-mcp-license.remewdy.workers.dev/delete (policy: https://asc-mcp-license.remewdy.workers.dev/privacy)."),
245
+ .describe("The user's email address. Required: the trial key is sent there so they still have it later. Ask the user for it; never invent one. Tell them what the request stores: this address, a one-way hash of their Issuer ID, the trial key with its start and end dates, and which tool they started from. Tell them the address gets the key, one reminder shortly before the trial ends and one note after it, and that each has an unsubscribe link or they can reply stop. Tell them it also saves the key on this machine (~/.asc-mcp/license.json) and adds it to any existing asc-mcp entry in their MCP client configs, leaving a .bak copy of each file it edits. All of it is deletable at https://asc-mcp-license.remewdy.workers.dev/delete (policy: https://asc-mcp-license.remewdy.workers.dev/privacy)."),
211
246
  tool: zod_1.z
212
247
  .string()
213
248
  .optional()
@@ -235,34 +270,56 @@ async function main() {
235
270
  tier = "pro";
236
271
  process.env.ASC_LICENSE_KEY = result.key;
237
272
  (0, license_js_1.clearLicenseCache)();
273
+ // Two places, on purpose. The client config is where someone looks for
274
+ // the key and what carries it to a reinstall; the file in ~/.asc-mcp is
275
+ // what makes it survive a restart in a client whose config this cannot
276
+ // find or edit. Either alone has left people on the free tier.
238
277
  const { updated, skipped } = (0, setup_js_1.injectLicenseKey)(result.key);
278
+ const savedLocally = (0, license_js_1.saveLicenseKey)(result.key);
279
+ // Where the key goes by hand, for this kind of install. A one-click
280
+ // install has no server block in any client config file: Claude Desktop
281
+ // keeps an extension's settings in its own registry, and a plugin keeps
282
+ // them in the plugin's options. Telling either to hand-edit JSON sends
283
+ // them looking for a file that does not exist. The manifests set
284
+ // ASC_INSTALL so the populations can be told apart.
285
+ const whereByHand = process.env.ASC_INSTALL === "mcpb"
286
+ ? "Claude Settings > Extensions > asc-mcp > Configure > License key, then Save."
287
+ : process.env.ASC_INSTALL === "plugin"
288
+ ? "the License key option in the asc-mcp plugin's settings."
289
+ : "the ASC_LICENSE_KEY line in your client's MCP config.";
290
+ // A key the client supplies always wins over the saved file. If one is
291
+ // set there, is not this key, and no config was rewritten, the next
292
+ // session starts on the old key: for a subscriber replacing a trial key,
293
+ // that is the free tier, after being told the key was saved.
294
+ // A bundle or a plugin keeps its key where no config edit reaches, so for
295
+ // those a rewritten config elsewhere (a Cursor file, say) changes nothing
296
+ // about which key this client starts with.
297
+ const clientKeyOutOfReach = process.env.ASC_INSTALL === "mcpb" || process.env.ASC_INSTALL === "plugin";
298
+ const staleClientKey = Boolean(licenseKeyFromClient) &&
299
+ licenseKeyFromClient !== result.key &&
300
+ (clientKeyOutOfReach || !updated.length);
301
+ const staleWarning = `A different key is set in your client's own settings, and that one is used after a restart. Replace it with the key above: ${whereByHand}`;
302
+ const inWorkingDir = updated.filter((path) => path === (0, node_path_1.join)(process.cwd(), ".mcp.json"));
239
303
  const persistence = updated.length
240
- ? `Saved to ${updated.join(", ")} (backup alongside), so it survives a restart.`
241
- : // A one-click install has no server block in any client config file:
242
- // Claude Desktop keeps an extension's settings in its own registry, and
243
- // the key belongs in the extension's own License key field. Telling a
244
- // bundle user to hand-edit JSON sends them looking for a file that does
245
- // not exist, right after they chose the install path that exists to
246
- // avoid JSON entirely. The manifest sets ASC_INSTALL so this branch can
247
- // tell the two populations apart.
248
- process.env.ASC_INSTALL === "mcpb"
249
- ? "To keep it after a restart, paste it into the extension's own settings: " +
250
- "Claude Settings > Extensions > asc-mcp > Configure > License key, then Save."
251
- : process.env.ASC_INSTALL === "plugin"
252
- ? // A plugin install keeps its settings in the plugin's own options,
253
- // and its server block lives inside the plugin, not in a client
254
- // config this process could edit.
255
- "To keep it after a restart, set it as the License key option in the asc-mcp plugin's settings."
256
- : "Could not find an asc-mcp block in a known client config, so add ASC_LICENSE_KEY yourself to keep it after a restart:\n" +
257
- ` "ASC_LICENSE_KEY": "${result.key}"`;
304
+ ? `Saved to ${updated.join(", ")} (backup alongside)` +
305
+ (savedLocally ? ` and to ${(0, license_js_1.savedLicenseKeyPath)()}` : "") +
306
+ (staleClientKey ? `. ${staleWarning}` : ", so it survives a restart.") +
307
+ (inWorkingDir.length
308
+ ? ` ${inWorkingDir.join(", ")} is in this project folder and is often committed: keep the key and the .bak out of version control.`
309
+ : "")
310
+ : savedLocally
311
+ ? `Saved on this machine in ${(0, license_js_1.savedLicenseKeyPath)()}` +
312
+ (staleClientKey
313
+ ? `. ${staleWarning}`
314
+ : ", so it survives a restart. To use it on another machine, set ASC_LICENSE_KEY there.")
315
+ : "It could not be saved on this machine. To keep it after a restart, set it in " + whereByHand;
258
316
  return text([
259
317
  result.subscription
260
318
  ? // Deliberately says nothing about replacing a trial key. Most
261
319
  // subscribers never trialled at all (every live subscription has
262
320
  // a null trial_fingerprint), and telling those people their trial
263
321
  // key was swapped out describes a key they never had.
264
- "You already subscribed, so this is your paid license key, not a trial. " +
265
- "It is now in your config, replacing whatever key was there."
322
+ "You already subscribed, so this is your paid license key, not a trial."
266
323
  : result.already_started
267
324
  ? `Trial already running: ${result.days_remaining} day(s) left.`
268
325
  : `Pro trial started. ${result.days_remaining} day(s), no card, nothing to cancel.`,