@aifinpay/mcp 2.11.0 → 2.11.4

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
@@ -4,8 +4,8 @@ AiFinPay MCP server for persistent agent identity, Agent Passport resolution,
4
4
  route discovery and non-signing settlement invoices. Canonical domain:
5
5
  **aifinpay.io**.
6
6
 
7
- Version **2.11.0** is prepared in this checkout, on the published agent 2.8.0
8
- and canonical skill 2.10.0 (AiFinPay/skill 49c2e2a, published 2026-10-19). The separate canonical producer's final immutable
7
+ Version **2.11.4** is prepared in this checkout, on the published agent 2.9.0
8
+ and canonical skill 2.10.2 (AiFinPay/skill 48285cf, published 2026-10-19). The separate canonical producer's final immutable
9
9
  source pin is a required handoff, not a moving-branch substitution.
10
10
  The published baseline checked2026-10-04 was MCP2.5.0. Package publication and
11
11
  real registry dependency/lock refresh remain release gates; a source-cohort
@@ -25,30 +25,38 @@ and only once the owner has set every limit in step 4.
25
25
  200 standard requests).
26
26
  2. **Check the setup.** Call `payment_setup_status`. It returns the wallet
27
27
  (persistent or ephemeral), whether payments are enabled, which owner limits
28
- are set, the balance when the RPC answers, and `next_step`: the first thing
28
+ are set, the balance when the RPC answers, `funding` (what a persistent
29
+ wallet needs, priced at today's rate) and `next_step`: the first thing
29
30
  still missing.
30
31
  3. **Persistent wallet.** If `wallet.persistent` is false, run
31
32
  `npx @aifinpay/mcp init`. Without a terminal it prints one JSON document;
32
33
  copy its `env` (the passphrase is only there) into the `aifinpay` server
33
34
  entry of the MCP client config, reconnect the server, then call
34
35
  `agent_reload`. Never fund an ephemeral address.
35
- 4. **Fund and enable.** Tell the owner `addresses.evm` and the amount: the
36
- batch price in POL plus the gas cap, so about `0.5 POL` for one `$0.10`
37
- batch at `$0.20`/POL plus up to `0.3 POL` gas (the SDK refuses before
38
- signing if the worst-case fee exceeds the cap). When the owner confirms
39
- funding, they add the payment settings to the same `env` and reconnect:
36
+ 4. **Fund and enable.** Tell the owner `addresses.evm` and the amount from
37
+ `payment_setup_status`'s `funding`: the smallest batch (`$0.10`) in POL at
38
+ today's rate plus the gas cap (the SDK refuses before signing if the
39
+ worst-case fee exceeds the cap). The rate moves — `$0.10` was 1.08 POL on
40
+ 2026-10-19 — so never quote a remembered number; if `funding` carries a
41
+ `rate_error` instead of an `amount`, ask the owner to fund "the batch price
42
+ in POL at today's rate plus the gas cap" and name no number. When the owner
43
+ confirms funding, they add the payment settings to the same `env` and
44
+ restart the aifinpay MCP server in the client (`agent_reload` does not read
45
+ env):
40
46
 
41
47
  ```json
42
48
  {
43
49
  "AIFINPAY_PAYMENTS_ENABLED": "1",
44
50
  "AIFINPAY_GATEWAY_ORIGINS": "https://dev.ratersapp.com",
45
51
  "AIFINPAY_GATEWAY_PATH_MODE": "direct",
46
- "AIFINPAY_MAX_USD": "0.15",
47
- "AIFINPAY_DAILY_USD": "1.00",
52
+ "AIFINPAY_MAX_USD": "5",
53
+ "AIFINPAY_DAILY_USD": "20",
48
54
  "AIFINPAY_MAX_GAS_POL": "0.3"
49
55
  }
50
56
  ```
51
57
 
58
+ The USD values are a ceiling the owner sets once, not the budget: the
59
+ working limits live in the dashboard (see "Owner limits" below).
52
60
  `payment_setup_status` then reports `ready: true`.
53
61
 
54
62
  5. **Pay.** `payable_fetch({"url": "https://dev.ratersapp.com/api/agent/genres/list"})`
@@ -70,8 +78,8 @@ to the server's `env` (`init` prints the same block):
70
78
  "AIFINPAY_PAYMENTS_ENABLED": "1",
71
79
  "AIFINPAY_GATEWAY_ORIGINS": "https://merchant.example",
72
80
  "AIFINPAY_GATEWAY_PATH_MODE": "direct",
73
- "AIFINPAY_MAX_USD": "0.15",
74
- "AIFINPAY_DAILY_USD": "1.00",
81
+ "AIFINPAY_MAX_USD": "5",
82
+ "AIFINPAY_DAILY_USD": "20",
75
83
  "AIFINPAY_MAX_GAS_POL": "0.3"
76
84
  }
