@x402scan/mcp 0.0.5 → 0.0.6
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/run-server.cjs +63706 -76028
- package/dist/esm/index.js +325 -263
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import z, { z
|
|
3
|
-
import { getAddress,
|
|
2
|
+
import z$1, { z } from 'zod';
|
|
3
|
+
import { getAddress, formatUnits } from 'viem';
|
|
4
4
|
import path2, { join } from 'path';
|
|
5
5
|
import os, { homedir } from 'os';
|
|
6
6
|
import * as fs from 'fs';
|
|
@@ -10,7 +10,7 @@ import { intro, outro, log as log$1, confirm, stream, spinner, select, text } fr
|
|
|
10
10
|
import { errAsync, ResultAsync, err } from 'neverthrow';
|
|
11
11
|
import chalk from 'chalk';
|
|
12
12
|
import open from 'open';
|
|
13
|
-
import {
|
|
13
|
+
import { x402HTTPClient, x402Client } from '@x402/core/client';
|
|
14
14
|
import { ExactEvmScheme } from '@x402/evm/exact/client';
|
|
15
15
|
import { wrapFetchWithPayment } from '@x402/fetch';
|
|
16
16
|
import { base58 } from '@scure/base';
|
|
@@ -40,6 +40,96 @@ var __export = (target, all) => {
|
|
|
40
40
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
// src/install/clients.ts
|
|
44
|
+
var Clients, clientMetadata;
|
|
45
|
+
var init_clients = __esm({
|
|
46
|
+
"src/install/clients.ts"() {
|
|
47
|
+
Clients = /* @__PURE__ */ ((Clients2) => {
|
|
48
|
+
Clients2["ClaudeCode"] = "claude-code";
|
|
49
|
+
Clients2["Cursor"] = "cursor";
|
|
50
|
+
Clients2["Claude"] = "claude";
|
|
51
|
+
Clients2["Codex"] = "codex";
|
|
52
|
+
Clients2["Vscode"] = "vscode";
|
|
53
|
+
Clients2["Cline"] = "cline";
|
|
54
|
+
Clients2["RooCline"] = "roo-cline";
|
|
55
|
+
Clients2["Windsurf"] = "windsurf";
|
|
56
|
+
Clients2["Warp"] = "warp";
|
|
57
|
+
Clients2["GeminiCli"] = "gemini-cli";
|
|
58
|
+
Clients2["Goose"] = "goose";
|
|
59
|
+
Clients2["Zed"] = "zed";
|
|
60
|
+
Clients2["Opencode"] = "opencode";
|
|
61
|
+
return Clients2;
|
|
62
|
+
})(Clients || {});
|
|
63
|
+
clientMetadata = {
|
|
64
|
+
["claude-code" /* ClaudeCode */]: {
|
|
65
|
+
name: "Claude Code",
|
|
66
|
+
description: "Claude Code is a code editor that uses the Claude API.",
|
|
67
|
+
website: "https://claude.com"
|
|
68
|
+
},
|
|
69
|
+
["cursor" /* Cursor */]: {
|
|
70
|
+
name: "Cursor",
|
|
71
|
+
description: "Cursor is a code editor that uses the Cursor API.",
|
|
72
|
+
website: "https://cursor.com"
|
|
73
|
+
},
|
|
74
|
+
["claude" /* Claude */]: {
|
|
75
|
+
name: "Claude",
|
|
76
|
+
description: "Claude is a code editor that uses the Claude API.",
|
|
77
|
+
website: "https://claude.com"
|
|
78
|
+
},
|
|
79
|
+
["codex" /* Codex */]: {
|
|
80
|
+
name: "Codex",
|
|
81
|
+
description: "Codex is a code editor that uses the Codex API.",
|
|
82
|
+
website: "https://codex.com"
|
|
83
|
+
},
|
|
84
|
+
["vscode" /* Vscode */]: {
|
|
85
|
+
name: "VSCode",
|
|
86
|
+
description: "VSCode is a code editor that uses the VSCode API.",
|
|
87
|
+
website: "https://vscode.com"
|
|
88
|
+
},
|
|
89
|
+
["cline" /* Cline */]: {
|
|
90
|
+
name: "Cline",
|
|
91
|
+
description: "Cline is a code editor that uses the Cline API.",
|
|
92
|
+
website: "https://cline.com"
|
|
93
|
+
},
|
|
94
|
+
["roo-cline" /* RooCline */]: {
|
|
95
|
+
name: "RooCline",
|
|
96
|
+
description: "RooCline is a code editor that uses the RooCline API.",
|
|
97
|
+
website: "https://roo-cline.com"
|
|
98
|
+
},
|
|
99
|
+
["windsurf" /* Windsurf */]: {
|
|
100
|
+
name: "Windsurf",
|
|
101
|
+
description: "Windsurf is a code editor that uses the Windsurf API.",
|
|
102
|
+
website: "https://windsurf.com"
|
|
103
|
+
},
|
|
104
|
+
["warp" /* Warp */]: {
|
|
105
|
+
name: "Warp",
|
|
106
|
+
description: "Warp is a code editor that uses the Warp API.",
|
|
107
|
+
website: "https://warp.com"
|
|
108
|
+
},
|
|
109
|
+
["gemini-cli" /* GeminiCli */]: {
|
|
110
|
+
name: "Gemini CLI",
|
|
111
|
+
description: "Gemini CLI is a code editor that uses the Gemini CLI API.",
|
|
112
|
+
website: "https://gemini-cli.com"
|
|
113
|
+
},
|
|
114
|
+
["goose" /* Goose */]: {
|
|
115
|
+
name: "Goose",
|
|
116
|
+
description: "Goose is a code editor that uses the Goose API.",
|
|
117
|
+
website: "https://goose.com"
|
|
118
|
+
},
|
|
119
|
+
["zed" /* Zed */]: {
|
|
120
|
+
name: "Zed",
|
|
121
|
+
description: "Zed is a code editor that uses the Zed API.",
|
|
122
|
+
website: "https://zed.com"
|
|
123
|
+
},
|
|
124
|
+
["opencode" /* Opencode */]: {
|
|
125
|
+
name: "Opencode",
|
|
126
|
+
description: "Opencode is a code editor that uses the Opencode API.",
|
|
127
|
+
website: "https://opencode.com"
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
43
133
|
// src/server/lib/response.ts
|
|
44
134
|
var mcpSuccess, mcpError;
|
|
45
135
|
var init_response = __esm({
|
|
@@ -75,15 +165,15 @@ var init_response = __esm({
|
|
|
75
165
|
var ethereumAddressSchema, ethereumPrivateKeySchema, requestSchema, requestWithHeadersSchema;
|
|
76
166
|
var init_schemas = __esm({
|
|
77
167
|
"src/server/lib/schemas.ts"() {
|
|
78
|
-
ethereumAddressSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address").transform((address) => getAddress(address));
|
|
79
|
-
ethereumPrivateKeySchema = z.string().regex(/^0x[a-fA-F0-9]{64}$/, "Invalid Ethereum private key").transform((privateKey) => privateKey);
|
|
80
|
-
requestSchema = z.object({
|
|
81
|
-
url: z.url().describe("The endpoint URL"),
|
|
82
|
-
method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).default("GET").describe("HTTP method"),
|
|
83
|
-
body: z.unknown().optional().describe("Request body for POST/PUT/PATCH methods")
|
|
168
|
+
ethereumAddressSchema = z$1.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address").transform((address) => getAddress(address));
|
|
169
|
+
ethereumPrivateKeySchema = z$1.string().regex(/^0x[a-fA-F0-9]{64}$/, "Invalid Ethereum private key").transform((privateKey) => privateKey);
|
|
170
|
+
requestSchema = z$1.object({
|
|
171
|
+
url: z$1.url().describe("The endpoint URL"),
|
|
172
|
+
method: z$1.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).default("GET").describe("HTTP method"),
|
|
173
|
+
body: z$1.unknown().optional().describe("Request body for POST/PUT/PATCH methods")
|
|
84
174
|
});
|
|
85
175
|
requestWithHeadersSchema = requestSchema.extend({
|
|
86
|
-
headers: z.record(z.string(), z.string()).optional().describe("Additional headers to include").default({})
|
|
176
|
+
headers: z$1.record(z$1.string(), z$1.string()).optional().describe("Additional headers to include").default({})
|
|
87
177
|
});
|
|
88
178
|
}
|
|
89
179
|
});
|
|
@@ -150,12 +240,6 @@ function toCaip2(network) {
|
|
|
150
240
|
function getChainConfig(network) {
|
|
151
241
|
return CHAIN_CONFIGS[toCaip2(network)];
|
|
152
242
|
}
|
|
153
|
-
function getUSDCAddress(network) {
|
|
154
|
-
return getChainConfig(network)?.usdcAddress;
|
|
155
|
-
}
|
|
156
|
-
function getChain(network) {
|
|
157
|
-
return getChainConfig(network)?.chain;
|
|
158
|
-
}
|
|
159
243
|
function getChainName(network) {
|
|
160
244
|
return getChainConfig(network)?.chain.name ?? network;
|
|
161
245
|
}
|
|
@@ -218,41 +302,66 @@ var init_networks = __esm({
|
|
|
218
302
|
DEFAULT_NETWORK = "eip155:8453";
|
|
219
303
|
}
|
|
220
304
|
});
|
|
221
|
-
var
|
|
305
|
+
var tokenStringToNumber;
|
|
222
306
|
var init_token = __esm({
|
|
223
307
|
"src/lib/token.ts"() {
|
|
224
|
-
tokenBigIntToNumber = (amount, decimals = 6) => {
|
|
225
|
-
return Number(formatUnits(amount, decimals));
|
|
226
|
-
};
|
|
227
308
|
tokenStringToNumber = (amount, decimals = 6) => {
|
|
228
|
-
return
|
|
309
|
+
return Number(formatUnits(BigInt(amount), decimals));
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// src/lib/utils.ts
|
|
315
|
+
var getBaseUrl;
|
|
316
|
+
var init_utils = __esm({
|
|
317
|
+
"src/lib/utils.ts"() {
|
|
318
|
+
getBaseUrl = (dev) => {
|
|
319
|
+
return dev ? "http://localhost:3000" : "https://x402scan.com";
|
|
229
320
|
};
|
|
230
321
|
}
|
|
231
322
|
});
|
|
232
|
-
async function getUSDCBalance({
|
|
233
|
-
address
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const usdcAddress = getUSDCAddress(caip2);
|
|
240
|
-
if (!usdcAddress) throw new Error(`No USDC address for network: ${network}`);
|
|
241
|
-
log.debug(`Reading USDC balance for ${address} on ${chain.name}`);
|
|
242
|
-
const client = createPublicClient({ chain, transport: http() });
|
|
243
|
-
const balance = await client.readContract({
|
|
244
|
-
address: usdcAddress,
|
|
245
|
-
abi: erc20Abi,
|
|
246
|
-
functionName: "balanceOf",
|
|
247
|
-
args: [address]
|
|
323
|
+
async function getUSDCBalance(address, flags) {
|
|
324
|
+
const url = `${getBaseUrl(flags.dev)}/api/rpc/balance/${address}`;
|
|
325
|
+
const res = await fetch(url, {
|
|
326
|
+
method: "GET",
|
|
327
|
+
headers: {
|
|
328
|
+
accept: "application/json"
|
|
329
|
+
}
|
|
248
330
|
});
|
|
249
|
-
|
|
331
|
+
if (!res.ok) {
|
|
332
|
+
throw new Error(
|
|
333
|
+
`Balance API request failed (${res.status} ${res.statusText})`
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
let json;
|
|
337
|
+
try {
|
|
338
|
+
json = await res.json();
|
|
339
|
+
} catch {
|
|
340
|
+
throw new Error(
|
|
341
|
+
`Failed to parse balance API response as JSON (${res.status} ${res.statusText})`
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
const result = balanceApiResponseSchema.safeParse(json);
|
|
345
|
+
if (!result.success) {
|
|
346
|
+
throw new Error(
|
|
347
|
+
`Failed to safeParse balance API response (${res.status} ${res.statusText})`
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
balanceFormatted: result.data.balance,
|
|
352
|
+
balanceRaw: result.data.rawBalance
|
|
353
|
+
};
|
|
250
354
|
}
|
|
355
|
+
var balanceApiResponseSchema;
|
|
251
356
|
var init_balance = __esm({
|
|
252
357
|
"src/lib/balance.ts"() {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
358
|
+
init_utils();
|
|
359
|
+
balanceApiResponseSchema = z.object({
|
|
360
|
+
address: z.string(),
|
|
361
|
+
chain: z.number().int(),
|
|
362
|
+
balance: z.coerce.number(),
|
|
363
|
+
rawBalance: z.string()
|
|
364
|
+
});
|
|
256
365
|
}
|
|
257
366
|
});
|
|
258
367
|
var wait;
|
|
@@ -306,24 +415,14 @@ var init_safe_fetch = __esm({
|
|
|
306
415
|
};
|
|
307
416
|
}
|
|
308
417
|
});
|
|
309
|
-
|
|
310
|
-
// src/lib/utils.ts
|
|
311
|
-
var getBaseUrl;
|
|
312
|
-
var init_utils = __esm({
|
|
313
|
-
"src/lib/utils.ts"() {
|
|
314
|
-
getBaseUrl = (dev) => {
|
|
315
|
-
return dev ? "http://localhost:3000" : "https://x402scan.com";
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
418
|
var STATE_FILE, stateSchema, getState, setState;
|
|
320
419
|
var init_state = __esm({
|
|
321
420
|
"src/lib/state.ts"() {
|
|
322
421
|
init_fs();
|
|
323
422
|
init_log();
|
|
324
423
|
STATE_FILE = configFile("state.json");
|
|
325
|
-
stateSchema = z.looseObject({
|
|
326
|
-
redeemedCodes: z.array(z.string())
|
|
424
|
+
stateSchema = z$1.looseObject({
|
|
425
|
+
redeemedCodes: z$1.array(z$1.string())
|
|
327
426
|
}).partial();
|
|
328
427
|
getState = () => {
|
|
329
428
|
if (!fs__default.existsSync(STATE_FILE)) {
|
|
@@ -448,7 +547,7 @@ var init_deposit = __esm({
|
|
|
448
547
|
};
|
|
449
548
|
promptDeposit = async (address, flags) => {
|
|
450
549
|
const depositLink = getDepositLink(address, flags);
|
|
451
|
-
const depositChoice = await select({
|
|
550
|
+
const depositChoice = flags.yes ? "manual" : await select({
|
|
452
551
|
message: chalk.bold("How would you like to deposit?"),
|
|
453
552
|
initialValue: "guided",
|
|
454
553
|
options: [
|
|
@@ -510,21 +609,19 @@ var init_check_balance = __esm({
|
|
|
510
609
|
message,
|
|
511
610
|
flags
|
|
512
611
|
}) => {
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
});
|
|
516
|
-
if (balance < amountNeeded) {
|
|
612
|
+
const { balanceFormatted } = await getUSDCBalance(address, flags);
|
|
613
|
+
if (balanceFormatted < amountNeeded) {
|
|
517
614
|
const capabilities = server.server.getClientCapabilities();
|
|
518
615
|
if (!capabilities?.elicitation) {
|
|
519
616
|
throw new Error(
|
|
520
|
-
`${message(
|
|
617
|
+
`${message(balanceFormatted)}
|
|
521
618
|
|
|
522
619
|
You can deposit USDC at ${getDepositLink(address, flags)}`
|
|
523
620
|
);
|
|
524
621
|
}
|
|
525
622
|
const result = await server.server.elicitInput({
|
|
526
623
|
mode: "form",
|
|
527
|
-
message: message(
|
|
624
|
+
message: message(balanceFormatted),
|
|
528
625
|
requestedSchema: {
|
|
529
626
|
type: "object",
|
|
530
627
|
properties: {}
|
|
@@ -534,7 +631,7 @@ You can deposit USDC at ${getDepositLink(address, flags)}`
|
|
|
534
631
|
await openDepositLink(address, flags);
|
|
535
632
|
}
|
|
536
633
|
}
|
|
537
|
-
return
|
|
634
|
+
return balanceFormatted;
|
|
538
635
|
};
|
|
539
636
|
}
|
|
540
637
|
});
|
|
@@ -1055,9 +1152,11 @@ var init_wallet = __esm({
|
|
|
1055
1152
|
init_response();
|
|
1056
1153
|
init_balance();
|
|
1057
1154
|
init_networks();
|
|
1155
|
+
init_deposit();
|
|
1058
1156
|
registerWalletTools = ({
|
|
1059
1157
|
server,
|
|
1060
|
-
account: { address }
|
|
1158
|
+
account: { address },
|
|
1159
|
+
flags
|
|
1061
1160
|
}) => {
|
|
1062
1161
|
server.registerTool(
|
|
1063
1162
|
"check_balance",
|
|
@@ -1065,16 +1164,15 @@ var init_wallet = __esm({
|
|
|
1065
1164
|
description: "Check wallet address and USDC balance. Creates wallet if needed."
|
|
1066
1165
|
},
|
|
1067
1166
|
async () => {
|
|
1068
|
-
const
|
|
1069
|
-
address
|
|
1070
|
-
});
|
|
1167
|
+
const { balanceFormatted } = await getUSDCBalance(address, flags);
|
|
1071
1168
|
return mcpSuccess({
|
|
1072
1169
|
address,
|
|
1073
1170
|
network: DEFAULT_NETWORK,
|
|
1074
1171
|
networkName: getChainName(DEFAULT_NETWORK),
|
|
1075
|
-
usdcBalance:
|
|
1076
|
-
balanceFormatted:
|
|
1077
|
-
isNewWallet:
|
|
1172
|
+
usdcBalance: balanceFormatted,
|
|
1173
|
+
balanceFormatted: balanceFormatted.toString(),
|
|
1174
|
+
isNewWallet: balanceFormatted === 0,
|
|
1175
|
+
depositLink: getDepositLink(address, flags)
|
|
1078
1176
|
});
|
|
1079
1177
|
}
|
|
1080
1178
|
);
|
|
@@ -1182,8 +1280,8 @@ var init_redeem_invite2 = __esm({
|
|
|
1182
1280
|
"redeem_invite",
|
|
1183
1281
|
{
|
|
1184
1282
|
description: "Redeem an invite code to receive USDC.",
|
|
1185
|
-
inputSchema: z.object({
|
|
1186
|
-
code: z.string().min(1).describe("The invite code")
|
|
1283
|
+
inputSchema: z$1.object({
|
|
1284
|
+
code: z$1.string().min(1).describe("The invite code")
|
|
1187
1285
|
})
|
|
1188
1286
|
},
|
|
1189
1287
|
async ({ code }) => {
|
|
@@ -1207,7 +1305,7 @@ var init_redeem_invite2 = __esm({
|
|
|
1207
1305
|
});
|
|
1208
1306
|
function getVersion() {
|
|
1209
1307
|
{
|
|
1210
|
-
return "0.0.
|
|
1308
|
+
return "0.0.6";
|
|
1211
1309
|
}
|
|
1212
1310
|
}
|
|
1213
1311
|
var MCP_VERSION;
|
|
@@ -1222,13 +1320,13 @@ var init_telemetry = __esm({
|
|
|
1222
1320
|
init_log();
|
|
1223
1321
|
init_response();
|
|
1224
1322
|
init_version();
|
|
1225
|
-
errorReportSchema = z
|
|
1226
|
-
tool: z
|
|
1227
|
-
resource: z
|
|
1228
|
-
summary: z
|
|
1229
|
-
errorMessage: z
|
|
1230
|
-
stack: z
|
|
1231
|
-
fullReport: z
|
|
1323
|
+
errorReportSchema = z.object({
|
|
1324
|
+
tool: z.string().describe("MCP tool name"),
|
|
1325
|
+
resource: z.string().optional().describe("x402 resource URL"),
|
|
1326
|
+
summary: z.string().describe("1-2 sentence summary"),
|
|
1327
|
+
errorMessage: z.string().describe("Error message"),
|
|
1328
|
+
stack: z.string().optional().describe("Stack trace"),
|
|
1329
|
+
fullReport: z.string().optional().describe("Detailed report with context, logs, repro steps")
|
|
1232
1330
|
});
|
|
1233
1331
|
registerTelemetryTools = ({
|
|
1234
1332
|
server,
|
|
@@ -1457,10 +1555,10 @@ var init_wallet2 = __esm({
|
|
|
1457
1555
|
init_schemas();
|
|
1458
1556
|
init_fs();
|
|
1459
1557
|
WALLET_FILE = configFile("wallet.json");
|
|
1460
|
-
storedWalletSchema = z.object({
|
|
1558
|
+
storedWalletSchema = z$1.object({
|
|
1461
1559
|
privateKey: ethereumPrivateKeySchema,
|
|
1462
1560
|
address: ethereumAddressSchema,
|
|
1463
|
-
createdAt: z.string()
|
|
1561
|
+
createdAt: z$1.string()
|
|
1464
1562
|
});
|
|
1465
1563
|
}
|
|
1466
1564
|
});
|
|
@@ -1681,13 +1779,13 @@ function registerDiscoveryTools(server) {
|
|
|
1681
1779
|
- https://stablestudio.io -> generate images / videos
|
|
1682
1780
|
`,
|
|
1683
1781
|
inputSchema: {
|
|
1684
|
-
url: z
|
|
1782
|
+
url: z.url().describe(
|
|
1685
1783
|
"The origin URL or any URL on the origin to discover resources from"
|
|
1686
1784
|
),
|
|
1687
|
-
fanOut: z
|
|
1785
|
+
fanOut: z.boolean().default(false).describe(
|
|
1688
1786
|
"Whether to query each discovered resource for full pricing/schema info. NEVER use on first try."
|
|
1689
1787
|
),
|
|
1690
|
-
concurrency: z
|
|
1788
|
+
concurrency: z.number().int().min(1).max(10).default(5).describe(
|
|
1691
1789
|
"Max concurrent requests when querying resources (default: 5)"
|
|
1692
1790
|
)
|
|
1693
1791
|
}
|
|
@@ -1770,11 +1868,11 @@ var init_discover_resources = __esm({
|
|
|
1770
1868
|
init_response();
|
|
1771
1869
|
init_token();
|
|
1772
1870
|
init_networks();
|
|
1773
|
-
DiscoveryDocumentSchema = z
|
|
1774
|
-
version: z
|
|
1775
|
-
resources: z
|
|
1776
|
-
ownershipProofs: z
|
|
1777
|
-
instructions: z
|
|
1871
|
+
DiscoveryDocumentSchema = z.object({
|
|
1872
|
+
version: z.number().refine((v) => v === 1, { message: "version must be 1" }),
|
|
1873
|
+
resources: z.array(z.url()),
|
|
1874
|
+
ownershipProofs: z.array(z.string()).optional(),
|
|
1875
|
+
instructions: z.string().optional()
|
|
1778
1876
|
});
|
|
1779
1877
|
}
|
|
1780
1878
|
});
|
|
@@ -1852,102 +1950,26 @@ var init_server = __esm({
|
|
|
1852
1950
|
};
|
|
1853
1951
|
}
|
|
1854
1952
|
});
|
|
1855
|
-
|
|
1856
|
-
// src/install/clients.ts
|
|
1857
|
-
var Clients, clientMetadata;
|
|
1858
|
-
var init_clients = __esm({
|
|
1859
|
-
"src/install/clients.ts"() {
|
|
1860
|
-
Clients = /* @__PURE__ */ ((Clients2) => {
|
|
1861
|
-
Clients2["ClaudeCode"] = "claude-code";
|
|
1862
|
-
Clients2["Cursor"] = "cursor";
|
|
1863
|
-
Clients2["Claude"] = "claude";
|
|
1864
|
-
Clients2["Codex"] = "codex";
|
|
1865
|
-
Clients2["Vscode"] = "vscode";
|
|
1866
|
-
Clients2["Cline"] = "cline";
|
|
1867
|
-
Clients2["RooCline"] = "roo-cline";
|
|
1868
|
-
Clients2["Windsurf"] = "windsurf";
|
|
1869
|
-
Clients2["Warp"] = "warp";
|
|
1870
|
-
Clients2["GeminiCli"] = "gemini-cli";
|
|
1871
|
-
Clients2["Goose"] = "goose";
|
|
1872
|
-
Clients2["Zed"] = "zed";
|
|
1873
|
-
Clients2["Opencode"] = "opencode";
|
|
1874
|
-
return Clients2;
|
|
1875
|
-
})(Clients || {});
|
|
1876
|
-
clientMetadata = {
|
|
1877
|
-
["claude-code" /* ClaudeCode */]: {
|
|
1878
|
-
name: "Claude Code",
|
|
1879
|
-
description: "Claude Code is a code editor that uses the Claude API.",
|
|
1880
|
-
website: "https://claude.com"
|
|
1881
|
-
},
|
|
1882
|
-
["cursor" /* Cursor */]: {
|
|
1883
|
-
name: "Cursor",
|
|
1884
|
-
description: "Cursor is a code editor that uses the Cursor API.",
|
|
1885
|
-
website: "https://cursor.com"
|
|
1886
|
-
},
|
|
1887
|
-
["claude" /* Claude */]: {
|
|
1888
|
-
name: "Claude",
|
|
1889
|
-
description: "Claude is a code editor that uses the Claude API.",
|
|
1890
|
-
website: "https://claude.com"
|
|
1891
|
-
},
|
|
1892
|
-
["codex" /* Codex */]: {
|
|
1893
|
-
name: "Codex",
|
|
1894
|
-
description: "Codex is a code editor that uses the Codex API.",
|
|
1895
|
-
website: "https://codex.com"
|
|
1896
|
-
},
|
|
1897
|
-
["vscode" /* Vscode */]: {
|
|
1898
|
-
name: "VSCode",
|
|
1899
|
-
description: "VSCode is a code editor that uses the VSCode API.",
|
|
1900
|
-
website: "https://vscode.com"
|
|
1901
|
-
},
|
|
1902
|
-
["cline" /* Cline */]: {
|
|
1903
|
-
name: "Cline",
|
|
1904
|
-
description: "Cline is a code editor that uses the Cline API.",
|
|
1905
|
-
website: "https://cline.com"
|
|
1906
|
-
},
|
|
1907
|
-
["roo-cline" /* RooCline */]: {
|
|
1908
|
-
name: "RooCline",
|
|
1909
|
-
description: "RooCline is a code editor that uses the RooCline API.",
|
|
1910
|
-
website: "https://roo-cline.com"
|
|
1911
|
-
},
|
|
1912
|
-
["windsurf" /* Windsurf */]: {
|
|
1913
|
-
name: "Windsurf",
|
|
1914
|
-
description: "Windsurf is a code editor that uses the Windsurf API.",
|
|
1915
|
-
website: "https://windsurf.com"
|
|
1916
|
-
},
|
|
1917
|
-
["warp" /* Warp */]: {
|
|
1918
|
-
name: "Warp",
|
|
1919
|
-
description: "Warp is a code editor that uses the Warp API.",
|
|
1920
|
-
website: "https://warp.com"
|
|
1921
|
-
},
|
|
1922
|
-
["gemini-cli" /* GeminiCli */]: {
|
|
1923
|
-
name: "Gemini CLI",
|
|
1924
|
-
description: "Gemini CLI is a code editor that uses the Gemini CLI API.",
|
|
1925
|
-
website: "https://gemini-cli.com"
|
|
1926
|
-
},
|
|
1927
|
-
["goose" /* Goose */]: {
|
|
1928
|
-
name: "Goose",
|
|
1929
|
-
description: "Goose is a code editor that uses the Goose API.",
|
|
1930
|
-
website: "https://goose.com"
|
|
1931
|
-
},
|
|
1932
|
-
["zed" /* Zed */]: {
|
|
1933
|
-
name: "Zed",
|
|
1934
|
-
description: "Zed is a code editor that uses the Zed API.",
|
|
1935
|
-
website: "https://zed.com"
|
|
1936
|
-
},
|
|
1937
|
-
["opencode" /* Opencode */]: {
|
|
1938
|
-
name: "Opencode",
|
|
1939
|
-
description: "Opencode is a code editor that uses the Opencode API.",
|
|
1940
|
-
website: "https://opencode.com"
|
|
1941
|
-
}
|
|
1942
|
-
};
|
|
1943
|
-
}
|
|
1944
|
-
});
|
|
1945
1953
|
var getClient;
|
|
1946
1954
|
var init_get_client = __esm({
|
|
1947
1955
|
"src/install/1-get-client/index.ts"() {
|
|
1948
1956
|
init_clients();
|
|
1949
|
-
getClient = async ({ client: flagClient }) => {
|
|
1950
|
-
|
|
1957
|
+
getClient = async ({ client: flagClient, yes }) => {
|
|
1958
|
+
if (yes) {
|
|
1959
|
+
if (!flagClient) {
|
|
1960
|
+
throw new Error(
|
|
1961
|
+
`Client is required when yes is true. Pass --client as one of these values: ${Object.values(Clients).join(", ")}`
|
|
1962
|
+
);
|
|
1963
|
+
}
|
|
1964
|
+
const parsedClient2 = z$1.enum(Clients).safeParse(flagClient);
|
|
1965
|
+
if (!parsedClient2.success) {
|
|
1966
|
+
throw new Error(
|
|
1967
|
+
`${flagClient} is not a valid client. Valid options are: ${Object.values(Clients).join(", ")}`
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
return parsedClient2.data;
|
|
1971
|
+
}
|
|
1972
|
+
const parsedClient = z$1.enum(Clients).safeParse(flagClient);
|
|
1951
1973
|
if (parsedClient.success) {
|
|
1952
1974
|
return parsedClient.data;
|
|
1953
1975
|
}
|
|
@@ -1965,7 +1987,7 @@ var init_get_client = __esm({
|
|
|
1965
1987
|
}),
|
|
1966
1988
|
maxItems: 7
|
|
1967
1989
|
});
|
|
1968
|
-
const parsedClientSelection = z.enum(Clients).safeParse(client);
|
|
1990
|
+
const parsedClientSelection = z$1.enum(Clients).safeParse(client);
|
|
1969
1991
|
if (parsedClientSelection.success) {
|
|
1970
1992
|
return parsedClientSelection.data;
|
|
1971
1993
|
}
|
|
@@ -1984,7 +2006,7 @@ var init_platforms = __esm({
|
|
|
1984
2006
|
return Platforms2;
|
|
1985
2007
|
})(Platforms || {});
|
|
1986
2008
|
getPlatformPath = () => {
|
|
1987
|
-
const platform = z.enum(Platforms).safeParse(process2.platform);
|
|
2009
|
+
const platform = z$1.enum(Platforms).safeParse(process2.platform);
|
|
1988
2010
|
if (!platform.success) {
|
|
1989
2011
|
throw new Error(`Invalid platform: ${process2.platform}`);
|
|
1990
2012
|
}
|
|
@@ -2296,11 +2318,13 @@ async function addServer(client, globalFlags) {
|
|
|
2296
2318
|
log.info("Config file not found, creating default empty config");
|
|
2297
2319
|
setNestedValue(config, clientFileTarget.configKey, {});
|
|
2298
2320
|
log.info("Config created successfully");
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2321
|
+
if (!globalFlags.yes) {
|
|
2322
|
+
await wait({
|
|
2323
|
+
startText: "Locating config file",
|
|
2324
|
+
stopText: `No config found, creating default empty config`,
|
|
2325
|
+
ms: 1e3
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2304
2328
|
} else {
|
|
2305
2329
|
log.info("Config file found, reading config file content");
|
|
2306
2330
|
const { config: rawConfig, fileContent } = parseClientConfig(clientFileTarget);
|
|
@@ -2316,11 +2340,13 @@ async function addServer(client, globalFlags) {
|
|
|
2316
2340
|
log.info(
|
|
2317
2341
|
`Config loaded successfully: ${JSON.stringify(rawConfig, null, 2)}`
|
|
2318
2342
|
);
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2343
|
+
if (!globalFlags.yes) {
|
|
2344
|
+
await wait({
|
|
2345
|
+
startText: `Locating config file`,
|
|
2346
|
+
stopText: `Config loaded from ${clientFileTarget.path}`,
|
|
2347
|
+
ms: 1e3
|
|
2348
|
+
});
|
|
2349
|
+
}
|
|
2324
2350
|
}
|
|
2325
2351
|
const servers = getNestedValue(config, clientFileTarget.configKey);
|
|
2326
2352
|
if (!servers || typeof servers !== "object") {
|
|
@@ -2363,10 +2389,14 @@ async function addServer(client, globalFlags) {
|
|
|
2363
2389
|
args
|
|
2364
2390
|
};
|
|
2365
2391
|
}
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
)
|
|
2392
|
+
if (!globalFlags.yes) {
|
|
2393
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
2394
|
+
}
|
|
2395
|
+
if (!globalFlags.yes) {
|
|
2396
|
+
log$1.step(
|
|
2397
|
+
`The following will be added to ${chalk.bold.underline(clientFileTarget.path)}`
|
|
2398
|
+
);
|
|
2399
|
+
}
|
|
2370
2400
|
const configStr = formatDiffByFormat(
|
|
2371
2401
|
{
|
|
2372
2402
|
[clientFileTarget.configKey]: {
|
|
@@ -2375,24 +2405,26 @@ async function addServer(client, globalFlags) {
|
|
|
2375
2405
|
},
|
|
2376
2406
|
clientFileTarget.format
|
|
2377
2407
|
);
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2408
|
+
if (!globalFlags.yes) {
|
|
2409
|
+
await stream.message(
|
|
2410
|
+
(async function* () {
|
|
2411
|
+
for (const num of Array.from(
|
|
2412
|
+
{ length: configStr.length },
|
|
2413
|
+
(_, i) => i
|
|
2414
|
+
)) {
|
|
2415
|
+
const char = configStr[num];
|
|
2416
|
+
yield char;
|
|
2417
|
+
if (!["\n", " ", "\u2500", "\u256E", "\u256D", "\u2570", "\u256F", "\u2502"].includes(char)) {
|
|
2418
|
+
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
2419
|
+
} else {
|
|
2420
|
+
await new Promise((resolve) => setTimeout(resolve, 2));
|
|
2421
|
+
}
|
|
2390
2422
|
}
|
|
2391
|
-
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
const isConfirmed = await confirm({
|
|
2423
|
+
})()
|
|
2424
|
+
);
|
|
2425
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
2426
|
+
}
|
|
2427
|
+
const isConfirmed = globalFlags.yes ? true : await confirm({
|
|
2396
2428
|
message: `Would you like to proceed?`,
|
|
2397
2429
|
active: "Install MCP",
|
|
2398
2430
|
inactive: "Cancel"
|
|
@@ -2425,7 +2457,7 @@ var init_add_server = __esm({
|
|
|
2425
2457
|
return {
|
|
2426
2458
|
serverName: "x402",
|
|
2427
2459
|
command: "node",
|
|
2428
|
-
args: [`${process.cwd()}/dist/index.js`, "--dev"]
|
|
2460
|
+
args: [`${process.cwd()}/dist/esm/index.js`, "--dev"]
|
|
2429
2461
|
};
|
|
2430
2462
|
}
|
|
2431
2463
|
return {
|
|
@@ -2467,62 +2499,44 @@ var init_add_server = __esm({
|
|
|
2467
2499
|
};
|
|
2468
2500
|
}
|
|
2469
2501
|
});
|
|
2470
|
-
var addFunds;
|
|
2471
|
-
var init_add_funds = __esm({
|
|
2472
|
-
"src/install/3-add-funds/index.ts"() {
|
|
2473
|
-
init_balance();
|
|
2474
|
-
init_deposit();
|
|
2475
|
-
init_wait();
|
|
2476
|
-
addFunds = async ({ flags, address, isNew }) => {
|
|
2477
|
-
if (isNew) {
|
|
2478
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
2479
|
-
log$1.info("To use paid API tools, you will need USDC in your wallet.");
|
|
2480
|
-
await promptDeposit(address, flags);
|
|
2481
|
-
} else {
|
|
2482
|
-
const balance = await getUSDCBalance({ address });
|
|
2483
|
-
await wait({
|
|
2484
|
-
startText: "Checking balance...",
|
|
2485
|
-
stopText: `Balance: ${chalk.bold(`${balance} USDC`)} `,
|
|
2486
|
-
ms: 1e3
|
|
2487
|
-
});
|
|
2488
|
-
if (balance < 1) {
|
|
2489
|
-
log$1.warning(
|
|
2490
|
-
chalk.bold(
|
|
2491
|
-
`Your balance is low (${balance} USDC). Consider topping up.`
|
|
2492
|
-
)
|
|
2493
|
-
);
|
|
2494
|
-
await promptDeposit(address, flags);
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
};
|
|
2498
|
-
}
|
|
2499
|
-
});
|
|
2500
2502
|
var redeemInviteCode2;
|
|
2501
2503
|
var init_redeem_invite3 = __esm({
|
|
2502
|
-
"src/install/
|
|
2504
|
+
"src/install/3-redeem-invite/index.ts"() {
|
|
2503
2505
|
init_wait();
|
|
2504
2506
|
init_redeem_invite();
|
|
2505
|
-
redeemInviteCode2 = async (props) => {
|
|
2507
|
+
redeemInviteCode2 = async (props, flags) => {
|
|
2506
2508
|
const s = spinner();
|
|
2507
|
-
|
|
2509
|
+
if (!flags.yes) {
|
|
2510
|
+
s.start("Redeeming invite code...");
|
|
2511
|
+
}
|
|
2508
2512
|
const result = await redeemInviteCode(props);
|
|
2509
2513
|
return result.match(
|
|
2510
2514
|
async ({ data }) => {
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2515
|
+
if (!flags.yes) {
|
|
2516
|
+
s.stop("Invite code redeemed successfully!");
|
|
2517
|
+
await wait({
|
|
2518
|
+
startText: "Processing...",
|
|
2519
|
+
stopText: chalk.green(
|
|
2520
|
+
`${chalk.bold(data.amount)} USDC has been sent to your wallet!`
|
|
2521
|
+
),
|
|
2522
|
+
ms: 1e3
|
|
2523
|
+
});
|
|
2524
|
+
} else {
|
|
2525
|
+
log$1.success(
|
|
2526
|
+
chalk.green(
|
|
2527
|
+
`${chalk.bold(data.amount)} USDC has been sent to your wallet!`
|
|
2528
|
+
)
|
|
2529
|
+
);
|
|
2530
|
+
}
|
|
2519
2531
|
log$1.info(
|
|
2520
2532
|
chalk.dim(`Transaction: https://basescan.org/tx/${data.txHash}`)
|
|
2521
2533
|
);
|
|
2522
2534
|
return true;
|
|
2523
2535
|
},
|
|
2524
2536
|
(error) => {
|
|
2525
|
-
|
|
2537
|
+
if (!flags.yes) {
|
|
2538
|
+
s.stop("Invite code redemption failed");
|
|
2539
|
+
}
|
|
2526
2540
|
log$1.warning(
|
|
2527
2541
|
chalk.yellow(`Failed to redeem invite code: ${error?.message}`)
|
|
2528
2542
|
);
|
|
@@ -2532,6 +2546,40 @@ var init_redeem_invite3 = __esm({
|
|
|
2532
2546
|
};
|
|
2533
2547
|
}
|
|
2534
2548
|
});
|
|
2549
|
+
var addFunds;
|
|
2550
|
+
var init_add_funds = __esm({
|
|
2551
|
+
"src/install/4-add-funds/index.ts"() {
|
|
2552
|
+
init_balance();
|
|
2553
|
+
init_deposit();
|
|
2554
|
+
init_wait();
|
|
2555
|
+
addFunds = async ({ flags, address, isNew }) => {
|
|
2556
|
+
if (isNew) {
|
|
2557
|
+
if (!flags.yes) {
|
|
2558
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
2559
|
+
}
|
|
2560
|
+
log$1.info("To use paid API tools, you will need USDC in your wallet.");
|
|
2561
|
+
await promptDeposit(address, flags);
|
|
2562
|
+
} else {
|
|
2563
|
+
const { balanceFormatted } = await getUSDCBalance(address, flags);
|
|
2564
|
+
if (!flags.yes) {
|
|
2565
|
+
await wait({
|
|
2566
|
+
startText: "Checking balance...",
|
|
2567
|
+
stopText: `Balance: ${chalk.bold(`${balanceFormatted} USDC`)} `,
|
|
2568
|
+
ms: 1e3
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
if (balanceFormatted < 1) {
|
|
2572
|
+
log$1.warning(
|
|
2573
|
+
chalk.bold(
|
|
2574
|
+
`Your balance is low (${balanceFormatted} USDC). Consider topping up.`
|
|
2575
|
+
)
|
|
2576
|
+
);
|
|
2577
|
+
await promptDeposit(address, flags);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
};
|
|
2581
|
+
}
|
|
2582
|
+
});
|
|
2535
2583
|
|
|
2536
2584
|
// src/install/index.ts
|
|
2537
2585
|
var install_exports = {};
|
|
@@ -2544,8 +2592,8 @@ var init_install = __esm({
|
|
|
2544
2592
|
init_wallet2();
|
|
2545
2593
|
init_get_client();
|
|
2546
2594
|
init_add_server();
|
|
2547
|
-
init_add_funds();
|
|
2548
2595
|
init_redeem_invite3();
|
|
2596
|
+
init_add_funds();
|
|
2549
2597
|
installMcpServer = async (flags) => {
|
|
2550
2598
|
const {
|
|
2551
2599
|
account: { address },
|
|
@@ -2554,11 +2602,14 @@ var init_install = __esm({
|
|
|
2554
2602
|
intro(chalk.green.bold(`Install x402scan MCP`));
|
|
2555
2603
|
const client = await getClient(flags);
|
|
2556
2604
|
await addServer(client, flags);
|
|
2557
|
-
const inviteRedeemed = flags.invite ? await redeemInviteCode2(
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2605
|
+
const inviteRedeemed = flags.invite ? await redeemInviteCode2(
|
|
2606
|
+
{
|
|
2607
|
+
code: flags.invite,
|
|
2608
|
+
dev: flags.dev,
|
|
2609
|
+
address
|
|
2610
|
+
},
|
|
2611
|
+
flags
|
|
2612
|
+
) : false;
|
|
2562
2613
|
if (!inviteRedeemed) {
|
|
2563
2614
|
await addFunds({ flags, address, isNew });
|
|
2564
2615
|
}
|
|
@@ -2587,6 +2638,11 @@ var init_fund = __esm({
|
|
|
2587
2638
|
};
|
|
2588
2639
|
}
|
|
2589
2640
|
});
|
|
2641
|
+
|
|
2642
|
+
// src/index.ts
|
|
2643
|
+
init_clients();
|
|
2644
|
+
var isClaudeCode = Boolean(process.env.CLAUDECODE);
|
|
2645
|
+
var defaultYes = isClaudeCode || Boolean(process.env.CI);
|
|
2590
2646
|
void yargs(hideBin(process.argv)).scriptName("@x402scan/mcp").option("dev", {
|
|
2591
2647
|
type: "boolean",
|
|
2592
2648
|
description: "Enable dev mode",
|
|
@@ -2595,6 +2651,11 @@ void yargs(hideBin(process.argv)).scriptName("@x402scan/mcp").option("dev", {
|
|
|
2595
2651
|
type: "string",
|
|
2596
2652
|
description: "Invite code to redeem for starter money",
|
|
2597
2653
|
required: false
|
|
2654
|
+
}).option("yes", {
|
|
2655
|
+
alias: "y",
|
|
2656
|
+
type: "boolean",
|
|
2657
|
+
description: "Yes to all prompts",
|
|
2658
|
+
default: defaultYes ? true : void 0
|
|
2598
2659
|
}).command(
|
|
2599
2660
|
"$0",
|
|
2600
2661
|
"Start the MCP server",
|
|
@@ -2609,7 +2670,8 @@ void yargs(hideBin(process.argv)).scriptName("@x402scan/mcp").option("dev", {
|
|
|
2609
2670
|
(yargs2) => yargs2.option("client", {
|
|
2610
2671
|
type: "string",
|
|
2611
2672
|
description: "The client name",
|
|
2612
|
-
required: false
|
|
2673
|
+
required: false,
|
|
2674
|
+
default: isClaudeCode ? "claude-code" /* ClaudeCode */ : void 0
|
|
2613
2675
|
}),
|
|
2614
2676
|
async (args) => {
|
|
2615
2677
|
const { installMcpServer: installMcpServer2 } = await Promise.resolve().then(() => (init_install(), install_exports));
|