@paywithtender/mcp 0.1.2 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tender (paywithtender)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @paywithtender/mcp
2
2
 
3
+ [![Tender MCP server](https://glama.ai/mcp/servers/paywithtender/tender/badges/score.svg)](https://glama.ai/mcp/servers/paywithtender/tender) [![Tender MCP on mcprush](https://mcprush.com/badge/paywithtender-tender-mcp/compact.svg)](https://mcprush.com/to/paywithtender-tender-mcp?ref=badge)
4
+
3
5
  An MCP server that lets any AI agent pay x402 APIs on Robinhood Chain with whatever token it holds. Tender swaps the token to USDG on Uniswap inside the payment, so the API always receives the exact price, in one transaction.
4
6
 
5
7
  Works with Claude Desktop, Claude Code, Cursor, and any other MCP client.
@@ -57,6 +59,7 @@ It costs $0.01 plus gas, in whatever token you set as `TENDER_PAY_WITH`.
57
59
  | `TENDER_MAX_PER_CALL_USD` | `1` | Refuse any API priced above this. |
58
60
  | `TENDER_MAX_FEE_USD` | `0.10` | Refuse if Tender's fee plus gas is above this. |
59
61
  | `TENDER_DAILY_LIMIT_USD` | `10` | Total the agent may spend per UTC day. The running total is saved to disk, so restarting the server or the AI app doesn't reset it. |
62
+ | `TENDER_APPROVAL_DAYS` | `7` | The agent approves only enough of its token for this many days at the daily limit, and renews the approval when it runs low. It never grants an unlimited allowance unless you set this to `unlimited`. A wallet without ETH gets its first approval sponsored; renewals need a little ETH for gas. |
60
63
  | `TENDER_STATE_FILE` | `~/.tender/spend.json` | Where today's spending is kept, per wallet. Set to `none` to keep it in memory only (resets on restart). |
61
64
  | `TENDER_RPC_URL` | Robinhood Chain public RPC | |
62
65
  | `TENDER_FACILITATOR` | `https://facilitator.paywithtender.com` | |
@@ -67,7 +70,7 @@ It costs $0.01 plus gas, in whatever token you set as `TENDER_PAY_WITH`.
67
70
  - Paying in any other token: 0.5% + gas
68
71
  - Paying in $TENDER: gas only
69
72
 
70
- The first payment with a new token needs a one-time Permit2 approval. If the agent wallet has no ETH, Tender covers the gas for it.
73
+ The first payment with a new token approves Permit2 for a capped amount: enough for `TENDER_APPROVAL_DAYS` days at your daily limit, never unlimited. If the agent wallet has no ETH, Tender covers the gas for that first approval. When the approval runs low the agent renews it, which needs a little ETH.
71
74
 
72
75
  ## Links
73
76
 
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { type Address, type Hex } from "viem";
3
- export declare const VERSION = "0.1.2";
3
+ export declare const VERSION = "0.1.4";
4
4
  export interface TenderMcpConfig {
5
5
  /** Agent wallet key. Without it, only the read-only tools work. */
6
6
  privateKey?: Hex;
@@ -20,6 +20,11 @@ export interface TenderMcpConfig {
20
20
  /** Allow paying plain-http URLs (local testing only). */
21
21
  allowHttp: boolean;
22
22
  explorer?: string;
23
+ /**
24
+ * Token approval to Permit2, in days of `dailyLimit`. The agent approves only enough of its
25
+ * token for this many days of maximum spending, and renews when it runs low. 0 = unlimited.
26
+ */
27
+ approvalDays?: number;
23
28
  }
24
29
  export declare function configFromEnv(env?: NodeJS.ProcessEnv): TenderMcpConfig;
25
30
  export declare function createTenderMcp(cfg: TenderMcpConfig): {
package/dist/server.js CHANGED
@@ -6,7 +6,7 @@ import { z } from "zod";
6
6
  import { createPublicClient, createWalletClient, defineChain, erc20Abi, formatUnits, getAddress, http, isAddress, } from "viem";
7
7
  import { privateKeyToAccount } from "viem/accounts";
8
8
  import { HEADER_PAYMENT, HEADER_REQUIRED, HEADER_RESPONSE, ROBINHOOD, SCHEME_SWAP, buildPayment, decodeHeader, encodeHeader, ensurePermit2Approval, } from "@paywithtender/sdk";
9
- export const VERSION = "0.1.2";
9
+ export const VERSION = "0.1.4";
10
10
  const USD = 1000000n;
11
11
  function usdUnits(v, fallback) {
12
12
  const s = (v ?? fallback).replace("$", "").trim();
@@ -15,6 +15,14 @@ function usdUnits(v, fallback) {
15
15
  const [w, f = ""] = s.split(".");
16
16
  return BigInt(w) * USD + BigInt((f + "000000").slice(0, 6));
17
17
  }
18
+ function approvalDaysFromEnv(v) {
19
+ const s = (v ?? "7").trim().toLowerCase();
20
+ if (s === "unlimited" || s === "0")
21
+ return 0;
22
+ if (!/^\d+$/.test(s) || Number(s) > 365)
23
+ throw new Error("TENDER_APPROVAL_DAYS must be a whole number of days (1-365), or 'unlimited'");
24
+ return Number(s);
25
+ }
18
26
  export function configFromEnv(env = process.env) {
19
27
  const key = env.TENDER_PRIVATE_KEY?.trim();
20
28
  if (key && !/^0x[0-9a-fA-F]{64}$/.test(key))
@@ -34,6 +42,7 @@ export function configFromEnv(env = process.env) {
34
42
  maxPerCall: usdUnits(env.TENDER_MAX_PER_CALL_USD, "1"),
35
43
  maxFeePerCall: usdUnits(env.TENDER_MAX_FEE_USD, "0.10"),
36
44
  dailyLimit: usdUnits(env.TENDER_DAILY_LIMIT_USD, "10"),
45
+ approvalDays: approvalDaysFromEnv(env.TENDER_APPROVAL_DAYS),
37
46
  allowHttp: env.TENDER_ALLOW_HTTP === "true",
38
47
  stateFile: env.TENDER_STATE_FILE === "none" ? undefined : env.TENDER_STATE_FILE || path.join(os.homedir(), ".tender", "spend.json"),
39
48
  explorer: chainId === ROBINHOOD.chainId ? "https://robinhoodchain.blockscout.com" : undefined,
@@ -251,8 +260,20 @@ export function createTenderMcp(cfg) {
251
260
  pc.readContract({ address: cfg.payWith, abi: erc20Abi, functionName: "balanceOf", args: [account.address] }),
252
261
  pc.readContract({ address: cfg.payWith, abi: erc20Abi, functionName: "allowance", args: [account.address, cfg.permit2] }),
253
262
  ]);
254
- lines.push(`Pays with ${info.symbol}: ${amt(bal, info.decimals)} (${allowance > 0n ? "ready" : "one-time approval happens on first payment"})`);
255
- Object.assign(structured, { payWith: info.symbol, payWithBalance: formatUnits(bal, info.decimals) });
263
+ // Describe the approval that is actually on-chain, not just the configured policy.
264
+ const days = cfg.approvalDays ?? 7;
265
+ const UNLIMITED = 2n ** 255n;
266
+ const approval = allowance === 0n
267
+ ? `approval happens on first payment, ${days === 0 ? "unlimited" : `capped at ${days} days of the daily limit`}`
268
+ : allowance >= UNLIMITED
269
+ ? "approved: unlimited (granted before capped approvals; revoke it to switch to a capped one)"
270
+ : `approved for ${amt(allowance, info.decimals)} ${info.symbol}, renews when it runs low`;
271
+ lines.push(`Pays with ${info.symbol}: ${amt(bal, info.decimals)} (${approval})`);
272
+ Object.assign(structured, {
273
+ payWith: info.symbol,
274
+ payWithBalance: formatUnits(bal, info.decimals),
275
+ payWithApproval: allowance === 0n ? "none" : allowance >= UNLIMITED ? "unlimited" : formatUnits(allowance, info.decimals),
276
+ });
256
277
  }
257
278
  else {
258
279
  lines.push("Pays with: USDG");
@@ -332,18 +353,7 @@ export function createTenderMcp(cfg) {
332
353
  }
333
354
  const tokenIn = payWith ?? cfg.usdg;
334
355
  const extra = (opt.extra ?? {});
335
- try {
336
- await ensurePermit2Approval({
337
- wallet,
338
- publicClient: pc,
339
- token: tokenIn,
340
- permit2: extra.permit2 ?? cfg.permit2,
341
- facilitator: extra.facilitator ?? cfg.facilitator,
342
- });
343
- }
344
- catch (e) {
345
- return fail(`One-time token approval failed: ${e.shortMessage ?? e.message}. Nothing was paid.`);
346
- }
356
+ // Sign first (no allowance needed to sign), so the approval can be sized from the real quote.
347
357
  let payload;
348
358
  try {
349
359
  payload = await buildPayment(pc, { account, chain, rpcUrl: cfg.rpcUrl, payWith: payWith ?? undefined, maxUsdgPerCall: cap, maxFeePerCall: cfg.maxFeePerCall }, required, cap);
@@ -351,6 +361,28 @@ export function createTenderMcp(cfg) {
351
361
  catch (e) {
352
362
  return fail(`Couldn't prepare the payment: ${e.message}. Nothing was paid.`);
353
363
  }
364
+ // Permit2 payments need an approval. Capped by default: enough of this token for
365
+ // TENDER_APPROVAL_DAYS days at the daily limit, never an unlimited allowance.
366
+ const permit = payload.payload.permit;
367
+ if (permit) {
368
+ const needed = BigInt(permit.permitted.amount);
369
+ const days = cfg.approvalDays ?? 7;
370
+ const amount = days === 0 ? undefined : (needed * cfg.dailyLimit * BigInt(days)) / (price > 0n ? price : 1n);
371
+ try {
372
+ await ensurePermit2Approval({
373
+ wallet,
374
+ publicClient: pc,
375
+ token: tokenIn,
376
+ permit2: extra.permit2 ?? cfg.permit2,
377
+ facilitator: extra.facilitator ?? cfg.facilitator,
378
+ amount,
379
+ needed,
380
+ });
381
+ }
382
+ catch (e) {
383
+ return fail(`Token approval failed: ${e.shortMessage ?? e.message}. Nothing was paid.`);
384
+ }
385
+ }
354
386
  const h = new Headers(init.headers);
355
387
  h.set(HEADER_PAYMENT, encodeHeader(payload));
356
388
  // count the payment before sending it, so parallel calls and crashes can't overspend; give it back only if it clearly failed
@@ -381,8 +413,9 @@ export function createTenderMcp(cfg) {
381
413
  if (payment?.success) {
382
414
  const sym = (await token(payment.tokenIn).catch(() => null))?.symbol ?? payment.tokenIn;
383
415
  const link = cfg.explorer && payment.transaction ? `${cfg.explorer}/tx/${payment.transaction}` : payment.transaction;
384
- lines.push(`Paid ${money(payment.price)} in ${sym} via Tender. Transaction: ${link}`);
385
- Object.assign(structured, { paid: true, priceUsd: formatUnits(payment.price, 6), paidWith: sym, transaction: payment.transaction });
416
+ lines.push(`Paid ${money(payment.price)} in ${sym} via Tender.`);
417
+ lines.push(`Receipt (on-chain, include this link when you tell the user about the payment): ${link}`);
418
+ Object.assign(structured, { paid: true, priceUsd: formatUnits(payment.price, 6), paidWith: sym, transaction: payment.transaction, receiptUrl: link });
386
419
  }
387
420
  else if (payment) {
388
421
  lines.push(`Payment did not settle: ${payment.errorReason ?? "unknown reason"}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithtender/mcp",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "mcpName": "io.github.paywithtender/tender",
5
5
  "description": "MCP server that lets any AI agent pay x402 APIs with any token on Robinhood Chain, through Tender.",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "main": "./dist/server.js",
25
25
  "types": "./dist/server.d.ts",
26
26
  "bin": {
27
- "tender-mcp": "./dist/cli.js"
27
+ "tender-mcp": "dist/cli.js"
28
28
  },
29
29
  "exports": {
30
30
  ".": {
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@modelcontextprotocol/sdk": "^1.32.2",
48
- "@paywithtender/sdk": "^0.1.2",
48
+ "@paywithtender/sdk": "^0.1.3",
49
49
  "viem": "^2.21.0",
50
50
  "zod": "^4.1.0"
51
51
  },