77
85
  ```
@@ -82,6 +90,18 @@ owner. `direct` uses the full path for self-hosted sites; `gateway` uses the
82
90
  merchant slug on the hosted gateway. Restart/reconnect the MCP process after
83
91
  changing its environment.
84
92
 
93
+ ### Owner limits: a ceiling in env, the working limits in the dashboard
94
+
95
+ `AIFINPAY_MAX_USD` and `AIFINPAY_DAILY_USD` are the ceiling the SDK requires
96
+ before it signs with the owner's key: set them once, high enough that they do
97
+ not need revisiting (the example `5` per payment and `20` per day is a ceiling,
98
+ not a budget), and leave them. The day-to-day limits belong in the dashboard:
99
+ once the agent is linked with `agent_claim_self`, the owner manages the
100
+ per-payment cap, the daily cap, pause and the allowed sites under **Controls**
101
+ at https://dash.aifinpay.io, and the backend enforces that policy on every
102
+ `/v1/quote` and `/v1/pay` for the claimed agent — no env change, no server
103
+ restart. The env ceiling still applies underneath; a payment has to pass both.
104
+
85
105
  ## Indexed wallet derivation
86
106
 
87
107
  The wallet CLI and MCP can use deterministic child wallets from one recovery
@@ -148,8 +168,8 @@ runtime/signer verification and owner limits. It persists the prepared transacti
148
168
  before sending, verifies the receipt, and reuses the purchased batch. No special
149
169
  merchant script, alternate contract or facilitator fallback is used. GET on the configured chain; EVM receipt payments use live
150
170
  mode only, in its native currency or the configured
151
- stablecoin; Amoy payment receipts are not supported. The smallest batch is $0.10 plus gas, so keep `AIFINPAY_MAX_USD`
152
- a little above the batch you expect to buy.
171
+ stablecoin; Amoy payment receipts are not supported. The smallest batch is $0.10 plus gas; `AIFINPAY_MAX_USD`
172
+ only has to be at or above the batch you expect to buy.
153
173
 
154
174
  To buy access to a whole site rather than one endpoint, call
155
175
  `payable_fetch({"url":"https://merchant.example/api/data","scope":"merchant"})`.
@@ -180,11 +200,15 @@ header on the payment requests (and on recovery of a pending payment).
180
200
  | `cursor`, `cursor-vscode` | `cursor` |
181
201
  | `windsurf` | `windsurf` |
182
202
  | `chatgpt`, `openai` | `chatgpt` |
203
+ | `codex-mcp-client` | `codex` |
183
204
  | `gemini` | `gemini` |
184
205
  | `perplexity` | `perplexity` |
185
206
 
186
207
  Names are matched exactly. Any other client sends no header; the server never
187
- guesses. Nothing in the payment, limits or receipts depends on it.
208
+ guesses. Nothing in the payment, limits or receipts depends on it. At
209
+ initialize the server logs one line to stderr with the name it received, for
210
+ example `[aifinpay-mcp] client "codex-mcp-client" → framework codex`, so a
211
+ client missing from this table can be reported with its exact name.
188
212
 
189
213
  ## Link the agent to its owner's dashboard
190
214
 
@@ -195,7 +219,8 @@ origins, signs only the claim challenge for this agent's own address, and moves
195
219
  no funds. The owner-selected payment family must be confirmed successfully;
196
220
  the second wallet is best-effort. Use the selected wallet's Fund panel for
197
221
  available networks and assets; binding does not activate a disabled network.
198
- Offer this to the owner after `init`.
222
+ Offer this to the owner after `init`: from then on the owner manages the
223
+ agent's working limits under Controls there (see "Owner limits" above).
199
224
 
200
225
  Private recovery state for all payment families lives at `AIFINPAY_HOME/payments/<evm-address>/state.json`
201
226
  (default home `~/.aifinpay`). State is mode600 in mode700 directories, atomically
@@ -338,9 +363,15 @@ passphrase, encrypts the keystore and prints one JSON document:
338
363
  The passphrase appears only inside `env`, because the caller must put it in
339
364
  the client config and there is no other channel; a process that captures that
340
365
  output captures the passphrase, so treat the output as a secret. A second run
341
- keeps the wallet and prints a placeholder instead of the passphrase. If the
342
- keystore exists and `AIFINPAY_WALLET_PASSPHRASE` is unset, `init` prints one
343
- line naming the variable and exits with status 2.
366
+ keeps the wallet and prints a placeholder instead of the passphrase. When
367
+ `AIFINPAY_HOME` is set, `env` also carries it (absolute), so the server reads the
368
+ keystore init wrote; `payment_setup_status` gives the init command with the
369
+ server's `AIFINPAY_HOME` for the same reason. If the keystore exists, is
370
+ encrypted and `AIFINPAY_WALLET_PASSPHRASE` is unset, `init` leaves it untouched,
371
+ prints one JSON line naming the variable and exits with status 2; its
372
+ `next_step` is to run init in a new, empty `AIFINPAY_HOME`
373
+ (`~/.aifinpay/agent-<yyyymmdd>`) and put the `env` it prints into the client
374
+ config.
344
375
 
345
376
  Select the wallet in this order: `SEED_HASH` → `./aifinpay/agents.json` →
346
377
  legacy `AIFINPAY_AGENT_SECRET` → `~/.aifinpay/agent.json`.
@@ -41,7 +41,7 @@ import {
41
41
  linkSync,
42
42
  unlinkSync,
43
43
  } from "node:fs";
44
- import { join } from "node:path";
44
+ import { join, resolve } from "node:path";
45
45
  import { homedir } from "node:os";
46
46
  import { createRequire } from "node:module";
47
47
  import { scryptSync, randomBytes, createCipheriv, createDecipheriv } from "node:crypto";
@@ -178,19 +178,31 @@ if (arg === "init") {
178
178
 
179
179
  const { loadConfigFromEnv } = await import("../dist/config.js");
180
180
  const { loadWalletIdentity } = await import("../dist/identity.js");
181
- const { PAYMENT_ENV } = await import("../dist/tools/payment-setup-status.js");
181
+ const { PAYMENT_ENV, lockedKeystoreStep } = await import("../dist/tools/payment-setup-status.js");
182
182
  const config = loadConfigFromEnv();
183
183
  // A keystore that cannot be opened is reported in one line that names the
184
- // variable, never as a stack trace — and never replaced.
184
+ // variable, never as a stack trace — and never replaced. An agent cannot ask
185
+ // anyone for the passphrase, so its JSON also names the way past it that
186
+ // touches nothing: a new wallet in a new, empty AIFINPAY_HOME.
185
187
  const failKeystore = (error) => {
186
188
  const line =
187
189
  !PASSPHRASE && existsSync(KEYSTORE)
188
190
  ? `${KEYSTORE} exists and is encrypted; set ${PASSPHRASE_ENV} to the passphrase used at init (it is not set in this environment).`
189
191
  : error.message;
192
+ let encrypted = false;
193
+ try {
194
+ encrypted = Boolean(JSON.parse(readFileSync(KEYSTORE, "utf8"))?.enc);
195
+ } catch {
196
+ /* No readable keystore: the error is about something else. */
197
+ }
190
198
  if (NONINTERACTIVE)
191
199
  process.stdout.write(
192
- JSON.stringify({ error: line, keystore: KEYSTORE, ...(PASSPHRASE ? {} : { missing_env: PASSPHRASE_ENV }) }) +
193
- "\n"
200
+ JSON.stringify({
201
+ error: line,
202
+ keystore: KEYSTORE,
203
+ ...(PASSPHRASE ? {} : { missing_env: PASSPHRASE_ENV }),
204
+ ...(encrypted ? { next_step: lockedKeystoreStep(KEYSTORE) } : {}),
205
+ }) + "\n"
194
206
  );
195
207
  else process.stderr.write(line + "\n");
196
208
  process.exit(2);
@@ -205,6 +217,10 @@ if (arg === "init") {
205
217
  const addressesOf = (agent) => ({ evm: agent.evmAddress, solana: agent.solanaAddress, casper: agent.casperAddress });
206
218
  const indexEnv =
207
219
  selected?.derivationIndex === undefined ? {} : { AIFINPAY_WALLET_INDEX: String(selected.derivationIndex) };
220
+ // The server reads the keystore (and keeps its payment journal) under the same
221
+ // AIFINPAY_HOME init used, so a non-default one goes into the client env too,
222
+ // absolute: the client does not start the server in this directory.
223
+ const homeEnv = process.env.AIFINPAY_HOME ? { AIFINPAY_HOME: resolve(process.env.AIFINPAY_HOME) } : {};
208
224
  // Non-interactive stdout is one JSON document and nothing else, so the
209
225
  // caller can parse it. The same facts, as prose, go to a terminal.
210
226
  const emit = (json, text) => process.stdout.write(NONINTERACTIVE ? JSON.stringify(json, null, 2) + "\n" : text);
@@ -222,7 +238,7 @@ if (arg === "init") {
222
238
  encrypted: null,
223
239
  source: selected.source,
224
240
  addresses: addressesOf(agent),
225
- env: indexEnv,
241
+ env: { ...homeEnv, ...indexEnv },
226
242
  payment_env_example: PAYMENT_ENV,
227
243
  next_step: nextStep,
228
244
  },
@@ -316,6 +332,7 @@ if (arg === "init") {
316
332
  source: "legacy-keystore",
317
333
  addresses: addressesOf(agent),
318
334
  env: {
335
+ ...homeEnv,
319
336
  ...(encrypted
320
337
  ? {
321
338
  [PASSPHRASE_ENV]: GENERATED_PASSPHRASE
@@ -383,6 +400,7 @@ if (arg === "init") {
383
400
  command: "npx",
384
401
  args: ["-y", `@aifinpay/mcp@${VERSION}`],
385
402
  env: {
403
+ ...homeEnv,
386
404
  ...(encrypted ? { AIFINPAY_WALLET_PASSPHRASE: "<the passphrase you used for init>" } : {}),
387
405
  ...indexEnv,
388
406
  },
@@ -409,20 +427,24 @@ if (arg === "init") {
409
427
  ` replace the example. No wildcards.\n` +
410
428
  ` AIFINPAY_GATEWAY_PATH_MODE "direct" for a site that runs its own AiFinPay\n` +
411
429
  ` paywall, "gateway" for gateway.aifinpay.io.\n` +
412
- ` AIFINPAY_MAX_USD per payment. The smallest batch is $0.10, so\n` +
413
- ` keep it a little above the batch you expect.\n` +
414
- ` AIFINPAY_DAILY_USD total over any 24 hours.\n` +
430
+ ` AIFINPAY_MAX_USD per payment, a ceiling set once (the smallest\n` +
431
+ ` batch is $0.10; the example is not a budget).\n` +
432
+ ` AIFINPAY_DAILY_USD total over any 24 hours, the same kind of ceiling.\n` +
433
+ ` Day-to-day limits: dashboard Controls, once the\n` +
434
+ ` agent is claimed (see below).\n` +
415
435
  ` AIFINPAY_MAX_GAS_POL worst-case network fee of one payment, checked\n` +
416
436
  ` before signing. It follows Polygon's gas price:\n` +
