@aifinpay/mcp 2.3.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,14 +4,16 @@ 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.2.4**. Owner-enabled native Polygon v1.4 purchases with
8
- `payable_fetch` are released (since 2.2.0). Without payment configuration the
9
- server keeps its inspection-only tool inventory.
7
+ Version **2.5.0**. Owner-enabled v1.4 purchases with `payable_fetch` are
8
+ released: on Polygon since 2.2.0, on Base (ETH or USDC) since 2.5.0; site-wide
9
+ batches with `scope: "merchant"` since 2.4.1. Without payment configuration the server keeps
10
+ its inspection-only tool inventory.
10
11
 
11
12
  ## Enable native paid GET requests
12
13
 
13
14
  Use a persistent wallet created with public `npx @aifinpay/mcp init` or an
14
- existing configured identity. Keep its passphrase private. The owner must set:
15
+ existing configured identity. Keep its passphrase private. The owner adds these
16
+ to the server's `env` (`init` prints the same block):
15
17
 
16
18
  ```json
17
19
  {
@@ -20,36 +22,81 @@ existing configured identity. Keep its passphrase private. The owner must set:
20
22
  "AIFINPAY_GATEWAY_PATH_MODE": "direct",
21
23
  "AIFINPAY_MAX_USD": "0.15",
22
24
  "AIFINPAY_DAILY_USD": "1.00",
23
- "AIFINPAY_MAX_GAS_POL": "0.05"
25
+ "AIFINPAY_MAX_GAS_POL": "0.3"
24
26
  }
25
27
  ```
26
28
 
27
29
  Limits are examples, not authorization. USD limits cover purchases; gas has its
28
- own per-transaction POL cap. Origins are exact HTTPS origins authorized by the
30
+ own POL cap. Origins are exact HTTPS origins authorized by the
29
31
  owner. `direct` uses the full path for self-hosted sites; `gateway` uses the
30
32
  merchant slug on the hosted gateway. Restart/reconnect the MCP process after
31
33
  changing its environment.
32
34
 
35
+ `AIFINPAY_MAX_GAS_POL` caps the worst case, not the fee you expect to pay.
36
+ Before signing, the client prices the estimated gas plus 20% at the maximum fee
37
+ per gas the Polygon RPC quotes, and refuses with `V14_GAS_BUDGET_EXCEEDED` if
38
+ that exceeds the cap. The worst case follows the gas price: at about 280 gwei
39
+ (September 2026) it is about 0.10 POL for a POL payment and about 0.21 POL for
40
+ USDC, which needs a token approval and the settlement. `0.3` covers both at that
41
+ price; check the current Polygon gas price and raise the cap when it is higher.
42
+ The fee actually charged is usually a fraction of the cap, but the wallet must
43
+ hold the batch price plus the worst case before it signs.
44
+
33
45
  To pay in USDC instead of native POL, the owner also sets
34
- `"AIFINPAY_PAY_ASSET": "USDC"`. The wallet then needs USDC for the batch and a
35
- little POL for gas (an exact-amount token approval plus the settlement, both
36
- within `AIFINPAY_MAX_GAS_POL` together). Unset or `"POL"` keeps native POL.
46
+ `"AIFINPAY_PAY_ASSET": "USDC"`. The wallet then needs USDC for the batch and
47
+ POL for gas: an exact-amount token approval plus the settlement, both within
48
+ `AIFINPAY_MAX_GAS_POL` together. Unset or `"POL"` keeps native POL.
49
+
50
+ ### Paying on another chain
51
+
52
+ `AIFINPAY_PAY_CHAIN` picks the chain `payable_fetch` settles on: `polygon`
53
+ (default) or `base`. Only the owner sets it, and a merchant is paid on a chain
54
+ only if its quote is for that chain; a quote for any other chain is refused,
55
+ never followed. On Base the batch is paid in ETH (or `AIFINPAY_PAY_ASSET:
56
+ "USDC"`) and gas is ETH, so the cap is `AIFINPAY_MAX_GAS`, in ETH:
57
+
58
+ ```json
59
+ {
60
+ "AIFINPAY_PAY_CHAIN": "base",
61
+ "AIFINPAY_MAX_GAS": "0.0002"
62
+ }
63
+ ```
64
+
65
+ `AIFINPAY_MAX_GAS` is the gas cap in the pay chain's native currency;
66
+ `AIFINPAY_MAX_GAS_POL` remains accepted on Polygon and is refused on Base rather
67
+ than read as ETH (0.3 POL is about $0.04; 0.3 ETH is several hundred dollars).
68
+ On Base the worst case includes the L1 data fee, typically well under 0.0001 ETH
69
+ for one settlement. The wallet's EVM address is the same on every chain, so
70
+ fund it with ETH on Base, not on Ethereum mainnet. `AIFINPAY_RPC_URL` optionally
71
+ replaces the chain's public RPC (`https://mainnet.base.org`,
72
+ `https://polygon.drpc.org`).
73
+
74
+ A payment still pending on one chain is recovered only with that chain
75
+ configured; switching chains never re-sends or forgets it.
37
76
 
