@paywithtender/mcp 0.1.3 → 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/dist/server.d.ts +1 -1
- package/dist/server.js +18 -5
- package/package.json +1 -1
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.
|
|
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;
|
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.
|
|
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();
|
|
@@ -260,8 +260,20 @@ export function createTenderMcp(cfg) {
|
|
|
260
260
|
pc.readContract({ address: cfg.payWith, abi: erc20Abi, functionName: "balanceOf", args: [account.address] }),
|
|
261
261
|
pc.readContract({ address: cfg.payWith, abi: erc20Abi, functionName: "allowance", args: [account.address, cfg.permit2] }),
|
|
262
262
|
]);
|
|
263
|
-
|
|
264
|
-
|
|
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
|
+
});
|
|
265
277
|
}
|
|
266
278
|
else {
|
|
267
279
|
lines.push("Pays with: USDG");
|
|
@@ -401,8 +413,9 @@ export function createTenderMcp(cfg) {
|
|
|
401
413
|
if (payment?.success) {
|
|
402
414
|
const sym = (await token(payment.tokenIn).catch(() => null))?.symbol ?? payment.tokenIn;
|
|
403
415
|
const link = cfg.explorer && payment.transaction ? `${cfg.explorer}/tx/${payment.transaction}` : payment.transaction;
|
|
404
|
-
lines.push(`Paid ${money(payment.price)} in ${sym} via Tender
|
|
405
|
-
|
|
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 });
|
|
406
419
|
}
|
|
407
420
|
else if (payment) {
|
|
408
421
|
lines.push(`Payment did not settle: ${payment.errorReason ?? "unknown reason"}`);
|
package/package.json
CHANGED