417
437
  ` at ~280 gwei it is ~0.10 POL paying in POL and\n` +
418
438
  ` ~0.21 POL paying in USDC. A lower cap refuses\n` +
419
439
  ` the payment; raise it when gas is higher.\n\n` +
420
- `Fund the EVM address on Polygon with the batch price plus the gas cap, in POL.\n` +
440
+ `Fund the EVM address on Polygon with the batch price at today's rate plus the\n` +
441
+ `gas cap, in POL; payment_setup_status prices it.\n` +
421
442
  `To pay in USDC, also set "AIFINPAY_PAY_ASSET": "USDC" and hold USDC for the\n` +
422
443
  `batch plus POL up to the gas cap. Check the balance before funding or paying.\n\n` +
423
444
  `See its balance, payments and receipts in your dashboard:\n` +
424
445
  ` https://dash.aifinpay.io → My Agents → Claim via MCP, then give the\n` +
425
- ` one-time URL to the agent (tool agent_claim_self).\n`
446
+ ` one-time URL to the agent (tool agent_claim_self). Controls there set the\n` +
447
+ ` working limits; the env values above stay as the ceiling.\n`
426
448
  );
427
449
  process.exit(0);
428
450
  }
@@ -1,3 +1,9 @@
1
1
  import type { AgentFramework } from "@aifinpay/agent";
2
2
  export declare function frameworkForClient(name: unknown): AgentFramework | undefined;
3
+ /**
4
+ * One stderr line per connection, so a client the table does not know shows up
5
+ * in the server log instead of silently sending no header. The name is the
6
+ * client's own public identifier, never a secret.
7
+ */
8
+ export declare function clientFrameworkLine(name: unknown): string;
3
9
  //# sourceMappingURL=client-framework.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-framework.d.ts","sourceRoot":"","sources":["../src/client-framework.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAqBtD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAE5E"}
