@t402/mcp 2.8.0 → 2.8.1
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/cjs/index.js +286 -58
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/index.d.ts +5 -0
- package/dist/cjs/server/index.js +286 -58
- package/dist/cjs/server/index.js.map +1 -1
- package/dist/cjs/tools/index.d.ts +322 -1
- package/dist/cjs/tools/index.js +606 -58
- package/dist/cjs/tools/index.js.map +1 -1
- package/dist/esm/{chunk-XOPD7VTU.mjs → chunk-4DCBAKH2.mjs} +25 -2
- package/dist/esm/chunk-4DCBAKH2.mjs.map +1 -0
- package/dist/esm/{chunk-SUDCVXHQ.mjs → chunk-OSPCSAZF.mjs} +591 -55
- package/dist/esm/chunk-OSPCSAZF.mjs.map +1 -0
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/server/index.d.mts +5 -0
- package/dist/esm/server/index.mjs +2 -2
- package/dist/esm/tools/index.d.mts +322 -1
- package/dist/esm/tools/index.mjs +25 -1
- package/package.json +11 -11
- package/dist/esm/chunk-SUDCVXHQ.mjs.map +0 -1
- package/dist/esm/chunk-XOPD7VTU.mjs.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1234,10 +1234,10 @@ var import_zod7 = require("zod");
|
|
|
1234
1234
|
var wdkGetWalletInputSchema = import_zod7.z.object({});
|
|
1235
1235
|
async function executeWdkGetWallet(_input, wdk) {
|
|
1236
1236
|
const signer = await wdk.getSigner("ethereum");
|
|
1237
|
-
const
|
|
1237
|
+
const chains10 = wdk.getConfiguredChains();
|
|
1238
1238
|
return {
|
|
1239
1239
|
evmAddress: signer.address,
|
|
1240
|
-
chains:
|
|
1240
|
+
chains: chains10.length > 0 ? chains10 : ["ethereum"]
|
|
1241
1241
|
};
|
|
1242
1242
|
}
|
|
1243
1243
|
function executeWdkGetWalletDemo() {
|
|
@@ -1269,14 +1269,14 @@ function findTokenFormatted(tokens, symbol) {
|
|
|
1269
1269
|
}
|
|
1270
1270
|
async function executeWdkGetBalances(input, wdk) {
|
|
1271
1271
|
const balances = await wdk.getAggregatedBalances();
|
|
1272
|
-
const
|
|
1272
|
+
const chains10 = balances.chains.filter((c) => !input.chains || input.chains.includes(c.chain)).map((c) => ({
|
|
1273
1273
|
chain: c.chain,
|
|
1274
1274
|
usdt0: findTokenFormatted(c.tokens, "USDT0"),
|
|
1275
1275
|
usdc: findTokenFormatted(c.tokens, "USDC"),
|
|
1276
1276
|
native: (0, import_viem6.formatUnits)(c.native, 18)
|
|
1277
1277
|
}));
|
|
1278
1278
|
return {
|
|
1279
|
-
chains:
|
|
1279
|
+
chains: chains10,
|
|
1280
1280
|
totalUsdt0: (0, import_viem6.formatUnits)(balances.totalUsdt0, 6),
|
|
1281
1281
|
totalUsdc: (0, import_viem6.formatUnits)(balances.totalUsdc, 6)
|
|
1282
1282
|
};
|
|
@@ -1476,22 +1476,37 @@ async function executeAutoPay(input, wdk) {
|
|
|
1476
1476
|
}
|
|
1477
1477
|
};
|
|
1478
1478
|
}
|
|
1479
|
-
const
|
|
1479
|
+
const chains10 = input.preferredChain ? [input.preferredChain] : ["ethereum", "arbitrum", "base"];
|
|
1480
1480
|
const { T402Protocol } = await import("@t402/wdk-protocol");
|
|
1481
|
-
const protocol = await T402Protocol.create(wdk, { chains:
|
|
1482
|
-
|
|
1483
|
-
if (receipt && input.maxAmount) {
|
|
1484
|
-
const paidAmount = parseFloat(receipt.amount) / 1e6;
|
|
1481
|
+
const protocol = await T402Protocol.create(wdk, { chains: chains10 });
|
|
1482
|
+
if (input.maxAmount) {
|
|
1485
1483
|
const maxAmount = parseFloat(input.maxAmount);
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1484
|
+
const preflightResponse = await fetch(input.url);
|
|
1485
|
+
if (preflightResponse.status === 402) {
|
|
1486
|
+
const requirementsHeader = preflightResponse.headers.get("x-payment") || preflightResponse.headers.get("x-payment-requirements");
|
|
1487
|
+
if (requirementsHeader) {
|
|
1488
|
+
try {
|
|
1489
|
+
const requirements = JSON.parse(requirementsHeader);
|
|
1490
|
+
const reqArray = Array.isArray(requirements) ? requirements : [requirements];
|
|
1491
|
+
for (const req of reqArray) {
|
|
1492
|
+
if (req.amount) {
|
|
1493
|
+
const reqAmount = parseFloat(req.amount) / 1e6;
|
|
1494
|
+
if (reqAmount > maxAmount) {
|
|
1495
|
+
return {
|
|
1496
|
+
success: false,
|
|
1497
|
+
statusCode: 402,
|
|
1498
|
+
body: "",
|
|
1499
|
+
error: `Required payment amount (${reqAmount}) exceeds max allowed (${maxAmount})`
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
} catch {
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1493
1507
|
}
|
|
1494
1508
|
}
|
|
1509
|
+
const { response, receipt } = await protocol.fetch(input.url);
|
|
1495
1510
|
const contentType = response.headers.get("content-type") ?? void 0;
|
|
1496
1511
|
let body = "";
|
|
1497
1512
|
try {
|
|
@@ -2344,6 +2359,71 @@ function formatNetworkFeeComparison(result) {
|
|
|
2344
2359
|
return lines.join("\n");
|
|
2345
2360
|
}
|
|
2346
2361
|
|
|
2362
|
+
// src/tools/signMessage.ts
|
|
2363
|
+
var import_zod19 = require("zod");
|
|
2364
|
+
var signMessageInputSchema = import_zod19.z.object({
|
|
2365
|
+
chain: import_zod19.z.enum([
|
|
2366
|
+
"ethereum",
|
|
2367
|
+
"base",
|
|
2368
|
+
"arbitrum",
|
|
2369
|
+
"optimism",
|
|
2370
|
+
"polygon",
|
|
2371
|
+
"avalanche",
|
|
2372
|
+
"ink",
|
|
2373
|
+
"berachain",
|
|
2374
|
+
"unichain"
|
|
2375
|
+
]).describe("Blockchain network context for signing"),
|
|
2376
|
+
message: import_zod19.z.string().min(1).describe("Message to sign")
|
|
2377
|
+
});
|
|
2378
|
+
|
|
2379
|
+
// src/tools/verifySignature.ts
|
|
2380
|
+
var import_zod20 = require("zod");
|
|
2381
|
+
var import_viem11 = require("viem");
|
|
2382
|
+
var verifySignatureInputSchema = import_zod20.z.object({
|
|
2383
|
+
chain: import_zod20.z.enum([
|
|
2384
|
+
"ethereum",
|
|
2385
|
+
"base",
|
|
2386
|
+
"arbitrum",
|
|
2387
|
+
"optimism",
|
|
2388
|
+
"polygon",
|
|
2389
|
+
"avalanche",
|
|
2390
|
+
"ink",
|
|
2391
|
+
"berachain",
|
|
2392
|
+
"unichain"
|
|
2393
|
+
]).describe("Blockchain network context for verification"),
|
|
2394
|
+
message: import_zod20.z.string().min(1).describe("The original message that was signed"),
|
|
2395
|
+
signature: import_zod20.z.string().regex(/^0x[a-fA-F0-9]+$/).describe("The signature to verify (hex string)"),
|
|
2396
|
+
address: import_zod20.z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe("The expected signer address")
|
|
2397
|
+
});
|
|
2398
|
+
|
|
2399
|
+
// src/tools/getTransferHistory.ts
|
|
2400
|
+
var import_zod21 = require("zod");
|
|
2401
|
+
var import_viem12 = require("viem");
|
|
2402
|
+
var chains9 = __toESM(require("viem/chains"));
|
|
2403
|
+
var getTransferHistoryInputSchema = import_zod21.z.object({
|
|
2404
|
+
network: import_zod21.z.enum([
|
|
2405
|
+
"ethereum",
|
|
2406
|
+
"base",
|
|
2407
|
+
"arbitrum",
|
|
2408
|
+
"optimism",
|
|
2409
|
+
"polygon",
|
|
2410
|
+
"avalanche",
|
|
2411
|
+
"ink",
|
|
2412
|
+
"berachain",
|
|
2413
|
+
"unichain"
|
|
2414
|
+
]).describe("Blockchain network to query"),
|
|
2415
|
+
address: import_zod21.z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe("Wallet address to get transfer history for"),
|
|
2416
|
+
token: import_zod21.z.enum(["USDC", "USDT", "USDT0"]).optional().describe("Filter by specific token. If not provided, queries all supported stablecoins."),
|
|
2417
|
+
limit: import_zod21.z.number().int().min(1).max(100).optional().describe("Maximum number of transfers to return (default: 10, max: 100)")
|
|
2418
|
+
});
|
|
2419
|
+
|
|
2420
|
+
// src/tools/getHistoricalPrice.ts
|
|
2421
|
+
var import_zod22 = require("zod");
|
|
2422
|
+
var getHistoricalPriceInputSchema = import_zod22.z.object({
|
|
2423
|
+
token: import_zod22.z.string().min(1).describe('Token symbol (e.g., "ETH", "USDC", "USDT", "MATIC", "AVAX")'),
|
|
2424
|
+
days: import_zod22.z.number().int().min(1).max(365).optional().describe("Number of days of history to retrieve (default: 7, max: 365)")
|
|
2425
|
+
});
|
|
2426
|
+
|
|
2347
2427
|
// src/tools/quoteStore.ts
|
|
2348
2428
|
var import_crypto = require("crypto");
|
|
2349
2429
|
var DEFAULT_TTL_MS = 5 * 60 * 1e3;
|
|
@@ -2390,17 +2470,17 @@ function deleteQuote(quoteId) {
|
|
|
2390
2470
|
}
|
|
2391
2471
|
|
|
2392
2472
|
// src/tools/wdkQuoteSwap.ts
|
|
2393
|
-
var
|
|
2394
|
-
var
|
|
2395
|
-
var wdkQuoteSwapInputSchema =
|
|
2396
|
-
fromToken:
|
|
2397
|
-
toToken:
|
|
2398
|
-
amount:
|
|
2399
|
-
chain:
|
|
2473
|
+
var import_zod23 = require("zod");
|
|
2474
|
+
var import_viem13 = require("viem");
|
|
2475
|
+
var wdkQuoteSwapInputSchema = import_zod23.z.object({
|
|
2476
|
+
fromToken: import_zod23.z.string().describe('Token to swap from (e.g., "ETH", "USDC")'),
|
|
2477
|
+
toToken: import_zod23.z.string().describe('Token to swap to (e.g., "USDT0", "USDC")'),
|
|
2478
|
+
amount: import_zod23.z.string().regex(/^\d+(\.\d+)?$/).describe("Amount to swap (e.g., '1.0')"),
|
|
2479
|
+
chain: import_zod23.z.string().describe('Chain to execute swap on (e.g., "ethereum", "arbitrum")')
|
|
2400
2480
|
});
|
|
2401
2481
|
async function executeWdkQuoteSwap(input, wdk) {
|
|
2402
2482
|
const decimals = ["USDC", "USDT", "USDT0"].includes(input.fromToken.toUpperCase()) ? 6 : 18;
|
|
2403
|
-
const amountBigInt = (0,
|
|
2483
|
+
const amountBigInt = (0, import_viem13.parseUnits)(input.amount, decimals);
|
|
2404
2484
|
const quote = await wdk.getSwapQuote(input.chain, input.fromToken, amountBigInt);
|
|
2405
2485
|
const outputDecimals = ["USDC", "USDT", "USDT0"].includes(input.toToken.toUpperCase()) ? 6 : 18;
|
|
2406
2486
|
const outputDivisor = 10 ** outputDecimals;
|
|
@@ -2474,11 +2554,11 @@ function formatSwapQuoteResult(result) {
|
|
|
2474
2554
|
}
|
|
2475
2555
|
|
|
2476
2556
|
// src/tools/wdkExecuteSwap.ts
|
|
2477
|
-
var
|
|
2478
|
-
var
|
|
2479
|
-
var wdkExecuteSwapInputSchema =
|
|
2480
|
-
quoteId:
|
|
2481
|
-
confirmed:
|
|
2557
|
+
var import_zod24 = require("zod");
|
|
2558
|
+
var import_viem14 = require("viem");
|
|
2559
|
+
var wdkExecuteSwapInputSchema = import_zod24.z.object({
|
|
2560
|
+
quoteId: import_zod24.z.string().uuid().describe("Quote ID from wdk/quoteSwap"),
|
|
2561
|
+
confirmed: import_zod24.z.boolean().optional().describe("Set to true to confirm and execute this swap")
|
|
2482
2562
|
});
|
|
2483
2563
|
async function executeWdkExecuteSwap(input, wdk) {
|
|
2484
2564
|
const quote = getQuote(input.quoteId);
|
|
@@ -2497,7 +2577,7 @@ async function executeWdkExecuteSwap(input, wdk) {
|
|
|
2497
2577
|
};
|
|
2498
2578
|
}
|
|
2499
2579
|
const decimals = ["USDC", "USDT", "USDT0"].includes(fromToken.toUpperCase()) ? 6 : 18;
|
|
2500
|
-
const amountBigInt = (0,
|
|
2580
|
+
const amountBigInt = (0, import_viem14.parseUnits)(fromAmount, decimals);
|
|
2501
2581
|
const result = await wdk.swapAndPay({
|
|
2502
2582
|
chain,
|
|
2503
2583
|
fromToken,
|
|
@@ -2551,12 +2631,12 @@ function formatExecuteSwapResult(result) {
|
|
|
2551
2631
|
}
|
|
2552
2632
|
|
|
2553
2633
|
// src/tools/quoteBridge.ts
|
|
2554
|
-
var
|
|
2555
|
-
var quoteBridgeInputSchema =
|
|
2556
|
-
fromChain:
|
|
2557
|
-
toChain:
|
|
2558
|
-
amount:
|
|
2559
|
-
recipient:
|
|
2634
|
+
var import_zod25 = require("zod");
|
|
2635
|
+
var quoteBridgeInputSchema = import_zod25.z.object({
|
|
2636
|
+
fromChain: import_zod25.z.enum(["ethereum", "arbitrum", "ink", "berachain", "unichain"]).describe("Source chain to bridge from"),
|
|
2637
|
+
toChain: import_zod25.z.enum(["ethereum", "arbitrum", "ink", "berachain", "unichain"]).describe("Destination chain to bridge to"),
|
|
2638
|
+
amount: import_zod25.z.string().regex(/^\d+(\.\d+)?$/).describe("Amount of USDT0 to bridge (e.g., '100' for 100 USDT0)"),
|
|
2639
|
+
recipient: import_zod25.z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe("Recipient address on destination chain")
|
|
2560
2640
|
});
|
|
2561
2641
|
async function executeQuoteBridge(input, rpcUrls) {
|
|
2562
2642
|
const feeResult = await executeGetBridgeFee(input, rpcUrls);
|
|
@@ -2624,10 +2704,10 @@ function formatBridgeQuoteResult(result) {
|
|
|
2624
2704
|
}
|
|
2625
2705
|
|
|
2626
2706
|
// src/tools/executeBridgeFromQuote.ts
|
|
2627
|
-
var
|
|
2628
|
-
var executeBridgeFromQuoteInputSchema =
|
|
2629
|
-
quoteId:
|
|
2630
|
-
confirmed:
|
|
2707
|
+
var import_zod26 = require("zod");
|
|
2708
|
+
var executeBridgeFromQuoteInputSchema = import_zod26.z.object({
|
|
2709
|
+
quoteId: import_zod26.z.string().uuid().describe("Quote ID from t402/quoteBridge"),
|
|
2710
|
+
confirmed: import_zod26.z.boolean().optional().describe("Set to true to confirm and execute this bridge")
|
|
2631
2711
|
});
|
|
2632
2712
|
async function executeExecuteBridgeFromQuote(input, options) {
|
|
2633
2713
|
const quote = getQuote(input.quoteId);
|
|
@@ -2686,22 +2766,22 @@ function executeExecuteBridgeFromQuoteDemo(input) {
|
|
|
2686
2766
|
}
|
|
2687
2767
|
|
|
2688
2768
|
// src/tools/unified.ts
|
|
2689
|
-
var
|
|
2690
|
-
var smartPayInputSchema =
|
|
2691
|
-
url:
|
|
2692
|
-
maxBridgeFee:
|
|
2693
|
-
preferredNetwork:
|
|
2694
|
-
confirmed:
|
|
2769
|
+
var import_zod27 = require("zod");
|
|
2770
|
+
var smartPayInputSchema = import_zod27.z.object({
|
|
2771
|
+
url: import_zod27.z.string().url().describe("URL of the 402-protected resource"),
|
|
2772
|
+
maxBridgeFee: import_zod27.z.string().regex(/^\d+(\.\d+)?$/).optional().describe("Maximum acceptable bridge fee in native token (optional)"),
|
|
2773
|
+
preferredNetwork: import_zod27.z.string().optional().describe("Preferred network for payment (optional)"),
|
|
2774
|
+
confirmed: import_zod27.z.boolean().optional().describe("Set to true to confirm and execute this payment")
|
|
2695
2775
|
});
|
|
2696
|
-
var paymentPlanInputSchema =
|
|
2697
|
-
paymentRequired:
|
|
2698
|
-
scheme:
|
|
2699
|
-
network:
|
|
2700
|
-
maxAmountRequired:
|
|
2701
|
-
resource:
|
|
2702
|
-
description:
|
|
2703
|
-
payTo:
|
|
2704
|
-
maxDeadline:
|
|
2776
|
+
var paymentPlanInputSchema = import_zod27.z.object({
|
|
2777
|
+
paymentRequired: import_zod27.z.object({
|
|
2778
|
+
scheme: import_zod27.z.string().optional(),
|
|
2779
|
+
network: import_zod27.z.string().optional(),
|
|
2780
|
+
maxAmountRequired: import_zod27.z.string().optional(),
|
|
2781
|
+
resource: import_zod27.z.string().optional(),
|
|
2782
|
+
description: import_zod27.z.string().optional(),
|
|
2783
|
+
payTo: import_zod27.z.string().optional(),
|
|
2784
|
+
maxDeadline: import_zod27.z.number().optional()
|
|
2705
2785
|
}).passthrough().describe("The 402 PaymentRequired response")
|
|
2706
2786
|
});
|
|
2707
2787
|
var UNIFIED_TOOL_DEFINITIONS = {
|
|
@@ -2756,14 +2836,14 @@ async function executeSmartPay(input, wdk) {
|
|
|
2756
2836
|
};
|
|
2757
2837
|
}
|
|
2758
2838
|
const steps = [];
|
|
2759
|
-
const
|
|
2839
|
+
const chains10 = input.preferredNetwork ? [input.preferredNetwork] : ["ethereum", "arbitrum", "base"];
|
|
2760
2840
|
steps.push({
|
|
2761
2841
|
action: "check_balance",
|
|
2762
2842
|
status: "success",
|
|
2763
|
-
detail: `Checking balances on ${
|
|
2843
|
+
detail: `Checking balances on ${chains10.join(", ")}`
|
|
2764
2844
|
});
|
|
2765
2845
|
const { T402Protocol } = await import("@t402/wdk-protocol");
|
|
2766
|
-
const protocol = await T402Protocol.create(wdk, { chains:
|
|
2846
|
+
const protocol = await T402Protocol.create(wdk, { chains: chains10 });
|
|
2767
2847
|
steps.push({
|
|
2768
2848
|
action: "fetch",
|
|
2769
2849
|
status: "success",
|
|
@@ -3324,6 +3404,131 @@ var TOOL_DEFINITIONS = {
|
|
|
3324
3404
|
},
|
|
3325
3405
|
required: ["quoteId"]
|
|
3326
3406
|
}
|
|
3407
|
+
},
|
|
3408
|
+
"t402/signMessage": {
|
|
3409
|
+
name: "t402/signMessage",
|
|
3410
|
+
description: "Sign a message using the configured wallet. Returns an EIP-191 personal signature. Requires a configured private key.",
|
|
3411
|
+
inputSchema: {
|
|
3412
|
+
type: "object",
|
|
3413
|
+
properties: {
|
|
3414
|
+
chain: {
|
|
3415
|
+
type: "string",
|
|
3416
|
+
enum: [
|
|
3417
|
+
"ethereum",
|
|
3418
|
+
"base",
|
|
3419
|
+
"arbitrum",
|
|
3420
|
+
"optimism",
|
|
3421
|
+
"polygon",
|
|
3422
|
+
"avalanche",
|
|
3423
|
+
"ink",
|
|
3424
|
+
"berachain",
|
|
3425
|
+
"unichain"
|
|
3426
|
+
],
|
|
3427
|
+
description: "Blockchain network context for signing"
|
|
3428
|
+
},
|
|
3429
|
+
message: {
|
|
3430
|
+
type: "string",
|
|
3431
|
+
description: "Message to sign"
|
|
3432
|
+
}
|
|
3433
|
+
},
|
|
3434
|
+
required: ["chain", "message"]
|
|
3435
|
+
}
|
|
3436
|
+
},
|
|
3437
|
+
"t402/verifySignature": {
|
|
3438
|
+
name: "t402/verifySignature",
|
|
3439
|
+
description: "Verify an EIP-191 signed message. Checks whether a signature was produced by the claimed address. No wallet configuration needed \u2014 this is a read-only verification.",
|
|
3440
|
+
inputSchema: {
|
|
3441
|
+
type: "object",
|
|
3442
|
+
properties: {
|
|
3443
|
+
chain: {
|
|
3444
|
+
type: "string",
|
|
3445
|
+
enum: [
|
|
3446
|
+
"ethereum",
|
|
3447
|
+
"base",
|
|
3448
|
+
"arbitrum",
|
|
3449
|
+
"optimism",
|
|
3450
|
+
"polygon",
|
|
3451
|
+
"avalanche",
|
|
3452
|
+
"ink",
|
|
3453
|
+
"berachain",
|
|
3454
|
+
"unichain"
|
|
3455
|
+
],
|
|
3456
|
+
description: "Blockchain network context for verification"
|
|
3457
|
+
},
|
|
3458
|
+
message: {
|
|
3459
|
+
type: "string",
|
|
3460
|
+
description: "The original message that was signed"
|
|
3461
|
+
},
|
|
3462
|
+
signature: {
|
|
3463
|
+
type: "string",
|
|
3464
|
+
pattern: "^0x[a-fA-F0-9]+$",
|
|
3465
|
+
description: "The signature to verify (hex string)"
|
|
3466
|
+
},
|
|
3467
|
+
address: {
|
|
3468
|
+
type: "string",
|
|
3469
|
+
pattern: "^0x[a-fA-F0-9]{40}$",
|
|
3470
|
+
description: "The expected signer address"
|
|
3471
|
+
}
|
|
3472
|
+
},
|
|
3473
|
+
required: ["chain", "message", "signature", "address"]
|
|
3474
|
+
}
|
|
3475
|
+
},
|
|
3476
|
+
"t402/getTransferHistory": {
|
|
3477
|
+
name: "t402/getTransferHistory",
|
|
3478
|
+
description: "Get recent ERC-20 stablecoin transfer history for a wallet address. Queries on-chain Transfer events for USDC, USDT, and USDT0. Returns sent and received transfers sorted by most recent.",
|
|
3479
|
+
inputSchema: {
|
|
3480
|
+
type: "object",
|
|
3481
|
+
properties: {
|
|
3482
|
+
network: {
|
|
3483
|
+
type: "string",
|
|
3484
|
+
enum: [
|
|
3485
|
+
"ethereum",
|
|
3486
|
+
"base",
|
|
3487
|
+
"arbitrum",
|
|
3488
|
+
"optimism",
|
|
3489
|
+
"polygon",
|
|
3490
|
+
"avalanche",
|
|
3491
|
+
"ink",
|
|
3492
|
+
"berachain",
|
|
3493
|
+
"unichain"
|
|
3494
|
+
],
|
|
3495
|
+
description: "Blockchain network to query"
|
|
3496
|
+
},
|
|
3497
|
+
address: {
|
|
3498
|
+
type: "string",
|
|
3499
|
+
pattern: "^0x[a-fA-F0-9]{40}$",
|
|
3500
|
+
description: "Wallet address to get transfer history for"
|
|
3501
|
+
},
|
|
3502
|
+
token: {
|
|
3503
|
+
type: "string",
|
|
3504
|
+
enum: ["USDC", "USDT", "USDT0"],
|
|
3505
|
+
description: "Filter by specific token. If not provided, queries all supported stablecoins."
|
|
3506
|
+
},
|
|
3507
|
+
limit: {
|
|
3508
|
+
type: "number",
|
|
3509
|
+
description: "Maximum number of transfers to return (default: 10, max: 100)"
|
|
3510
|
+
}
|
|
3511
|
+
},
|
|
3512
|
+
required: ["network", "address"]
|
|
3513
|
+
}
|
|
3514
|
+
},
|
|
3515
|
+
"t402/getHistoricalPrice": {
|
|
3516
|
+
name: "t402/getHistoricalPrice",
|
|
3517
|
+
description: "Get historical price data for a token over a specified period via CoinGecko. Returns price data points, high/low, and percentage change. Useful for trend analysis.",
|
|
3518
|
+
inputSchema: {
|
|
3519
|
+
type: "object",
|
|
3520
|
+
properties: {
|
|
3521
|
+
token: {
|
|
3522
|
+
type: "string",
|
|
3523
|
+
description: 'Token symbol (e.g., "ETH", "USDC", "USDT", "MATIC", "AVAX", "BTC", "SOL")'
|
|
3524
|
+
},
|
|
3525
|
+
days: {
|
|
3526
|
+
type: "number",
|
|
3527
|
+
description: "Number of days of history to retrieve (default: 7, max: 365)"
|
|
3528
|
+
}
|
|
3529
|
+
},
|
|
3530
|
+
required: ["token"]
|
|
3531
|
+
}
|
|
3327
3532
|
}
|
|
3328
3533
|
};
|
|
3329
3534
|
var WDK_TOOL_DEFINITIONS = {
|
|
@@ -3603,6 +3808,19 @@ var T402McpServer = class {
|
|
|
3603
3808
|
console.error("Warning: Failed to initialize WDK. WDK tools will not be available.");
|
|
3604
3809
|
}
|
|
3605
3810
|
}
|
|
3811
|
+
/**
|
|
3812
|
+
* Clear sensitive data from memory.
|
|
3813
|
+
* Should be called on server shutdown to minimize key exposure window.
|
|
3814
|
+
*/
|
|
3815
|
+
cleanup() {
|
|
3816
|
+
if (this.config.privateKey) {
|
|
3817
|
+
this.config.privateKey = "";
|
|
3818
|
+
}
|
|
3819
|
+
if (this.config.seedPhrase) {
|
|
3820
|
+
this.config.seedPhrase = "";
|
|
3821
|
+
}
|
|
3822
|
+
this.wdk = null;
|
|
3823
|
+
}
|
|
3606
3824
|
/**
|
|
3607
3825
|
* Register TON bridge tools
|
|
3608
3826
|
*
|
|
@@ -4112,6 +4330,16 @@ var T402McpServer = class {
|
|
|
4112
4330
|
*/
|
|
4113
4331
|
async run() {
|
|
4114
4332
|
await this.initWdk();
|
|
4333
|
+
const onExit = () => this.cleanup();
|
|
4334
|
+
process.on("exit", onExit);
|
|
4335
|
+
process.on("SIGINT", () => {
|
|
4336
|
+
onExit();
|
|
4337
|
+
process.exit(0);
|
|
4338
|
+
});
|
|
4339
|
+
process.on("SIGTERM", () => {
|
|
4340
|
+
onExit();
|
|
4341
|
+
process.exit(0);
|
|
4342
|
+
});
|
|
4115
4343
|
const transport = new import_stdio.StdioServerTransport();
|
|
4116
4344
|
await this.server.connect(transport);
|
|
4117
4345
|
console.error("t402 MCP Server running on stdio");
|