38
77
  Call `payable_fetch({"url":"https://merchant.example/api/data"})`. The tool
39
- uses the original signed v1.4 quote, independent fresh POL/USD pricing, SDK
78
+ uses the original signed v1.4 quote, independent fresh native/USD pricing, SDK
40
79
  runtime/signer verification and owner limits. It persists the prepared transaction
41
80
  before sending, verifies the receipt, and reuses the purchased batch. No special
42
- merchant script, alternate contract or facilitator fallback is used. GET,
43
- Polygon live mode only, in POL or the configured stablecoin; Amoy payment
44
- receipts are not supported. The smallest batch is $0.10 plus gas, so keep `AIFINPAY_MAX_USD`
81
+ merchant script, alternate contract or facilitator fallback is used. GET, live
82
+ mode only, on the configured chain, in its native currency or the configured
83
+ stablecoin; Amoy payment receipts are not supported. The smallest batch is $0.10 plus gas, so keep `AIFINPAY_MAX_USD`
45
84
  a little above the batch you expect to buy.
46
85
 
86
+ To buy access to a whole site rather than one endpoint, call
87
+ `payable_fetch({"url":"https://merchant.example/api/data","scope":"merchant"})`.
88
+ One batch then covers every path on that merchant, and each request still costs
89
+ its own listed price, so a premium page drains more of it than a standard API
90
+ call. The price, the owner limits and the approved origins do not change. An
91
+ origin missing from `AIFINPAY_GATEWAY_ORIGINS` is refused by name; only the
92
+ owner can add it.
93
+
47
94
  ### Network access
48
95
 
49
96
  A sandbox that allowlists outbound hosts must allow `api.aifinpay.io` (quotes and
50
- receipts) and a Polygon RPC. The independent POL/USD rate comes from Chainlink
51
- on Polygon over that same RPC, then `api.coinbase.com`, then `api.coingecko.com`;
52
- one of them is enough. If none answers, `payable_fetch` stops before paying and
97
+ receipts) and an RPC for the pay chain. The independent POL/USD or ETH/USD rate
98
+ comes from Chainlink on that chain over the same RPC, then `api.coinbase.com`,
99
+ then `api.coingecko.com`; one of them is enough. If none answers, `payable_fetch` stops before paying and
53
100
  the error names each host it tried.
54
101
 
55
102
  ## Link the agent to its owner's dashboard
@@ -80,10 +127,18 @@ state file in chat. Unconfirmed payments consume the budget conservatively.
80
127
  | `agent_passport_resolve` | Resolve the global Agent Passport identity. |
81
128
  | `settlement_routes` | Read the available verified settlement routes. |
82
129
  | `settlement_invoice` | Prepare a non-signing settlement invoice. |