1
+ {"version":3,"file":"client-framework.d.ts","sourceRoot":"","sources":["../src/client-framework.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAyBtD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAGzD"}
@@ -2,8 +2,11 @@
2
2
  * MCP `clientInfo.name`, as the client sent it at initialize, → the
3
3
  * AIFP-Agent-Framework the backend records. Exact names only: a client not
4
4
  * listed here sends no header rather than a guess. Entries are the names the
5
- * product owner listed plus `cursor-vscode`, which Cursor is reported to send;
6
- * confirm new ones against real initialize payloads before adding them.
5
+ * product owner listed plus `cursor-vscode`, which Cursor is reported to send,
6
+ * and `codex-mcp-client`, which Codex sends (openai/codex
7
+ * codex-rs/codex-mcp/src/rmcp_client.rs, `Implementation::new("codex-mcp-client", …)`);
8
+ * confirm new ones against real initialize payloads before adding them. The
9
+ * server logs every client's name at initialize so an unlisted one is visible.
7
10
  */
8
11
  const CLIENT_FRAMEWORKS = new Map([
9
12
  ["claude-ai", "claude"],
@@ -13,10 +16,20 @@ const CLIENT_FRAMEWORKS = new Map([
13
16
  ["windsurf", "windsurf"],
14
17
  ["chatgpt", "chatgpt"],
15
18
  ["openai", "chatgpt"],
19
+ ["codex-mcp-client", "codex"],
16
20
  ["gemini", "gemini"],
17
21
  ["perplexity", "perplexity"],
18
22
  ]);
19
23
  export function frameworkForClient(name) {
20
24
  return typeof name === "string" ? CLIENT_FRAMEWORKS.get(name) : undefined;
21
25
  }
26
+ /**
27
+ * One stderr line per connection, so a client the table does not know shows up
28
+ * in the server log instead of silently sending no header. The name is the
29
+ * client's own public identifier, never a secret.
30
+ */
31
+ export function clientFrameworkLine(name) {
32
+ const client = typeof name === "string" ? JSON.stringify(name) : "(unnamed)";
33
+ return `[aifinpay-mcp] client ${client} → framework ${frameworkForClient(name) ?? "none"}`;
34
+ }
22
35
  //# sourceMappingURL=client-framework.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-framework.js","sourceRoot":"","sources":["../src/client-framework.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAyB;IACxD,CAAC,WAAW,EAAE,QAAQ,CAAC;IACvB,CAAC,aAAa,EAAE,QAAQ,CAAC;IACzB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,eAAe,EAAE,QAAQ,CAAC;IAC3B,CAAC,UAAU,EAAE,UAAU,CAAC;IACxB,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,QAAQ,EAAE,SAAS,CAAC;IACrB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,YAAY,EAAE,YAAY,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,IAAa;IAC9C,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC"}
1
+ {"version":3,"file":"client-framework.js","sourceRoot":"","sources":["../src/client-framework.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAyB;IACxD,CAAC,WAAW,EAAE,QAAQ,CAAC;IACvB,CAAC,aAAa,EA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M,WAAW,WAAW;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,+HAA+H;IAC/H,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAQnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAS7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAgCvD;iFACiF;AACjF,wBAAsB,YAAY,CAAC,MAAM,GAAE,SAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+MxD;AA2BD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,+HAA+H;IAC/H,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D"}
package/dist/server.js CHANGED
@@ -12,11 +12,11 @@ import { makeSafeFetch } from "./safe-fetch.js";
12
12
  import { loadConfigFromEnv, validatePaymentConfig } from "./config.js";
13
13
  import { PaymentStateStore } from "./payment-state.js";
14
14
  import { payableFetchTool, runPayableFetch } from "./tools/payable-fetch.js";
15
- import { paymentSetupStatusTool, runPaymentSetupStatus } from "./tools/payment-setup-status.js";
15
+ import { initCommand, paymentSetupStatusTool, runPaymentSetupStatus } from "./tools/payment-setup-status.js";
16
16
  import { agentPassportResolveTool, runAgentPassportResolve, settlementRoutesTool, runSettlementRoutes, settlementInvoiceTool, runSettlementInvoice, settlementSolanaTool, runSettlementSolana, settlementCasperTool, runSettlementCasper, } from "./tools/production-control.js";
17
17
  import { deploymentInfoTool, runDeploymentInfo } from "./tools/supported-chains.js";
18
18
  import { payChain } from "./pay-chains.js";
19
- import { frameworkForClient } from "./client-framework.js";
19
+ import { clientFrameworkLine, frameworkForClient } from "./client-framework.js";
20
20
  // Every backend/public request made by this server goes through safeFetch.
21
21
  // Public deployments never lift private-network protection; local development
22
22
  // may explicitly use AIFINPAY_ALLOW_PRIVATE_FETCH=1.
@@ -26,6 +26,7 @@ const safeFetch = makeSafeFetch({
26
26
  // for those names — see safe-fetch.ts for why this is not a proxy switch.
27
27
  trustedHosts: loadConfigFromEnv().trustedHosts,
28
28
  });
29
+ const RELOAD_ENV_NOTE = "Owner limits and AIFINPAY_PAYMENTS_ENABLED are read only when this server starts; agent_reload re-reads the keystore and nothing else. If the owner has saved them since, have the client restart the aifinpay MCP server (restart the client, or disable and re-enable the server), then call payment_setup_status.";
29
30
  /** Read-only by default. Explicit owner configuration enables the reviewed
30
31
  * family-specific v1.4 payable_fetch path; legacy signing tools stay retired. */
31
32
  export async function createServer(config = {}) {
@@ -62,7 +63,7 @@ export async function createServer(config = {}) {
62
63
  }));
63
64
  identitySource = configured?.source ?? "ephemeral";
64
65
  if (!configured)
65
- log("warn", "[aifinpay-mcp] EPHEMERAL wallet — DO NOT FUND. Run `npx @aifinpay/mcp init`, then agent_reload in this connection.");
66
+ log("warn", `[aifinpay-mcp] EPHEMERAL wallet — DO NOT FUND. Run \`${initCommand(config.walletHome)}\`, then agent_reload in this connection.`);
66
67
  let paymentState;
67
68
  if (config.paymentsEnabled) {
68
69
  validatePaymentConfig(config);
@@ -82,6 +83,10 @@ export async function createServer(config = {}) {
82
83
  name: "@aifinpay/mcp",
83
84
  version: JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version,
84
85
  }, { capabilities: { tools: {}, resources: {} } });
86
+ // The client names itself at initialize. Logging it is how an unlisted name
87
+ // gets found: the 2026-10-19 Codex payment showed as "Independent" because
88
+ // "codex-mcp-client" was not in the table and nothing said what was sent.
89
+ server.oninitialized = () => log("info", clientFrameworkLine(server.getClientVersion()?.name));
85
90
  server.setRequestHandler(ListResourcesRequestSchema, async () => ({
86
91
  resources: [
87
92
  {
@@ -113,7 +118,7 @@ export async function createServer(config = {}) {
113
118
  agentClaimSelfTool(),
114
119
  {
115
120
  name: "agent_reload",
116
- description: "Reload the configured local wallet files after init or a file update, without starting a new conversation. Returns public addresses only. Shell environment changes still require reconnecting the MCP process.",
121
+ description: "Reload the configured local wallet files after init or a file update, without starting a new conversation. Returns public addresses only. Owner limits and other env changes take effect only after the client restarts the aifinpay MCP server; agent_reload does not read them.",
117
122
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
118
123
  annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
119
124
  },
@@ -162,6 +167,11 @@ export async function createServer(config = {}) {
162
167
  evm: agent.evmAddress,
163
168
  casper: agent.casperAddress,
164
169
  reloaded: true,
170
+ // A reload that succeeds while payments stay off read as "the
171
+ // env was not picked up", and an agent stopped there
172
+ // (2026-10-19): config is fixed at start, so say so.
173
+ payments_enabled: Boolean(config.paymentsEnabled),
174
+ ...(config.paymentsEnabled ? {} : { env_note: RELOAD_ENV_NOTE }),
165
175
  }),
166
176
  },
167
177
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAA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AM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,eAAe,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,yDAAyD,QAAQ,CAAC,IAAI,KAAK,eAAe,GAAG,CAAC,CAAC;IACjH,CAAC;AACH,CAAC;AAaD,SAAS,UAAU,CAAC,KAAgC,EAAE,GAAW;IAC/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,GAAG,IAAI,CAAC,CAAC;AAC9C,CAAC"}
@@ -17,11 +17,28 @@ export declare const PAYMENT_ENV: Readonly<{
17
17
  AIFINPAY_PAYMENTS_ENABLED: "1";
18
18
  AIFINPAY_GATEWAY_ORIGINS: "https://merchant.example";
19
19
  AIFINPAY_GATEWAY_PATH_MODE: "direct";
20
- AIFINPAY_MAX_USD: "0.15";
21
- AIFINPAY_DAILY_USD: "1.00";
20
+ AIFINPAY_MAX_USD: "5";
21
+ AIFINPAY_DAILY_USD: "20";
22
22
  AIFINPAY_MAX_GAS_POL: "0.3";
23
23
  }>;
24
+ /** Where the owner manages the working limits once the agent is claimed. */
25
+ export declare const CONTROLS_NOTE = "The USD env values are a ceiling the owner sets once, not the budget: after agent_claim_self the owner sets the working limits (per-payment cap, daily cap, pause, allowed sites) in the dashboard Controls at https://dash.aifinpay.io, and the backend enforces them on every quote and payment.";
24
26
  export declare const INIT_COMMAND = "npx @aifinpay/mcp init";
27
+ /**
28
+ * init, run so that it writes the keystore this server reads. An agent's shell
29
+ * does not have the server's AIFINPAY_HOME, so a bare `npx @aifinpay/mcp init`
30
+ * wrote ~/.aifinpay/agent.json while the server kept looking elsewhere.
31
+ */
32
+ export declare function initCommand(walletHome: string | undefined): string;
33
+ /** A directory that does not exist yet, for a new wallet beside one that cannot be opened. */
34
+ export declare function freshWalletHome(now?: Date): string;
35
+ /**
36
+ * The way past an encrypted keystore nobody here can open. init and the server
37
+ * both refuse to replace it, rightly: it may hold funds. Without this the agent
38
+ * had a refusal and no next move, and the next move it invented was its own key
39
+ * handling. A new, empty AIFINPAY_HOME leaves the old file untouched.
40
+ */
41
+ export declare function lockedKeystoreStep(keystore: string): string;
25
42
  interface Limit {
26
43
  env: string;
27
44
  set: boolean;
@@ -52,8 +69,28 @@ export interface PaymentSetupStatus {
52
69
  rpc: string;
53
70
  } | "unknown";
54
71
  balance_error?: string;
72
+ /** What to fund a persistent wallet with, priced now; absent for an ephemeral wallet. */
73
+ funding?: Funding;
55
74
  next_step: string;
56
75
  }
76
+ export interface Funding {
77
+ address: string;
78
+ chain: string;
79
+ asset: string;
80
+ batch_usd: number;
81
+ /** The native/USD rate read for this answer; absent when no price source answered. */
82
+ rate_usd?: number;
83
+ rate_source?: string;
84
+ rate_error?: string;
85
+ /** The smallest batch at that rate. */
86
+ batch_native?: string;
87
+ /** The owner's gas cap, when set. */
88
+ gas_cap?: string;
89
+ /** batch_native plus gas_cap: the amount to fund, when both are known. */
90
+ amount?: string;
91
+ /** The sentence to give the owner. Names a number only when one was read. */
92
+ advice: string;
93
+ }
57
94
  export declare function paymentSetupStatusTool(): {
58
95
  name: string;
59
96
  description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"payment-setup-status.d.ts","sourceRoot":"","sources":["../../src/tools/payment-setup-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAIrE;;;;;;;;;;GAUG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAMtC,eAAO,MAAM,WAAW;;;;;;;EAOtB,CAAC;AAEH,eAAO,MAAM,YAAY,2BAA2B,CAAC;AAErD,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,k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W,EAAE,OAAO,CAAA;CAAE,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAmG7B"}
@@ -1,3 +1,6 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join, resolve } from "node:path";
1
4
  import { validatePaymentConfig } from "../config.js";
2
5
  import { independentNativeUsd } from "../native-price.js";
3
6
  import { payChain } from "../pay-chains.js";
@@ -16,22 +19,76 @@ import { payChain } from "../pay-chains.js";
16
19
  export const SMALLEST_BATCH_USD = 0.1;
17
20
  // The owner settings that let payable_fetch sign, as init prints them. README
18
21
  // "Enable native paid GET requests" shows the same block; a test keeps the two
19
- // equal and starts a server with it. The gas cap is a worst case at the current
20
- // Polygon gas price, not the fee: 0.05 POL refused every payment at ~280 gwei.
22
+ // equal and starts a server with it. The USD values are a ceiling the owner
23
+ // sets once, not the budget: the working limits (per-payment cap, daily cap,
24
+ // pause, allowed sites) live in the dashboard Controls once the agent is
25
+ // claimed, and the backend enforces those on every quote and payment. The gas
26
+ // cap is a worst case at the current Polygon gas price, not the fee: 0.05 POL
27
+ // refused every payment at ~280 gwei.
21
28
  export const PAYMENT_ENV = Object.freeze({
22
29
  AIFINPAY_PAYMENTS_ENABLED: "1",
23
30
  AIFINPAY_GATEWAY_ORIGINS: "https://merchant.example",
24
31
  AIFINPAY_GATEWAY_PATH_MODE: "direct",
25
- AIFINPAY_MAX_USD: "0.15",
26
- AIFINPAY_DAILY_USD: "1.00",
32
+ AIFINPAY_MAX_USD: "5",
33
+ AIFINPAY_DAILY_USD: "20",
27
34
  AIFINPAY_MAX_GAS_POL: "0.3",
28
35
  });
36
+ /** Where the owner manages the working limits once the agent is claimed. */
37
+ export const CONTROLS_NOTE = "The USD env values are a ceiling the owner sets once, not the budget: after agent_claim_self the owner sets the working limits (per-payment cap, daily cap, pause, allowed sites) in the dashboard Controls at https://dash.aifinpay.io, and the backend enforces them on every quote and payment.";
29
38
  export const INIT_COMMAND = "npx @aifinpay/mcp init";
39
+ /** POSIX single quotes: the path reaches init byte for byte, spaces and quotes included. */
40
+ function shellQuote(value) {
41
+ return `'${value.replace(/'/g, `'\\''`)}'`;
42
+ }
43
+ /**
44
+ * init, run so that it writes the keystore this server reads. An agent's shell
45
+ * does not have the server's AIFINPAY_HOME, so a bare `npx @aifinpay/mcp init`
46
+ * wrote ~/.aifinpay/agent.json while the server kept looking elsewhere.
47
+ */
48
+ export function initCommand(walletHome) {
49
+ return walletHome ? `AIFINPAY_HOME=${shellQuote(resolve(walletHome))} ${INIT_COMMAND}` : INIT_COMMAND;
50
+ }
51
+ /** A directory that does not exist yet, for a new wallet beside one that cannot be opened. */
52
+ export function freshWalletHome(now = new Date()) {
53
+ const base = join(homedir(), ".aifinpay", `agent-${now.toISOString().slice(0, 10).replace(/-/g, "")}`);
54
+ for (let n = 1;; n++) {
55
+ const candidate = n === 1 ? base : `${base}-${n}`;
56
+ if (!existsSync(candidate))
57
+ return candidate;
58
+ }
59
+ }
60
+ /**
61
+ * The way past an encrypted keystore nobody here can open. init and the server
62
+ * both refuse to replace it, rightly: it may hold funds. Without this the agent
63
+ * had a refusal and no next move, and the next move it invented was its own key
64
+ * handling. A new, empty AIFINPAY_HOME leaves the old file untouched.
65
+ */
66
+ export function lockedKeystoreStep(keystore) {
67
+ return (`${keystore} is an encrypted wallet that cannot be opened here: AIFINPAY_WALLET_PASSPHRASE is not set or is wrong. ` +
68
+ `Do not delete, move or overwrite it; it may hold funds. ` +
69
+ `If its passphrase is known, set AIFINPAY_WALLET_PASSPHRASE in the aifinpay server's env in the MCP client config and reconnect. ` +
70
+ `Otherwise create a new wallet in a new, empty directory: run \`${initCommand(freshWalletHome())}\`, ` +
71
+ `put the "env" it prints (it includes AIFINPAY_HOME) into the aifinpay server's env in the MCP client config, ` +
72
+ `reconnect the server, then call agent_reload and payment_setup_status again.`);
73
+ }
74
+ /** The keystore this server reads, when it is encrypted and the server has no passphrase for it. */
75
+ function lockedKeystore(config) {
76
+ if (config.walletPassphrase)
77
+ return undefined;
78
+ const keystore = join(resolve(config.walletHome || join(homedir(), ".aifinpay")), "agent.json");
79
+ try {
80
+ return JSON.parse(readFileSync(keystore, "utf8"))?.enc ? keystore : undefined;
81
+ }
82
+ catch {
83
+ return undefined;
84
+ }
85
+ }
30
86
  export function paymentSetupStatusTool() {
31
87
  return {
32
88
  name: "payment_setup_status",
33
89
  description: "Read-only checklist for paying with payable_fetch: wallet (persistent or ephemeral), whether the owner enabled payments, which owner limits are set, the wallet's native balance on the pay chain when readable, and next_step — exactly one instruction for the first unmet item. " +
34
- "First payment in five steps: (1) GET the resource and read its 402 (merchant, price, smallest batch); (2) call payment_setup_status; (3) no persistent wallet: run `npx @aifinpay/mcp init` without a terminal, put its printed env into the MCP client config, reconnect, agent_reload; (4) tell the owner the address and the amount to fund, and have the owner add the payment env (AIFINPAY_PAYMENTS_ENABLED=1, origins, USD limits, gas cap) and reconnect; (5) payable_fetch the URL. " +
90
+ "First payment in five steps: (1) GET the resource and read its 402 (merchant, price, smallest batch); (2) call payment_setup_status; (3) no persistent wallet: run `npx @aifinpay/mcp init` without a terminal, put its printed env into the MCP client config, reconnect, agent_reload; (4) tell the owner the address and the amount in `funding` (the smallest batch at today's rate plus the gas cap; if no rate could be read, ask for the batch price in the native currency at today's rate plus the gas cap and name no number), and have the owner add the payment env (AIFINPAY_PAYMENTS_ENABLED=1, origins, a USD ceiling, gas cap) and restart the server; (5) payable_fetch the URL. " +
91
+ "The env USD values are a one-time ceiling; after agent_claim_self the owner manages the working limits in the dashboard Controls. " +
35
92
  "Signs nothing, moves nothing, never asks the owner's limits from the model.",
36
93
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
37
94
  annotations: { readOnlyHint: true, openWorldHint: true, destructiveHint: false },
@@ -101,41 +158,49 @@ export async function paymentSetupStatus(ctx, options) {
101
158
  next_step: "",
102
159
  };
103
160
  if (!persistent) {
161
+ const locked = lockedKeystore(config);
104
162
  status.next_step =
105
163
  `No persistent wallet: this server started with an ephemeral one — do not fund ${ctx.agent.evmAddress}. ` +
106
- `Run \`${INIT_COMMAND}\` (without a terminal it prints JSON; copy its "env" into this server's env in the MCP client config), reconnect the server, then call agent_reload and payment_setup_status again.`;
164
+ (locked
165
+ ? lockedKeystoreStep(locked)
166
+ : `Run \`${initCommand(config.walletHome)}\` (without a terminal it prints JSON; copy its "env" into this server's env in the MCP client config), reconnect the server, then call agent_reload and payment_setup_status again.`);
107
167
  return status;
108
168
  }
169
+ // The amount to fund is answered before payments are enabled too: step 4
170
+ // ("tell the owner the address and the amount") happens with payments still
171
+ // off, and the 2026-10-19 quote priced $0.10 at 1.08 POL while the guide
172
+ // still said 0.5 — no fixed rate survives, so the tool reads one now.
173
+ const gasCap = status.limits.gas_cap.set && Number(status.limits.gas_cap.value) > 0 ? String(status.limits.gas_cap.value) : undefined;
174
+ const rpc = config.rpcUrl ?? chain.defaultRpc;
175
+ if (options.readBalance && chain.name !== "solana") {
176
+ status.funding = await funding(ctx, chain, rpc, gasCap);
177
+ }
109
178
  if (!config.paymentsEnabled || configError) {
110
179
  const block = JSON.stringify(paymentEnvFor(config));
111
180
  status.next_step =
112
181
  (configError && config.paymentsEnabled
113
182
  ? `Owner setting refused: ${configError}. `
114
183
  : `Payments are off until the owner enables them. `) +
115
- `Have the owner add this to the server's env in the MCP client config (their real site origin and limits, not the example), then reconnect: ${block}` +
116
- (configError && !config.paymentsEnabled ? ` Currently missing: ${configError}` : "");
184
+ (status.funding ? `${status.funding.advice} ` : "") +
185
+ `Have the owner add this to the server's env in the MCP client config (their real site origin, not the example; ${CONTROLS_NOTE}), then reconnect: ${block}` +
186
+ (configError && !config.paymentsEnabled ? ` Currently missing: ${configError}` : "") +
187
+ // The env is read once, at start. An agent that saw agent_reload succeed
188
+ // and payments stay off concluded the settings were lost, and stopped.
189
+ (config.paymentsEnabled
190
+ ? ""
191
+ : ` If the owner has already saved these settings, this server has not been restarted since: agent_reload does not read env. Have the client restart the aifinpay MCP server, then call payment_setup_status again.`);
117
192
  return status;
118
193
  }
119
- const gasCap = Number(status.limits.gas_cap.value);
120
- if (options.readBalance && chain.name !== "solana") {
121
- const rpc = config.rpcUrl ?? chain.defaultRpc;
194
+ if (status.funding) {
122
195
  try {
123
196
  const balance = await nativeBalance(ctx, rpc, ctx.agent.evmAddress);
124
197
  status.balance = { amount: formatNative(balance), asset: chain.native, chain: chain.name, rpc };
125
- const price = await independentNativeUsd({
126
- fetchImpl: (input, init) => ctx.agent.inner.fetchImpl(input, init),
127
- chain,
128
- rpc,
129
- }).catch(() => undefined);
130
- const batchNative = price ? SMALLEST_BATCH_USD / price.usd : 0;
131
- const needed = batchNative + gasCap;
198
+ const needed = status.funding.amount !== undefined ? Number(status.funding.amount) : Number(gasCap);
132
199
  if (Number(status.balance.amount) < needed) {
133
200
  status.next_step =
134
- `Fund ${ctx.agent.evmAddress} on ${chain.label} with about ${needed.toFixed(2)} ${chain.native}` +
135
- (price
136
- ? ` (the smallest batch is $${SMALLEST_BATCH_USD.toFixed(2)} ≈ ${batchNative.toFixed(4)} ${chain.native} plus up to ${gasCap} ${chain.native} gas; it holds ${status.balance.amount})`
137
- : ` (at least the gas cap of ${gasCap} ${chain.native} plus the batch price; it holds ${status.balance.amount})`) +
138
- `, then call payment_setup_status again.`;
201
+ status.funding.amount !== undefined
202
+ ? `Fund ${ctx.agent.evmAddress} on ${chain.label} with about ${status.funding.amount} ${chain.native} (the smallest batch is $${SMALLEST_BATCH_USD.toFixed(2)} ≈ ${status.funding.batch_native} ${chain.native} at today's rate plus up to ${gasCap} ${chain.native} gas; it holds ${status.balance.amount}), then call payment_setup_status again.`
203
+ : `Fund ${ctx.agent.evmAddress} on ${chain.label} with the batch price in ${chain.native} at today's rate plus the gas cap of ${gasCap} ${chain.native} (the rate could not be read here, so ask the owner to look it up; it holds ${status.balance.amount}), then call payment_setup_status again.`;
139
204
  return status;
140
205
  }
141
206
  }
@@ -146,12 +211,65 @@ export async function paymentSetupStatus(ctx, options) {
146
211
  status.ready = true;
147
212
  status.next_step =
148
213
  `Ready. Call payable_fetch({"url": "<HTTPS resource on ${config.gatewayOrigins.join(" or ")}>"}); ` +
149
- `it pays at most $${config.maxAmountUsd} per call and $${config.dailyAmountUsd} per 24 hours, with gas capped at ${status.limits.gas_cap.value} ${chain.native}.` +
214
+ `it pays at most $${config.maxAmountUsd} per call and $${config.dailyAmountUsd} per 24 hours, with gas capped at ${status.limits.gas_cap.value} ${chain.native}. ` +
215
+ CONTROLS_NOTE +
150
216
  (status.balance === "unknown"
151
- ? ` The wallet must hold the batch price plus up to the gas cap in ${chain.native} on ${chain.label}.`
217
+ ? ` The wallet must hold the batch price plus up to the gas cap in ${chain.native} on ${chain.label}` +
218
+ (status.funding?.amount !== undefined ? ` (about ${status.funding.amount} ${chain.native} at today's rate).` : ".")
152
219
  : "");
153
220
  return status;
154
221
  }
222
+ /**
223
+ * The amount to fund, priced now. Never a fixed rate: the number comes from
224
+ * the same independent price sources payable_fetch uses, and when none
225
+ * answers the advice says so and names no number, so the agent asks the owner
226
+ * for "the batch price at today's rate plus the gas cap" instead of inventing one.
227
+ */
228
+ async function funding(ctx, chain, rpc, gasCap) {
229
+ const address = ctx.agent.evmAddress;
230
+ const base = {
231
+ address,
232
+ chain: chain.name,
233
+ asset: chain.native,
234
+ batch_usd: SMALLEST_BATCH_USD,
235
+ ...(gasCap !== undefined ? { gas_cap: gasCap } : {}),
236
+ advice: "",
237
+ };
238
+ const batch = `the smallest batch ($${SMALLEST_BATCH_USD.toFixed(2)})`;
239
+ const cap = gasCap !== undefined ? `the gas cap of ${gasCap} ${chain.native}` : "the gas cap the owner sets";
240
+ try {
241
+ const price = await independentNativeUsd({
242
+ fetchImpl: (input, init) => ctx.agent.inner.fetchImpl(input, init),
243
+ chain,
244
+ rpc,
245
+ });
246
+ const batchNative = SMALLEST_BATCH_USD / price.usd;
247
+ const funded = {
248
+ ...base,
249
+ rate_usd: price.usd,
250
+ rate_source: price.source,
251
+ batch_native: formatAmount(batchNative, 4),
252
+ };
253
+ if (gasCap === undefined) {
254
+ funded.advice = `Fund ${address} on ${chain.label} with ${batch} ≈ ${funded.batch_native} ${chain.native} at today's rate ($${formatAmount(price.usd, 4)}/${chain.native}) plus ${cap}.`;
255
+ return funded;
256
+ }
257
+ funded.amount = formatAmount(batchNative + Number(gasCap), 2);
258
+ funded.advice = `Fund ${address} on ${chain.label} with about ${funded.amount} ${chain.native}: ${batch} ≈ ${funded.batch_native} ${chain.native} at today's rate ($${formatAmount(price.usd, 4)}/${chain.native}) plus up to ${gasCap} ${chain.native} gas.`;
259
+ return funded;
260
+ }
261
+ catch (error) {
262
+ return {
263
+ ...base,
264
+ rate_error: error.message,
265
+ advice: `The ${chain.native}/USD rate could not be read here, so name no amount: ask the owner to fund ${address} on ${chain.label} with the price of ${batch} in ${chain.native} at today's rate plus ${cap}.`,
266
+ };
267
+ }
268
+ }
269
+ /** Fixed decimals for readable amounts; more for ones that would round to zero (ETH on Base). */
270
+ function formatAmount(value, decimals) {
271
+ return value.toFixed(value >= 0.01 || value === 0 ? decimals : 6);
272
+ }
155
273
  function unready(ctx, source, chain, error) {
156
274
  return {
157
275
  ready: false,
@@ -1 +1 @@
1
- {"version":3,"file":"payment-setup-status.js","sourceRoot":"","sources":["../../src/tools/payment-setup-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAiB,MAAM,kBAAkB,CAAC;AAE3D;;;;;;;;;;GAUG;AAEH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,yBAAyB,EAAE,GAAG;IAC9B,wBAAwB,EAAE,0BAA0B;IACpD,0BAA0B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Name": "io.github.daochild/aifinpay",
5
5
  "description": "AiFinPay MCP: persistent local agent wallets, owner-configured EVM and Solana payment adapters, durable budgets and receipt recovery.",
6
6
  "type": "module",
@@ -76,8 +76,8 @@
76
76
  },
77
77
  "bugs": "https://github.com/AiFinPay/sdk/issues",
78
78
  "dependencies": {
79
- "@aifinpay/agent": "^2.8.0",
80
- "@aifinpay/skill": "^2.10.0",
79
+ "@aifinpay/agent": "^2.9.0",
80
+ "@aifinpay/skill": "^2.10.2",
81
81
  "@modelcontextprotocol/sdk": "^1.0.0",
82
82
  "bs58": "^6.0.0",
83
83
  "tweetnacl": "^1.0.3"
package/skills/SKILL.md CHANGED
@@ -6,7 +6,7 @@ description: Pay for x402-gated APIs and sites as an agent (AIFP-1 on an owner-s
6
6
  wallet, payment history, prepaid quotas and Agent Passport records through
7
7
  the AiFinPay MCP server or SDK.
8
8
  license: MIT
9
- version: 2.10.0
9
+ version: 2.10.2
10
10
  author: AiFinPay Support
11
11
  metadata:
12
12
  hermes:
@@ -61,17 +61,17 @@ your language. There is no "install together" scenario.
61
61
 
62
62
  ## Version and release status
63
63
 
64
- Release target: MCP **2.11.0**, Node SDK **2.8.0**, Python **2.7.0**.
64
+ Release target: MCP **2.11.3**, Node SDK **2.9.0**, Python **2.7.0**.
65
65
  This skill describes that coordinated package cohort. Check the installed
66
66
  versions before using its additional-network instructions; a release target
67
67
  does not establish npm/PyPI publication or production network activation.
68
- Published baseline checked 2026-10-19: MCP **2.10.0**, Node SDK **2.8.0**.
68
+ Published baseline checked 2026-10-19: MCP **2.11.2**, Node SDK **2.8.0**.
69
69
  `payable_fetch` has shipped since MCP 2.2.0, and Base since MCP 2.5.0.
70
70
  Published packages remain usable within their documented capabilities.
71
71
 
72
72
  | Surface | Can it pay? |
73
73
  |---|---|
74
- | MCP `@aifinpay/mcp` 2.11.x | `payable_fetch`, only with a persistent wallet and every owner limit set; it is always listed and, until then, answers with the setup checklist instead of signing. `payment_setup_status` is the read-only checklist with one `next_step`. Polygon is the default; other networks require explicit `AIFINPAY_PAY_CHAIN`. The merchant and backend must authorize and serve that network. `scope: "merchant"` buys a site-wide batch. |
74
+ | MCP `@aifinpay/mcp` 2.11.x | `payable_fetch`, only with a persistent wallet and every owner limit set; it is always listed and, until then, answers with the setup checklist instead of signing. `payment_setup_status` is the read-only checklist with one `next_step` and, from 2.11.3, `funding`: the amount to fund at today's rate. Polygon is the default; other networks require explicit `AIFINPAY_PAY_CHAIN`. The merchant and backend must authorize and serve that network. `scope: "merchant"` buys a site-wide batch. |
75
75
  | Node `@aifinpay/agent` 2.8.x | `fetchPaid` with a v14 journal, gas cap and owner budgets. Select another network with `v14.chain`; select a pinned stablecoin with `v14.asset`. Native payments require an independent native/USD rate. |
76
76
  | Python `aifinpay-agent` 2.7.x | `agent.fetch_paid(url, allowed_origins=…, max_amount_usd=…, daily_amount_usd=…)`; use explicit `chain` and the chain's native gas cap for another network, or a pinned stablecoin `asset`. `agent.recover_paid(journal_path)` recovers the original transaction. |
77
77
 
@@ -192,23 +192,41 @@ step — no key handling of your own, no funding of an ephemeral address.
192
192
  example `$0.10` for 200 standard requests).
193
193
  2. **Check the setup.** Call `payment_setup_status`. It returns the wallet
194
194
  (`persistent` or ephemeral), `payments_enabled`, which owner limits are
195
- set, the balance when the RPC answers, `ready`, and `next_step` — the one
196
- thing still missing. Follow `next_step`; do not skip ahead.
197
- 3. **Persistent wallet.** If `wallet.persistent` is false, run
198
- `npx @aifinpay/mcp init`. Without a terminal it does not prompt: it
199
- generates the passphrase, writes the keystore and prints one JSON document
200
- with `addresses` and an `env` block. Put that `env` into the `aifinpay`
201
- server entry of the MCP client config (the passphrase is only there — the
202
- output is a secret, and a second run never reprints it), reconnect the
203
- server, then call `agent_reload`. Never fund an ephemeral address.
195
+ set, the balance when the RPC answers, `funding` (what a persistent wallet
196
+ needs, priced now), `ready`, and `next_step` — the one thing still
197
+ missing. Follow `next_step`; do not skip ahead.
198
+ 3. **Persistent wallet.** If `wallet.persistent` is false, run the exact
199
+ command in `next_step` (it is `npx @aifinpay/mcp init`, prefixed with
200
+ `AIFINPAY_HOME=…` when the server uses its own wallet directory — keep
201
+ that prefix, or the server will not see the keystore). Without a terminal
202
+ init does not prompt: it generates the passphrase, writes the keystore and
203
+ prints one JSON document with `addresses` and an `env` block. Put that
204
+ `env` into the `aifinpay` server entry of the MCP client config (the
205
+ passphrase is only there — the output is a secret, and a second run never
206
+ reprints it), then call `agent_reload`: it reads the keystore and switches
207
+ this server to the persistent wallet. If init answers that a keystore
208
+ already exists and cannot be opened, do not delete or replace it: follow
209
+ its `next_step` and start a new wallet directory. Never fund an ephemeral
210
+ address.
204
211
  4. **Fund and enable.** Tell the owner `addresses.evm` and the amount: the
205
- batch price in the pay chain's native currency plus the gas cap (on
206
- Polygon, about `0.5 POL` covers one `$0.10` batch plus a `0.3 POL` cap).
207
- When the owner confirms funding, they add the payment settings from
208
- "Paying with payable_fetch" below — with their real origin and limits —
209
- to the same `env` and reconnect. `payment_setup_status` then reports
210
- `ready: true`. Funding, origins and limits are the owner's decisions;
211
- never choose them yourself.
212
+ batch price in the pay chain's native currency at today's rate plus the
213
+ gas cap. Take it from `payment_setup_status` — its `funding` field prices
214
+ the smallest batch now and adds the owner's gas cap into `amount`. The
215
+ rate moves (on 2026-10-19 one `$0.10` batch was 1.08 POL), so never
216
+ quote a remembered number; if `funding` has a `rate_error` and no
217
+ `amount`, ask the owner to fund "the batch price in POL at today's rate
218
+ plus the gas cap" and name no number. When the owner confirms funding,
219
+ they add the payment settings from "Paying with payable_fetch" below —
220
+ with their real origin, and USD values that are a ceiling they will not
221
+ need to revisit (the working limits are set in the dashboard, see "After
222
+ creating a wallet") — to the same `env`. **Limits are read only when the server starts**:
223
+ `agent_reload` re-reads the keystore and nothing else, so after the env
224
+ changes the client has to restart the `aifinpay` MCP server (restart the
225
+ client, or disable and re-enable the server in it). Until that restart
226
+ `payment_setup_status` keeps reporting `payments_enabled: false`; that is
227
+ expected, not a refusal — say so, ask the owner for the restart, and stop.
228
+ After it, `payment_setup_status` reports `ready: true`. Funding, origins
229
+ and limits are the owner's decisions; never choose them yourself.
212
230
  5. **Pay.** `payable_fetch({"url":"<origin><path>"})` (add
213
231
  `"scope":"merchant"` for a site-wide batch) buys the batch and returns the
214
232
  content with the receipt summary. Later requests reuse the batch.
@@ -238,9 +256,10 @@ into ratersapp.com", "купи доступ до цього сайту". Handle
238
256
  persistent wallet first, then the owner's funding and environment block
239
257
  with this origin in `AIFINPAY_GATEWAY_ORIGINS` (and
240
258
  `AIFINPAY_GATEWAY_PATH_MODE=direct` when the 402 comes from the site
241
- itself) — and stop until the owner has done their part. Adding a site,
242
- raising a limit and funding the wallet are the owner's decisions; never
243
- make them on your own initiative.
259
+ itself) — and stop until the owner has done their part. Env changes take
260
+ effect only after the client restarts the `aifinpay` server; `agent_reload`
261
+ does not read them. Adding a site, raising a limit and funding the wallet
262
+ are the owner's decisions; never make them on your own initiative.
244
263
  5. **Buy.** `payable_fetch({"url":"<origin><path>","scope":"merchant"})`, where
245
264
  the path is what the owner wants to read, or a standard resource from the
246
265
  discovery document.
@@ -259,21 +278,28 @@ default `scope`.
259
278
 
260
279
  ## Paying with payable_fetch
261
280
 
262
- The owner configures these MCP environment values (example limits only):
281
+ The owner configures these MCP environment values once (example values; the
282
+ USD ones are a ceiling, not a budget):
263
283
 
264
284
  ```json
265
285
  {
266
286
  "AIFINPAY_PAYMENTS_ENABLED": "1",
267
287
  "AIFINPAY_GATEWAY_ORIGINS": "https://merchant.example",
268
288
  "AIFINPAY_GATEWAY_PATH_MODE": "direct",
269
- "AIFINPAY_MAX_USD": "0.15",
270
- "AIFINPAY_DAILY_USD": "1.00",
289
+ "AIFINPAY_MAX_USD": "5",
290
+ "AIFINPAY_DAILY_USD": "20",
271
291
  "AIFINPAY_MAX_GAS_POL": "0.3"
272
292
  }
273
293
  ```
274
294
 
275
- The smallest batch is **$0.10 plus gas** on **Polygon**; keep `AIFINPAY_MAX_USD`
276
- a little above the batch you expect to buy. The gas cap has to cover the
295
+ `AIFINPAY_MAX_USD` and `AIFINPAY_DAILY_USD` are the ceiling the SDK requires
296
+ before it signs with the owner's key: set once, high enough not to need
297
+ revisiting, and left alone. The day-to-day limits — per-payment cap, daily
298
+ cap, pause, allowed sites — are the dashboard **Controls** once the agent is
299
+ claimed (see "After creating a wallet" below); the backend enforces them on
300
+ every quote and payment, with no env change and no server restart. A payment
301
+ has to pass both. The smallest batch is **$0.10 plus gas** on **Polygon**;
302
+ `AIFINPAY_MAX_USD` only has to be at or above the batch. The gas cap has to cover the
277
303
  worst-case fee: at ~280 gwei that is about 0.10 POL for a POL payment and
278
304
  0.21 POL for USDC, and a lower cap refuses before anything is signed. The fee
279
305
  charged is usually a fraction of that, but the wallet must hold the batch plus
@@ -286,8 +312,9 @@ wallet or create one with `npx @aifinpay/mcp init` (on a terminal it asks for
286
312
  a passphrase; without one it generates it and prints the `env` block to put
287
313
  into the MCP client config — the server's env needs that same
288
314
  `AIFINPAY_WALLET_PASSPHRASE`, or every start mints a new ephemeral wallet);
289
- fund its EVM address on Polygon with POL, or with USDC plus some POL. Funding a wallet does not establish
290
- unlimited spend authority. Use the owner's actual approved limits and origins,
315
+ fund its EVM address on Polygon with POL, or with USDC plus some POL, in the
316
+ amount `payment_setup_status` prices. Funding a wallet does not establish
317
+ unlimited spend authority. Use the owner's actual approved origins and ceiling,
291
318
  then call `payable_fetch({"url":"https://merchant.example/api/data"})`.
292
319
 
293
320
  For another network, the owner sets `AIFINPAY_PAY_CHAIN` to an exact name in
@@ -358,10 +385,16 @@ at https://dash.aifinpay.io → My Agents:
358
385
  `agent.sign_dashboard_claim(challenge)` (Python). These sign only
359
386
  `AiFinPay-claim:polygon:<own address>:<nonce>`.
360
387
 
361
- Keep local owner spending limits in the agent's configuration (`AIFINPAY_MAX_USD`,
362
- `AIFINPAY_DAILY_USD`). Claimed-wallet controls in the dashboard are additional
363
- backend restrictions on quotes and gateway access; they do not replace local
364
- limits or control transactions sent directly outside AiFinPay.
388
+ Once the agent is claimed, the dashboard is where the owner manages its
389
+ working limits: **Controls** on the agent's page sets the per-payment cap, the
390
+ daily cap, pause and the allowed sites, and the backend enforces that policy
391
+ on every `/v1/quote` and `/v1/pay` for the claimed agent — no env change, no
392
+ server restart. The env values (`AIFINPAY_MAX_USD`, `AIFINPAY_DAILY_USD`, the
393
+ gas cap, the origins) stay as the ceiling the SDK requires before it signs;
394
+ they do not replace the dashboard, and the dashboard does not replace them —
395
+ a payment has to pass both. Dashboard controls do not reach transactions sent
396
+ directly outside AiFinPay. After `agent_claim_self`, point the owner at
397
+ Controls rather than at the config file when they want to change a limit.
365
398
 
366
399
  Discover routes on the exact requested origin: `/.well-known/x402.json` and any
367
400
  API catalog linked by that site. A dev hostname does not imply testnet. If a