@t402/mcp 2.6.1 → 2.7.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/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +302 -26
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/index.d.ts +12 -0
- package/dist/cjs/server/index.js +302 -26
- package/dist/cjs/server/index.js.map +1 -1
- package/dist/cjs/tools/index.d.ts +179 -1
- package/dist/cjs/tools/index.js +283 -25
- package/dist/cjs/tools/index.js.map +1 -1
- package/dist/esm/{chunk-3FGPOVUZ.mjs → chunk-3PMBXSJ3.mjs} +51 -3
- package/dist/esm/chunk-3PMBXSJ3.mjs.map +1 -0
- package/dist/esm/{chunk-RDQ7AMR4.mjs → chunk-B7X7H6NV.mjs} +275 -27
- package/dist/esm/chunk-B7X7H6NV.mjs.map +1 -0
- package/dist/esm/index.d.mts +1 -0
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/server/index.d.mts +12 -0
- package/dist/esm/server/index.mjs +2 -2
- package/dist/esm/tools/index.d.mts +179 -1
- package/dist/esm/tools/index.mjs +21 -1
- package/package.json +4 -5
- package/dist/esm/chunk-3FGPOVUZ.mjs.map +0 -1
- package/dist/esm/chunk-RDQ7AMR4.mjs.map +0 -1
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1210,10 +1210,10 @@ var import_zod7 = require("zod");
|
|
|
1210
1210
|
var wdkGetWalletInputSchema = import_zod7.z.object({});
|
|
1211
1211
|
async function executeWdkGetWallet(_input, wdk) {
|
|
1212
1212
|
const signer = await wdk.getSigner("ethereum");
|
|
1213
|
-
const
|
|
1213
|
+
const chains7 = wdk.getConfiguredChains();
|
|
1214
1214
|
return {
|
|
1215
1215
|
evmAddress: signer.address,
|
|
1216
|
-
chains:
|
|
1216
|
+
chains: chains7.length > 0 ? chains7 : ["ethereum"]
|
|
1217
1217
|
};
|
|
1218
1218
|
}
|
|
1219
1219
|
function executeWdkGetWalletDemo() {
|
|
@@ -1245,14 +1245,14 @@ function findTokenFormatted(tokens, symbol) {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
async function executeWdkGetBalances(input, wdk) {
|
|
1247
1247
|
const balances = await wdk.getAggregatedBalances();
|
|
1248
|
-
const
|
|
1248
|
+
const chains7 = balances.chains.filter((c) => !input.chains || input.chains.includes(c.chain)).map((c) => ({
|
|
1249
1249
|
chain: c.chain,
|
|
1250
1250
|
usdt0: findTokenFormatted(c.tokens, "USDT0"),
|
|
1251
1251
|
usdc: findTokenFormatted(c.tokens, "USDC"),
|
|
1252
1252
|
native: (0, import_viem6.formatUnits)(c.native, 18)
|
|
1253
1253
|
}));
|
|
1254
1254
|
return {
|
|
1255
|
-
chains:
|
|
1255
|
+
chains: chains7,
|
|
1256
1256
|
totalUsdt0: (0, import_viem6.formatUnits)(balances.totalUsdt0, 6),
|
|
1257
1257
|
totalUsdc: (0, import_viem6.formatUnits)(balances.totalUsdc, 6)
|
|
1258
1258
|
};
|
|
@@ -1392,7 +1392,6 @@ function formatWdkSwapResult(result) {
|
|
|
1392
1392
|
|
|
1393
1393
|
// src/tools/autoPay.ts
|
|
1394
1394
|
var import_zod11 = require("zod");
|
|
1395
|
-
var import_wdk_protocol = require("@t402/wdk-protocol");
|
|
1396
1395
|
var autoPayInputSchema = import_zod11.z.object({
|
|
1397
1396
|
url: import_zod11.z.string().url().describe("URL to fetch (may return 402 Payment Required)"),
|
|
1398
1397
|
maxAmount: import_zod11.z.string().regex(/^\d+(\.\d+)?$/).optional().describe('Maximum amount willing to pay (e.g., "10.00"). If not set, pays any amount.'),
|
|
@@ -1401,8 +1400,9 @@ var autoPayInputSchema = import_zod11.z.object({
|
|
|
1401
1400
|
)
|
|
1402
1401
|
});
|
|
1403
1402
|
async function executeAutoPay(input, wdk) {
|
|
1404
|
-
const
|
|
1405
|
-
const
|
|
1403
|
+
const chains7 = input.preferredChain ? [input.preferredChain] : ["ethereum", "arbitrum", "base"];
|
|
1404
|
+
const { T402Protocol } = await import("@t402/wdk-protocol");
|
|
1405
|
+
const protocol = await T402Protocol.create(wdk, { chains: chains7 });
|
|
1406
1406
|
const { response, receipt } = await protocol.fetch(input.url);
|
|
1407
1407
|
if (receipt && input.maxAmount) {
|
|
1408
1408
|
const paidAmount = parseFloat(receipt.amount) / 1e6;
|
|
@@ -1720,23 +1720,185 @@ ${JSON.stringify(data.result[0], null, 2)}`
|
|
|
1720
1720
|
}
|
|
1721
1721
|
}
|
|
1722
1722
|
|
|
1723
|
-
// src/tools/
|
|
1723
|
+
// src/tools/erc8004ResolveAgent.ts
|
|
1724
1724
|
var import_zod12 = require("zod");
|
|
1725
|
-
var
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1725
|
+
var import_erc80042 = require("@t402/erc8004");
|
|
1726
|
+
|
|
1727
|
+
// src/tools/erc8004Shared.ts
|
|
1728
|
+
var import_viem8 = require("viem");
|
|
1729
|
+
var chains6 = __toESM(require("viem/chains"));
|
|
1730
|
+
var import_erc8004 = require("@t402/erc8004");
|
|
1731
|
+
var CHAIN_ID_TO_VIEM = {
|
|
1732
|
+
1: chains6.mainnet,
|
|
1733
|
+
8453: chains6.base,
|
|
1734
|
+
42161: chains6.arbitrum,
|
|
1735
|
+
10: chains6.optimism,
|
|
1736
|
+
137: chains6.polygon,
|
|
1737
|
+
43114: chains6.avalanche,
|
|
1738
|
+
57073: chains6.ink,
|
|
1739
|
+
80094: chains6.berachain,
|
|
1740
|
+
130: chains6.unichain
|
|
1741
|
+
};
|
|
1742
|
+
var CHAIN_ID_TO_NETWORK = Object.fromEntries(
|
|
1743
|
+
Object.entries(CHAIN_IDS).map(([name, id]) => [id, name])
|
|
1744
|
+
);
|
|
1745
|
+
function createErc8004Client(agentRegistry, rpcUrls) {
|
|
1746
|
+
const parsed = (0, import_erc8004.parseAgentRegistry)(agentRegistry);
|
|
1747
|
+
const chainId = parseInt(parsed.chainId, 10);
|
|
1748
|
+
const viemChain = CHAIN_ID_TO_VIEM[chainId];
|
|
1749
|
+
if (!viemChain) {
|
|
1750
|
+
throw new Error(
|
|
1751
|
+
`Unsupported chain ID ${chainId} from registry ${agentRegistry}. Supported: ${Object.keys(CHAIN_ID_TO_VIEM).join(", ")}`
|
|
1752
|
+
);
|
|
1753
|
+
}
|
|
1754
|
+
const network = CHAIN_ID_TO_NETWORK[chainId];
|
|
1755
|
+
const rpcUrl = network && rpcUrls?.[network] || network && DEFAULT_RPC_URLS[network];
|
|
1756
|
+
const client = (0, import_viem8.createPublicClient)({
|
|
1757
|
+
chain: viemChain,
|
|
1758
|
+
transport: (0, import_viem8.http)(rpcUrl)
|
|
1759
|
+
});
|
|
1760
|
+
return { client, registryAddress: parsed.address };
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
// src/tools/erc8004ResolveAgent.ts
|
|
1764
|
+
var erc8004ResolveAgentInputSchema = import_zod12.z.object({
|
|
1765
|
+
agentId: import_zod12.z.number().int().nonnegative().describe("Agent NFT token ID on the Identity Registry"),
|
|
1766
|
+
agentRegistry: import_zod12.z.string().regex(/^eip155:\d+:0x[a-fA-F0-9]+$/).describe('Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")')
|
|
1730
1767
|
});
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1768
|
+
async function executeErc8004ResolveAgent(input, rpcUrls) {
|
|
1769
|
+
const { client, registryAddress } = createErc8004Client(input.agentRegistry, rpcUrls);
|
|
1770
|
+
return (0, import_erc80042.resolveAgent)(
|
|
1771
|
+
client,
|
|
1772
|
+
registryAddress,
|
|
1773
|
+
BigInt(input.agentId),
|
|
1774
|
+
input.agentRegistry
|
|
1775
|
+
);
|
|
1776
|
+
}
|
|
1777
|
+
function formatErc8004ResolveAgentResult(agent) {
|
|
1778
|
+
const lines = [
|
|
1779
|
+
`## Agent Identity (ID: ${agent.agentId})`,
|
|
1780
|
+
"",
|
|
1781
|
+
`**Registry:** ${agent.registry.id}`,
|
|
1782
|
+
`**Wallet:** \`${agent.agentWallet}\``,
|
|
1783
|
+
`**Owner:** \`${agent.owner}\``,
|
|
1784
|
+
`**Registration URI:** ${agent.agentURI}`,
|
|
1785
|
+
""
|
|
1786
|
+
];
|
|
1787
|
+
if (agent.registration) {
|
|
1788
|
+
const reg = agent.registration;
|
|
1789
|
+
lines.push("### Registration File");
|
|
1790
|
+
if (reg.name) lines.push(`- **Name:** ${reg.name}`);
|
|
1791
|
+
if (reg.description) lines.push(`- **Description:** ${reg.description}`);
|
|
1792
|
+
if (reg.image) lines.push(`- **Image:** ${reg.image}`);
|
|
1793
|
+
if (reg.x402Support !== void 0) lines.push(`- **x402 Support:** ${reg.x402Support}`);
|
|
1794
|
+
if (reg.services?.length) {
|
|
1795
|
+
lines.push("");
|
|
1796
|
+
lines.push("### Services");
|
|
1797
|
+
for (const svc of reg.services) {
|
|
1798
|
+
lines.push(`- **${svc.name}:** ${svc.endpoint}`);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
return lines.join("\n");
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
// src/tools/erc8004CheckReputation.ts
|
|
1806
|
+
var import_zod13 = require("zod");
|
|
1807
|
+
var import_erc80043 = require("@t402/erc8004");
|
|
1808
|
+
var erc8004CheckReputationInputSchema = import_zod13.z.object({
|
|
1809
|
+
agentId: import_zod13.z.number().int().nonnegative().describe("Agent NFT token ID"),
|
|
1810
|
+
agentRegistry: import_zod13.z.string().regex(/^eip155:\d+:0x[a-fA-F0-9]+$/).describe('Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'),
|
|
1811
|
+
reputationRegistry: import_zod13.z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe("Reputation Registry contract address on the same chain"),
|
|
1812
|
+
trustedReviewers: import_zod13.z.array(import_zod13.z.string().regex(/^0x[a-fA-F0-9]{40}$/)).min(1).describe("Addresses whose feedback is trusted (required for Sybil resistance)")
|
|
1813
|
+
});
|
|
1814
|
+
async function executeErc8004CheckReputation(input, rpcUrls) {
|
|
1815
|
+
const { client } = createErc8004Client(input.agentRegistry, rpcUrls);
|
|
1816
|
+
return (0, import_erc80043.getReputationSummary)(
|
|
1817
|
+
client,
|
|
1818
|
+
input.reputationRegistry,
|
|
1819
|
+
BigInt(input.agentId),
|
|
1820
|
+
input.trustedReviewers
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1823
|
+
function formatErc8004CheckReputationResult(summary) {
|
|
1824
|
+
const lines = [
|
|
1825
|
+
`## Agent Reputation (ID: ${summary.agentId})`,
|
|
1826
|
+
"",
|
|
1827
|
+
`| Metric | Value |`,
|
|
1828
|
+
`|--------|-------|`,
|
|
1829
|
+
`| Feedback Count | ${summary.count} |`,
|
|
1830
|
+
`| Raw Score | ${summary.summaryValue} |`,
|
|
1831
|
+
`| Score Decimals | ${summary.summaryValueDecimals} |`,
|
|
1832
|
+
`| **Normalized Score** | **${summary.normalizedScore}/100** |`,
|
|
1833
|
+
""
|
|
1834
|
+
];
|
|
1835
|
+
if (summary.normalizedScore >= 80) {
|
|
1836
|
+
lines.push("_High reputation \u2014 trusted agent_");
|
|
1837
|
+
} else if (summary.normalizedScore >= 50) {
|
|
1838
|
+
lines.push("_Moderate reputation_");
|
|
1839
|
+
} else if (summary.count > 0n) {
|
|
1840
|
+
lines.push("_Low reputation \u2014 exercise caution_");
|
|
1841
|
+
} else {
|
|
1842
|
+
lines.push("_No feedback recorded from trusted reviewers_");
|
|
1843
|
+
}
|
|
1844
|
+
return lines.join("\n");
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
// src/tools/erc8004VerifyWallet.ts
|
|
1848
|
+
var import_zod14 = require("zod");
|
|
1849
|
+
var import_erc80044 = require("@t402/erc8004");
|
|
1850
|
+
var erc8004VerifyWalletInputSchema = import_zod14.z.object({
|
|
1851
|
+
agentId: import_zod14.z.number().int().nonnegative().describe("Agent NFT token ID"),
|
|
1852
|
+
agentRegistry: import_zod14.z.string().regex(/^eip155:\d+:0x[a-fA-F0-9]+$/).describe('Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'),
|
|
1853
|
+
walletAddress: import_zod14.z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe("Wallet address to verify (typically the payTo from PaymentRequirements)")
|
|
1854
|
+
});
|
|
1855
|
+
async function executeErc8004VerifyWallet(input, rpcUrls) {
|
|
1856
|
+
const { client, registryAddress } = createErc8004Client(input.agentRegistry, rpcUrls);
|
|
1857
|
+
const matches = await (0, import_erc80044.verifyPayToMatchesAgent)(
|
|
1858
|
+
client,
|
|
1859
|
+
registryAddress,
|
|
1860
|
+
BigInt(input.agentId),
|
|
1861
|
+
input.walletAddress
|
|
1862
|
+
);
|
|
1863
|
+
return {
|
|
1864
|
+
matches,
|
|
1865
|
+
agentId: input.agentId,
|
|
1866
|
+
walletAddress: input.walletAddress,
|
|
1867
|
+
registryAddress
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
function formatErc8004VerifyWalletResult(result) {
|
|
1871
|
+
const status = result.matches ? "VERIFIED" : "MISMATCH";
|
|
1872
|
+
const icon = result.matches ? "[PASS]" : "[FAIL]";
|
|
1873
|
+
const lines = [
|
|
1874
|
+
`## Wallet Verification: ${icon} ${status}`,
|
|
1875
|
+
"",
|
|
1876
|
+
`| Field | Value |`,
|
|
1877
|
+
`|-------|-------|`,
|
|
1878
|
+
`| Agent ID | ${result.agentId} |`,
|
|
1879
|
+
`| Wallet Address | \`${result.walletAddress}\` |`,
|
|
1880
|
+
`| Registry | \`${result.registryAddress}\` |`,
|
|
1881
|
+
`| **Result** | **${result.matches ? "Address matches on-chain agentWallet" : "Address does NOT match on-chain agentWallet"}** |`
|
|
1882
|
+
];
|
|
1883
|
+
return lines.join("\n");
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
// src/tools/unified.ts
|
|
1887
|
+
var import_zod15 = require("zod");
|
|
1888
|
+
var smartPayInputSchema = import_zod15.z.object({
|
|
1889
|
+
url: import_zod15.z.string().url().describe("URL of the 402-protected resource"),
|
|
1890
|
+
maxBridgeFee: import_zod15.z.string().regex(/^\d+(\.\d+)?$/).optional().describe("Maximum acceptable bridge fee in native token (optional)"),
|
|
1891
|
+
preferredNetwork: import_zod15.z.string().optional().describe("Preferred network for payment (optional)")
|
|
1892
|
+
});
|
|
1893
|
+
var paymentPlanInputSchema = import_zod15.z.object({
|
|
1894
|
+
paymentRequired: import_zod15.z.object({
|
|
1895
|
+
scheme: import_zod15.z.string().optional(),
|
|
1896
|
+
network: import_zod15.z.string().optional(),
|
|
1897
|
+
maxAmountRequired: import_zod15.z.string().optional(),
|
|
1898
|
+
resource: import_zod15.z.string().optional(),
|
|
1899
|
+
description: import_zod15.z.string().optional(),
|
|
1900
|
+
payTo: import_zod15.z.string().optional(),
|
|
1901
|
+
maxDeadline: import_zod15.z.number().optional()
|
|
1740
1902
|
}).passthrough().describe("The 402 PaymentRequired response")
|
|
1741
1903
|
});
|
|
1742
1904
|
var UNIFIED_TOOL_DEFINITIONS = {
|
|
@@ -1776,13 +1938,14 @@ var UNIFIED_TOOL_DEFINITIONS = {
|
|
|
1776
1938
|
};
|
|
1777
1939
|
async function executeSmartPay(input, wdk) {
|
|
1778
1940
|
const steps = [];
|
|
1779
|
-
const
|
|
1941
|
+
const chains7 = input.preferredNetwork ? [input.preferredNetwork] : ["ethereum", "arbitrum", "base"];
|
|
1780
1942
|
steps.push({
|
|
1781
1943
|
action: "check_balance",
|
|
1782
1944
|
status: "success",
|
|
1783
|
-
detail: `Checking balances on ${
|
|
1945
|
+
detail: `Checking balances on ${chains7.join(", ")}`
|
|
1784
1946
|
});
|
|
1785
|
-
const
|
|
1947
|
+
const { T402Protocol } = await import("@t402/wdk-protocol");
|
|
1948
|
+
const protocol = await T402Protocol.create(wdk, { chains: chains7 });
|
|
1786
1949
|
steps.push({
|
|
1787
1950
|
action: "fetch",
|
|
1788
1951
|
status: "success",
|
|
@@ -2274,6 +2437,81 @@ var WDK_TOOL_DEFINITIONS = {
|
|
|
2274
2437
|
}
|
|
2275
2438
|
}
|
|
2276
2439
|
};
|
|
2440
|
+
var ERC8004_TOOL_DEFINITIONS = {
|
|
2441
|
+
"erc8004/resolveAgent": {
|
|
2442
|
+
name: "erc8004/resolveAgent",
|
|
2443
|
+
description: "Look up an agent's on-chain ERC-8004 identity. Returns the agent's registered wallet address, owner, registration file (name, description, services), and verification URI. Use this to verify an agent before making a payment.",
|
|
2444
|
+
inputSchema: {
|
|
2445
|
+
type: "object",
|
|
2446
|
+
properties: {
|
|
2447
|
+
agentId: {
|
|
2448
|
+
type: "number",
|
|
2449
|
+
description: "Agent NFT token ID on the Identity Registry"
|
|
2450
|
+
},
|
|
2451
|
+
agentRegistry: {
|
|
2452
|
+
type: "string",
|
|
2453
|
+
pattern: "^eip155:\\d+:0x[a-fA-F0-9]+$",
|
|
2454
|
+
description: 'Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'
|
|
2455
|
+
}
|
|
2456
|
+
},
|
|
2457
|
+
required: ["agentId", "agentRegistry"]
|
|
2458
|
+
}
|
|
2459
|
+
},
|
|
2460
|
+
"erc8004/checkReputation": {
|
|
2461
|
+
name: "erc8004/checkReputation",
|
|
2462
|
+
description: "Query an agent's reputation score from the on-chain Reputation Registry. Returns a normalized 0-100 score based on feedback from trusted reviewers. Requires explicit trusted reviewer addresses for Sybil resistance.",
|
|
2463
|
+
inputSchema: {
|
|
2464
|
+
type: "object",
|
|
2465
|
+
properties: {
|
|
2466
|
+
agentId: {
|
|
2467
|
+
type: "number",
|
|
2468
|
+
description: "Agent NFT token ID"
|
|
2469
|
+
},
|
|
2470
|
+
agentRegistry: {
|
|
2471
|
+
type: "string",
|
|
2472
|
+
pattern: "^eip155:\\d+:0x[a-fA-F0-9]+$",
|
|
2473
|
+
description: 'Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'
|
|
2474
|
+
},
|
|
2475
|
+
reputationRegistry: {
|
|
2476
|
+
type: "string",
|
|
2477
|
+
pattern: "^0x[a-fA-F0-9]{40}$",
|
|
2478
|
+
description: "Reputation Registry contract address on the same chain"
|
|
2479
|
+
},
|
|
2480
|
+
trustedReviewers: {
|
|
2481
|
+
type: "array",
|
|
2482
|
+
items: { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" },
|
|
2483
|
+
minItems: 1,
|
|
2484
|
+
description: "Addresses whose feedback is trusted (required for Sybil resistance)"
|
|
2485
|
+
}
|
|
2486
|
+
},
|
|
2487
|
+
required: ["agentId", "agentRegistry", "reputationRegistry", "trustedReviewers"]
|
|
2488
|
+
}
|
|
2489
|
+
},
|
|
2490
|
+
"erc8004/verifyWallet": {
|
|
2491
|
+
name: "erc8004/verifyWallet",
|
|
2492
|
+
description: "Verify that a payment address (payTo) matches an agent's on-chain registered wallet. Use this before paying to confirm the recipient address is legitimate and owned by the declared agent.",
|
|
2493
|
+
inputSchema: {
|
|
2494
|
+
type: "object",
|
|
2495
|
+
properties: {
|
|
2496
|
+
agentId: {
|
|
2497
|
+
type: "number",
|
|
2498
|
+
description: "Agent NFT token ID"
|
|
2499
|
+
},
|
|
2500
|
+
agentRegistry: {
|
|
2501
|
+
type: "string",
|
|
2502
|
+
pattern: "^eip155:\\d+:0x[a-fA-F0-9]+$",
|
|
2503
|
+
description: 'Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'
|
|
2504
|
+
},
|
|
2505
|
+
walletAddress: {
|
|
2506
|
+
type: "string",
|
|
2507
|
+
pattern: "^0x[a-fA-F0-9]{40}$",
|
|
2508
|
+
description: "Wallet address to verify (typically the payTo from payment requirements)"
|
|
2509
|
+
}
|
|
2510
|
+
},
|
|
2511
|
+
required: ["agentId", "agentRegistry", "walletAddress"]
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2277
2515
|
|
|
2278
2516
|
// src/server/t402Server.ts
|
|
2279
2517
|
var T402McpServer = class {
|
|
@@ -2327,7 +2565,7 @@ var T402McpServer = class {
|
|
|
2327
2565
|
* Get all tool definitions (base + WDK if configured + unified if enabled + TON bridge if registered)
|
|
2328
2566
|
*/
|
|
2329
2567
|
getToolDefinitions() {
|
|
2330
|
-
const tools = { ...TOOL_DEFINITIONS };
|
|
2568
|
+
const tools = { ...TOOL_DEFINITIONS, ...ERC8004_TOOL_DEFINITIONS };
|
|
2331
2569
|
if (this.wdk || this.config.demoMode) {
|
|
2332
2570
|
Object.assign(tools, WDK_TOOL_DEFINITIONS);
|
|
2333
2571
|
}
|
|
@@ -2380,6 +2618,13 @@ var T402McpServer = class {
|
|
|
2380
2618
|
return await this.handleSmartPay(args);
|
|
2381
2619
|
case "t402/paymentPlan":
|
|
2382
2620
|
return await this.handlePaymentPlan(args);
|
|
2621
|
+
// ERC-8004 tools
|
|
2622
|
+
case "erc8004/resolveAgent":
|
|
2623
|
+
return await this.handleErc8004ResolveAgent(args);
|
|
2624
|
+
case "erc8004/checkReputation":
|
|
2625
|
+
return await this.handleErc8004CheckReputation(args);
|
|
2626
|
+
case "erc8004/verifyWallet":
|
|
2627
|
+
return await this.handleErc8004VerifyWallet(args);
|
|
2383
2628
|
// TON bridge tools
|
|
2384
2629
|
case "ton/getBalance":
|
|
2385
2630
|
case "ton/transfer":
|
|
@@ -2605,6 +2850,37 @@ var T402McpServer = class {
|
|
|
2605
2850
|
content: [{ type: "text", text: formatPaymentPlanResult(result) }]
|
|
2606
2851
|
};
|
|
2607
2852
|
}
|
|
2853
|
+
// ---- ERC-8004 Tool Handlers ----
|
|
2854
|
+
/**
|
|
2855
|
+
* Handle erc8004/resolveAgent
|
|
2856
|
+
*/
|
|
2857
|
+
async handleErc8004ResolveAgent(args) {
|
|
2858
|
+
const input = erc8004ResolveAgentInputSchema.parse(args);
|
|
2859
|
+
const result = await executeErc8004ResolveAgent(input, this.config.rpcUrls);
|
|
2860
|
+
return {
|
|
2861
|
+
content: [{ type: "text", text: formatErc8004ResolveAgentResult(result) }]
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
/**
|
|
2865
|
+
* Handle erc8004/checkReputation
|
|
2866
|
+
*/
|
|
2867
|
+
async handleErc8004CheckReputation(args) {
|
|
2868
|
+
const input = erc8004CheckReputationInputSchema.parse(args);
|
|
2869
|
+
const result = await executeErc8004CheckReputation(input, this.config.rpcUrls);
|
|
2870
|
+
return {
|
|
2871
|
+
content: [{ type: "text", text: formatErc8004CheckReputationResult(result) }]
|
|
2872
|
+
};
|
|
2873
|
+
}
|
|
2874
|
+
/**
|
|
2875
|
+
* Handle erc8004/verifyWallet
|
|
2876
|
+
*/
|
|
2877
|
+
async handleErc8004VerifyWallet(args) {
|
|
2878
|
+
const input = erc8004VerifyWalletInputSchema.parse(args);
|
|
2879
|
+
const result = await executeErc8004VerifyWallet(input, this.config.rpcUrls);
|
|
2880
|
+
return {
|
|
2881
|
+
content: [{ type: "text", text: formatErc8004VerifyWalletResult(result) }]
|
|
2882
|
+
};
|
|
2883
|
+
}
|
|
2608
2884
|
// ---- TON Bridge Tool Handler ----
|
|
2609
2885
|
/**
|
|
2610
2886
|
* Handle TON bridge tool calls
|