83
-
84
- `payable_fetch` appears only with valid owner payment configuration and a persistent wallet.
85
- Legacy `agent_call`, `agent_quote`, `pay_with_split` and `quote_split` remain
86
- unregistered.
130
+ | `agent_history` | Read indexed settlements or retained receipt batches. |
131
+ | `settlement_solana` | Build a non-signing Solana settlement invoice. |
132
+ | `settlement_casper` | Build a non-signing Casper settlement invoice. |
133
+ | `deployment_info` | Read deployments: addresses, assets, settlement status. |
134
+
135
+ `payable_fetch` is registered when the owner sets `AIFINPAY_PAYMENTS_ENABLED=1`
136
+ with a persistent wallet. With payments enabled and any owner limit missing or
137
+ invalid, the server refuses to start rather than hiding the tool. It accepts
138
+ only `url`, `max_amount_usd` and `scope`; `max_amount_usd` can lower the owner's
139
+ per-payment cap for one call, never raise it. `dev_payment_quote` is registered
140
+ only with `AIFINPAY_MODE=dev`. Legacy `agent_call`, `agent_quote`,
141
+ `pay_with_split` and `quote_split` remain unregistered.
87
142
 
88
143
  ## Persistent wallet selection
89
144
 
@@ -142,7 +197,7 @@ A client configuration can use the keystore without embedding its secret:
142
197
  "mcpServers": {
143
198
  "aifinpay": {
144
199
  "command": "npx",
145
- "args": ["-y", "@aifinpay/mcp@2.2.0"],
200
+ "args": ["-y", "@aifinpay/mcp@2.5.0"],
146
201
  "env": {
147
202
  "AIFINPAY_AGENTS_FILE": "/absolute/project/aifinpay/agents.json",
148
203
  "AIFINPAY_AGENT_ID": "research-agent"
@@ -158,8 +213,12 @@ After the pinned dependencies are published, source checkouts can run
158
213
  `node /absolute/path/to/mcp/bin/aifinpay-mcp.js` instead.
159
214
 
160
215
  If using the legacy keystore, run `npx @aifinpay/mcp init` once and omit the
161
- project-file variables. Optional `AIFINPAY_WALLET_PASSPHRASE` encrypts that
162
- legacy file at creation. An already connected server can load it with
216
+ project-file variables. `AIFINPAY_WALLET_PASSPHRASE` encrypts that legacy file
217
+ at creation, and the server's `env` needs the same value to open it; `init`
218
+ prints a block with a placeholder for it. Clients that expand variables in their
219
+ config, such as Claude Code's `.mcp.json`, can use
220
+ `"${AIFINPAY_WALLET_PASSPHRASE}"` instead of writing the passphrase into the
221
+ file. An already connected server can load it with
163
222
  `agent_reload`; it does not need a new conversation. A changed package or
164
223
  launch environment requires a server reconnect, subject to host support.
165
224
 
@@ -173,13 +232,17 @@ snapshot. Verify `agent_address` against the wallet you intend to use.
173
232
 
174
233
  ## Other environment variables
175
234
 
176
- | Variable | Default | Purpose |
177
- | ---------------------------- | --------------------- | ------------------------------------------------------------------------------------ |
178
- | `AIFINPAY_BASE_URL` | `https://aifinpay.io` | Backend URL. |
179
- | `AIFINPAY_TIMEOUT_MS` | `30000` | Request timeout. |
180
- | `AIFINPAY_MAX_USD` | — | Configures the underlying agent's per-call cap; it does not enable signing. |
181
- | `AIFINPAY_GATEWAY_ORIGINS` | SDK default | Comma-separated exact HTTPS origins trusted for AIFP-1 settlement. |
182
- | `AIFINPAY_GATEWAY_PATH_MODE` | `gateway` | Use `gateway` for merchant-slug identity or `direct` for full request-path identity. |
235
+ | Variable | Default | Purpose |
236
+ | ---------------------------- | --------------------- | ------------------------------------------------------------------------------------- |
237
+ | `AIFINPAY_BASE_URL` | `https://aifinpay.io` | Backend URL. Unset, `payable_fetch` quotes and verifies at `https://api.aifinpay.io`. |
238
+ | `AIFINPAY_TIMEOUT_MS` | `30000` | Request timeout. |
239
+ | `AIFINPAY_MAX_USD` | — | Per-payment USD cap for `payable_fetch`; required when payments are enabled. |
240
+ | `AIFINPAY_GATEWAY_ORIGINS` | — | Comma-separated exact HTTPS origins the agent may pay; required with payments. |
241
+ | `AIFINPAY_GATEWAY_PATH_MODE` | `gateway` | Use `gateway` for merchant-slug identity or `direct` for full request-path identity. |
242
+ | `AIFINPAY_PAY_CHAIN` | `polygon` | Chain `payable_fetch` settles on: `polygon` or `base`. |
243
+ | `AIFINPAY_MAX_GAS` | — | Gas cap per payment in the pay chain's native currency (POL, ETH). |
244
+ | `AIFINPAY_RPC_URL` | chain's public RPC | HTTPS RPC for the pay chain. |
245
+ | `AIFINPAY_CLAIM_ORIGINS` | AiFinPay dashboards | Exact origins `agent_claim_self` may link the agent to. |
183
246
 
184
247
  `agent_history({address, source:"transactions"})` reads indexed Polygon
185
248
  settlements; `source:"receipts"` reads retained batches, including test-mode
@@ -204,7 +267,7 @@ The programmatic equivalents of identity environment options are `seedHash`,
204
267
  - AIFINPAY_MODE=dev: expose dev_payment_quote; requires a separate dev base URL.
205
268
 
206
269
  - AIFINPAY_TIMEOUT_MS: SDK request timeout.
207
- - AIFINPAY_MAX_USD: legacy per-call budget; does not enable signing.
270
+ - AIFINPAY_MAX_USD: per-payment USD cap for payable_fetch; required with payments.
208
271
  - AIFINPAY_TRUSTED_HOSTS: exact hosts allowed to bypass the DNS pre-check.
209
272
  - AIFINPAY_ALLOW_PRIVATE_FETCH=1: explicit local-development network access.
210
273
  Never enable this on the public hosted MCP.
@@ -77,10 +77,14 @@ it up automatically — you do not have to put the secret in a config file.
77
77
 
78
78
  Env (all optional):
79
79
  SEED_HASH 32-byte hex seed; highest priority\n AIFINPAY_AGENTS_FILE default ./aifinpay/agents.json; second priority\n AIFINPAY_AGENT_ID select one record when the file has multiple agents\n AIFINPAY_AGENT_SECRET legacy base58 secret; after project wallet sources
80
- AIFINPAY_MAX_USD hard cap per single payment — set this
80
+ AIFINPAY_WALLET_PASSPHRASE opens an encrypted keystore; the server needs it too
81
81
  AIFINPAY_BASE_URL default https://aifinpay.io
82
82
  AIFINPAY_TIMEOUT_MS default 30000
83
83
  AIFINPAY_HOME default ~/.aifinpay
84
+
85
+ Payments (payable_fetch) are off until the owner sets all of
86
+ AIFINPAY_PAYMENTS_ENABLED=1, AIFINPAY_GATEWAY_ORIGINS, AIFINPAY_MAX_USD,
87
+ AIFINPAY_DAILY_USD and AIFINPAY_MAX_GAS_POL. init prints an example block.
84
88
  `);
85
89
  process.exit(0);
86
90
  }
@@ -152,6 +156,19 @@ function readKeystore() {
152
156
  return typeof parsed?.secretB58 === "string" ? parsed : null;
153
157
  }
154
158
 
159
+ // The owner settings that register payable_fetch, as init prints them. README
160
+ // "Enable native paid GET requests" shows the same block; a test keeps the two
161
+ // equal and starts a server with it. The gas cap is a worst case at the current
162
+ // Polygon gas price, not the fee: 0.05 POL refused every payment at ~280 gwei.
163
+ const PAYMENT_ENV = {
164
+ AIFINPAY_PAYMENTS_ENABLED: "1",
165
+ AIFINPAY_GATEWAY_ORIGINS: "https://merchant.example",
166
+ AIFINPAY_GATEWAY_PATH_MODE: "direct",
167
+ AIFINPAY_MAX_USD: "0.15",
168
+ AIFINPAY_DAILY_USD: "1.00",
169
+ AIFINPAY_MAX_GAS_POL: "0.3",
170
+ };
171
+
155
172
  if (arg === "init") {
156
173
  const { Agent, AiFinPayAgent } = await import("@aifinpay/agent");
157
174
 
@@ -249,36 +266,59 @@ if (arg === "init") {
249
266
  }
250
267
 
251
268
  const agent = await AiFinPayAgent.fromSolanaSecret(store.secretB58);
269
+ // The server cannot open an encrypted keystore without the passphrase, so a
270
+ // config block without it does not start.
271
+ const encrypted = freshlyCreated ? Boolean(PASSPHRASE) : Boolean(store.encrypted);
252
272
 
253
273
  process.stdout.write(
254
274
  `Your agent's addresses — the EVM one is the same on every EVM chain:\n\n` +
255
275
  ` EVM ${agent.evmAddress}\n` +
256
276
  ` Solana ${agent.solanaAddress}\n` +
257
277
  ` Casper ${agent.casperAddress}\n\n` +
258
- `Add this to your MCP client config and connect/reconnect this MCP server:\n\n` +
278
+ `Add this to your MCP client config and connect/reconnect this MCP server.\n` +
279
+ `As printed it cannot pay; payable_fetch appears once you add the payment\n` +
280
+ `settings further down:\n\n` +
259
281
  JSON.stringify(
260
282
  {
261
283
  mcpServers: {
262
284
  aifinpay: {
263
285
  command: "npx",
264
286
  args: ["-y", `@aifinpay/mcp@${VERSION}`],
265
- env: { AIFINPAY_MAX_USD: "0.10" },
287
+ env: encrypted ? { AIFINPAY_WALLET_PASSPHRASE: "<the passphrase you used for init>" } : {},
266
288
  },
267
289
  },
268
290
  },
269
291
  null,
270
292
  2
271
293
  ) +
272
- `\n\nThe secret is NOT in that block on purpose — the server reads the\n` +
294
+ `\n\n` +
295
+ (encrypted
296
+ ? `The server opens the encrypted wallet with AIFINPAY_WALLET_PASSPHRASE. If your\n` +
297
+ `client expands variables in its config (Claude Code's .mcp.json does), write\n` +
298
+ `"\${AIFINPAY_WALLET_PASSPHRASE}" there instead of the passphrase itself.\n`
299
+ : "") +
300
+ `The wallet secret is NOT in that block on purpose — the server reads the\n` +
273
301
  `keystore. If this server is already connected, call agent_reload after init.\nA new conversation is not required by this server.\n\n` +
274
302
  `Back up ${KEYSTORE}. It is the only copy. The derivation is not\n` +
275
303
  `BIP-39, so no standard wallet can recover this from a phrase.\n\n` +
276
- `The EVM address is used for Polygon payments. Check its balance before\n` +
277
- `funding it or paying for calls.\n\n` +
278
- `To let it pay, fund the EVM address with POL on Polygon (the smallest\n` +
279
- `batch is $0.10 plus gas) and add to the env block above:\n` +
280
- ` AIFINPAY_PAYMENTS_ENABLED=1 AIFINPAY_MAX_USD=0.15 AIFINPAY_DAILY_USD=1.00\n` +
281
- ` AIFINPAY_MAX_GAS_POL=0.05 AIFINPAY_GATEWAY_ORIGINS=https://<site it may pay>\n\n` +
304
+ `To let it pay, add these to "env" above, then reconnect the server:\n\n` +
305
+ JSON.stringify(PAYMENT_ENV, null, 2) +
306
+ `\n\n` +
307
+ ` AIFINPAY_GATEWAY_ORIGINS exact HTTPS origins it may pay, comma-separated;\n` +
308
+ ` replace the example. No wildcards.\n` +
309
+ ` AIFINPAY_GATEWAY_PATH_MODE "direct" for a site that runs its own AiFinPay\n` +
310
+ ` paywall, "gateway" for gateway.aifinpay.io.\n` +
311
+ ` AIFINPAY_MAX_USD per payment. The smallest batch is $0.10, so\n` +
312
+ ` keep it a little above the batch you expect.\n` +
313
+ ` AIFINPAY_DAILY_USD total over any 24 hours.\n` +
314
+ ` AIFINPAY_MAX_GAS_POL worst-case network fee of one payment, checked\n` +
315
+ ` before signing. It follows Polygon's gas price:\n` +
316
+ ` at ~280 gwei it is ~0.10 POL paying in POL and\n` +
317
+ ` ~0.21 POL paying in USDC. A lower cap refuses\n` +
318
+ ` the payment; raise it when gas is higher.\n\n` +
319
+ `Fund the EVM address on Polygon with the batch price plus the gas cap, in POL.\n` +
320
+ `To pay in USDC, also set "AIFINPAY_PAY_ASSET": "USDC" and hold USDC for the\n` +
321
+ `batch plus POL up to the gas cap. Check the balance before funding or paying.\n\n` +
282
322
  `See its balance, payments and receipts in your dashboard:\n` +
283
323
  ` https://dash.aifinpay.io → My Agents → Claim via MCP, then give the\n` +
284
324
  ` one-time URL to the agent (tool agent_claim_self).\n`
package/dist/config.d.ts CHANGED
@@ -17,9 +17,17 @@ export interface McpConfig {
17
17
  /** Owner opt-in; never accepted from tool arguments. */
18
18
  paymentsEnabled?: boolean;
19
19
  dailyAmountUsd?: number;
20
+ /** Chain payable_fetch settles on: "polygon" (default) or "base". Set by
21
+ * the owner only; never inferred from a quote or a tool argument. */
22
+ payChain?: string;
23
+ /** RPC for the pay chain; defaults to the chain's public RPC. */
24
+ rpcUrl?: string;
25
+ /** Gas cap per payment, in the pay chain's native currency (POL, ETH). */
26
+ maxGas?: string;
27
+ /** Same cap under its original name; accepted on Polygon only. */
20
28
  maxGasPol?: string;
21
- /** What payable_fetch pays with: "POL" (default) or a stablecoin the SDK
22
- * pins for Polygon v1.4, e.g. "USDC". Gas is paid in POL either way. */
29
+ /** What payable_fetch pays with: the chain's native currency (default) or a
30
+ * stablecoin the SDK pins for that chain, e.g. "USDC". Gas is native either way. */
23
31
  payAsset?: string;
24
32
  /** Hard cap on a single payment to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,EAAE,MAAM,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,iBAAiB,IAAI,SAAS,CA6B7C;AA0DD,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAuD/D"}
package/dist/config.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { payChain } from "./pay-chains.js";
1
2
  export function loadConfigFromEnv() {
2
3
  if (process.env.AIFINPAY_MODE && !["live", "dev"].includes(process.env.AIFINPAY_MODE)) {
3
4
  throw new Error("AIFINPAY_MODE must be live or dev");
@@ -8,6 +9,9 @@ export function loadConfigFromEnv() {
8
9
  return {
9
10
  paymentsEnabled: process.env.AIFINPAY_PAYMENTS_ENABLED === "1",
10
11
  dailyAmountUsd: process.env.AIFINPAY_DAILY_USD ? Number(process.env.AIFINPAY_DAILY_USD) : undefined,
12
+ payChain: process.env.AIFINPAY_PAY_CHAIN || undefined,
13
+ rpcUrl: process.env.AIFINPAY_RPC_URL || undefined,
14
+ maxGas: process.env.AIFINPAY_MAX_GAS || undefined,
11
15
  maxGasPol: process.env.AIFINPAY_MAX_GAS_POL || undefined,
12
16
  payAsset: process.env.AIFINPAY_PAY_ASSET || undefined,
13
17
  devMode: process.env.AIFINPAY_MODE === "dev",
@@ -84,7 +88,19 @@ export function validatePaymentConfig(config) {
84
88
  if (!config.paymentsEnabled)
85
89
  throw new Error("Payments disabled; owner must set AIFINPAY_PAYMENTS_ENABLED=1");
86
90
  if (config.devMode)
87
- throw new Error("MCP receipt payments currently support Polygon live mode only");
91
+ throw new Error("MCP receipt payments support live mode only");
92
+ const chain = payChain(config.payChain);
93
+ if (config.rpcUrl !== undefined) {
94
+ let rpc;
95
+ try {
96
+ rpc = new URL(config.rpcUrl);
97
+ }
98
+ catch {
99
+ rpc = undefined;
100
+ }
101
+ if (!rpc || rpc.protocol !== "https:" || rpc.username || rpc.password)
102
+ throw new Error("AIFINPAY_RPC_URL must be an https URL without credentials");
103
+ }
88
104
  for (const [name, value] of [
89
105
  ["AIFINPAY_MAX_USD", config.maxAmountUsd],
90
106
  ["AIFINPAY_DAILY_USD", config.dailyAmountUsd],
@@ -104,14 +120,21 @@ export function validatePaymentConfig(config) {
104
120
  }))
105
121
  throw new Error("Payments require explicit exact HTTPS AIFINPAY_GATEWAY_ORIGINS");
106
122
  if (config.payAsset !== undefined && !/^[A-Z][A-Z0-9.]{1,11}$/.test(config.payAsset))
107
- throw new Error('AIFINPAY_PAY_ASSET must be "POL" or a stablecoin symbol such as "USDC"');
108
- const gas = config.maxGasPol;
123
+ throw new Error(`AIFINPAY_PAY_ASSET must be "${chain.native}" or a stablecoin symbol such as "USDC"`);
124
+ // The POL-named cap means POL. Read on another chain it would silently cap
125
+ // ETH gas at a number chosen for POL — 0.3 POL is ~$0.04, 0.3 ETH is ~$800.
126
+ if (config.maxGasPol !== undefined && chain.name !== "polygon")
127
+ throw new Error(`AIFINPAY_MAX_GAS_POL caps POL gas and does not apply on ${chain.name}; set AIFINPAY_MAX_GAS in ${chain.native}`);
128
+ if (config.maxGas !== undefined && config.maxGasPol !== undefined && config.maxGas !== config.maxGasPol)
129
+ throw new Error("AIFINPAY_MAX_GAS and AIFINPAY_MAX_GAS_POL disagree; set one");
130
+ const name = config.maxGas !== undefined ? "AIFINPAY_MAX_GAS" : "AIFINPAY_MAX_GAS_POL";
131
+ const gas = config.maxGas ?? config.maxGasPol;
109
132
  if (typeof gas !== "string" || !/^(?:0|[1-9][0-9]*)(?:\.[0-9]{1,18})?$/.test(gas))
110
- throw new Error("AIFINPAY_MAX_GAS_POL must be a positive decimal with at most 18 places");
133
+ throw new Error(`${name} must be a positive decimal with at most 18 places: the gas cap per payment in ${chain.native}`);
111
134
  const [whole, fraction = ""] = gas.split(".");
112
135
  const wei = BigInt(whole) * 10n ** 18n + BigInt(fraction.padEnd(18, "0"));
113
136
  if (wei <= 0n || wei >= 2n ** 256n)
114
- throw new Error("AIFINPAY_MAX_GAS_POL is outside the supported range");
137
+ throw new Error(`${name} is outside the supported range`);
115
138
  return wei;
116
139
  }
117
140
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA+DA,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QACtF,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE,CAAC;QACzG,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO;QACL,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,KAAK,GAAG;QAC9D,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS;QACnG,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,SAAS;QACxD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,SAAS;QACrD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,KAAK;QAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS;QAC/B,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,SAAS;QACzD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,SAAS;QACnD,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,SA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AQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1E,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,iCAAiC,CAAC,CAAC;IAC9F,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  *
5
5
  * Tools: public addresses, history, quotas, passport resolution, non-signing
6
6
  * settlement invoices, local wallet reload, and opt-in dev batch quoting.
7
- * Signing tools are not registered in this RC.
7
+ * The one signing tool, payable_fetch, is registered only when the owner
8
+ * enables payments with every limit set.
8
9
  *
9
10
  * Quick start (stdio transport for Claude Desktop / MCP-aware runtimes):
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@
4
4
  *
5
5
  * Tools: public addresses, history, quotas, passport resolution, non-signing
6
6
  * settlement invoices, local wallet reload, and opt-in dev batch quoting.
7
- * Signing tools are not registered in this RC.
7
+ * The one signing tool, payable_fetch, is registered only when the owner
8
+ * enables payments with every limit set.
8
9
  *
9
10
  * Quick start (stdio transport for Claude Desktop / MCP-aware runtimes):
10
11
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { type PayChain } from "./pay-chains.js";
1
2
  /**
2
- * Independent POL/USD rate for payable_fetch.
3
+ * Independent native/USD rate for payable_fetch: POL on Polygon, ETH on Base.
3
4
  *
4
5
  * payable_fetch values a v1.4 quote in USD with a rate it fetches itself —
5
6
  * never the quote API's own — so the owner's per-payment and daily USD limits
@@ -9,23 +10,31 @@
9
10
  * it began, with nothing to try instead.
10
11
  *
11
12
  * Sources, in order; the first fresh, sane answer wins:
12
- * 1. Chainlink POL/USD on Polygon, read over the agent's own Polygon RPC —
13
- * the host the payment already needs, so no extra allowlist entry.
13
+ * 1. Chainlink <native>/USD on the payment chain, read over the agent's own
14
+ * RPC for that chain — the host the payment already needs, so no extra
15
+ * allowlist entry.
14
16
  * 2. api.coinbase.com spot price.
15
- * 3. api.coingecko.com, id polygon-ecosystem-token. NOT matic-network: that
16
- * id stopped updating in February 2026 and answers a stale, higher price.
17
+ * 3. api.coingecko.com.
18
+ * Feed addresses and ids live in pay-chains.ts.
17
19
  */
18
- export declare const CHAINLINK_POL_USD_POLYGON = "0xAB594600376Ec9fD91F8e885dADF0CE036862dE0";
20
+ export declare const CHAINLINK_POL_USD_POLYGON: `0x${string}`;
19
21
  export interface NativePrice {
20
22
  usd: number;
21
23
  observedAtMs: number;
22
- source: "chainlink-polygon" | "coinbase" | "coingecko";
24
+ source: `chainlink-${string}` | "coinbase" | "coingecko";
23
25
  }
24
26
  type FetchImpl = (input: string, init?: RequestInit) => Promise<Response>;
25
27
  /**
26
- * The first independent POL/USD rate any source gives. Throws one error naming
27
- * every source tried, so an agent in a restricted sandbox knows what to allow.
28
+ * The first independent native/USD rate any source gives for the payment
29
+ * chain. Throws one error naming every source tried, so an agent in a
30
+ * restricted sandbox knows what to allow.
28
31
  */
32
+ export declare function independentNativeUsd(opts: {
33
+ fetchImpl: FetchImpl;
34
+ chain: PayChain;
35
+ rpc?: string;
36
+ }): Promise<NativePrice>;
37
+ /** The Polygon rate, as before chains were configurable. */
29
38
  export declare function independentPolUsd(opts: {
30
39
  fetchImpl: FetchImpl;
31
40
  polygonRpc?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"native-price.d.ts","sourceRoot":"","sources":["../src/native-price.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,eAAO,MAAM,yBAAyB,+CAA+C,CAAC;AAOtF,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,mBAAmB,GAAG,UAAU,GAAG,WAAW,CAAC;CACxD;AAED,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAsE1E;;;GAG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