cards402 0.2.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/LICENSE +21 -0
- package/README.md +133 -0
- package/dist/__tests__/client.test.d.ts +2 -0
- package/dist/__tests__/client.test.d.ts.map +1 -0
- package/dist/__tests__/client.test.js +251 -0
- package/dist/__tests__/client.test.js.map +1 -0
- package/dist/__tests__/errors.test.d.ts +2 -0
- package/dist/__tests__/errors.test.d.ts.map +1 -0
- package/dist/__tests__/errors.test.js +177 -0
- package/dist/__tests__/errors.test.js.map +1 -0
- package/dist/__tests__/integration.test.d.ts +13 -0
- package/dist/__tests__/integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration.test.js +223 -0
- package/dist/__tests__/integration.test.js.map +1 -0
- package/dist/client.d.ts +116 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +261 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +66 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +148 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +521 -0
- package/dist/mcp.js.map +1 -0
- package/dist/ows.d.ts +121 -0
- package/dist/ows.d.ts.map +1 -0
- package/dist/ows.js +300 -0
- package/dist/ows.js.map +1 -0
- package/dist/soroban.d.ts +48 -0
- package/dist/soroban.d.ts.map +1 -0
- package/dist/soroban.js +132 -0
- package/dist/soroban.js.map +1 -0
- package/dist/stellar.d.ts +53 -0
- package/dist/stellar.d.ts.map +1 -0
- package/dist/stellar.js +156 -0
- package/dist/stellar.js.map +1 -0
- package/package.json +73 -0
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
5
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
7
|
+
const ows_1 = require("./ows");
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
// Audit A-38: version string imported from package.json instead of hardcoded.
|
|
10
|
+
// The `with { type: 'json' }` import lets tsc emit a real assertion and
|
|
11
|
+
// bun/node24 load it as JSON.
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
13
|
+
const PKG_VERSION = require('../package.json').version;
|
|
14
|
+
const API_KEY = process.env.CARDS402_API_KEY ?? '';
|
|
15
|
+
const BASE_URL = process.env.CARDS402_BASE_URL ?? 'https://api.cards402.com/v1';
|
|
16
|
+
const OWS_WALLET_NAME = process.env.OWS_WALLET_NAME ?? '';
|
|
17
|
+
const OWS_WALLET_PASSPHRASE = process.env.OWS_WALLET_PASSPHRASE ?? undefined;
|
|
18
|
+
const OWS_VAULT_PATH = process.env.OWS_VAULT_PATH ?? undefined;
|
|
19
|
+
if (!API_KEY) {
|
|
20
|
+
process.stderr.write('Warning: CARDS402_API_KEY is not set. Get one at https://cards402.com\n');
|
|
21
|
+
}
|
|
22
|
+
if (!OWS_WALLET_NAME) {
|
|
23
|
+
process.stderr.write('Warning: OWS_WALLET_NAME is not set. Run setup_wallet for instructions.\n');
|
|
24
|
+
}
|
|
25
|
+
const server = new index_js_1.Server({ name: 'cards402', version: PKG_VERSION }, { capabilities: { tools: {} } });
|
|
26
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
27
|
+
tools: [
|
|
28
|
+
{
|
|
29
|
+
name: 'purchase_vcc',
|
|
30
|
+
description: 'Purchase a prepaid Visa virtual card. Pay with USDC or XLM on Stellar. Returns card number, CVV, and expiry. Requires OWS_WALLET_NAME — run setup_wallet to configure.',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
amount_usdc: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: "Card value in USD, e.g. '10.00'",
|
|
37
|
+
},
|
|
38
|
+
payment_asset: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: ['usdc', 'xlm'],
|
|
41
|
+
description: "Payment asset: 'usdc' (default) or 'xlm'",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ['amount_usdc'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'setup_wallet',
|
|
49
|
+
description: 'Set up or inspect the OWS encrypted wallet used to pay cards402. Creates the wallet on first run. Shows public key and balances.',
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {},
|
|
53
|
+
required: [],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'check_order',
|
|
58
|
+
description: 'Check the status of a cards402 order',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
order_id: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'The cards402 order ID',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
required: ['order_id'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'check_budget',
|
|
72
|
+
description: "Check this agent's spend summary — how much has been spent, the configured limit, and how much budget remains. Use this to report spending to your owner or to decide whether you can afford a card.",
|
|
73
|
+
inputSchema: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {},
|
|
76
|
+
required: [],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
}));
|
|
81
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
82
|
+
const { name, arguments: args } = request.params;
|
|
83
|
+
if (name === 'setup_wallet') {
|
|
84
|
+
if (!OWS_WALLET_NAME) {
|
|
85
|
+
return {
|
|
86
|
+
content: [
|
|
87
|
+
{
|
|
88
|
+
type: 'text',
|
|
89
|
+
text: [
|
|
90
|
+
'OWS_WALLET_NAME is not set.',
|
|
91
|
+
'',
|
|
92
|
+
'To configure your wallet:',
|
|
93
|
+
' 1. Set OWS_WALLET_NAME=<name> in your MCP server environment',
|
|
94
|
+
' 2. Optionally set OWS_WALLET_PASSPHRASE=<passphrase> for extra encryption',
|
|
95
|
+
' 3. Optionally set OWS_VAULT_PATH=<path> to store the vault file at a custom location',
|
|
96
|
+
' 4. Run setup_wallet to create the wallet and get your public key',
|
|
97
|
+
'',
|
|
98
|
+
'Also set CARDS402_API_KEY=<your key> (get one at cards402.com)',
|
|
99
|
+
].join('\n'),
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
let publicKey;
|
|
106
|
+
let created = false;
|
|
107
|
+
try {
|
|
108
|
+
publicKey = (0, ows_1.getOWSPublicKey)(OWS_WALLET_NAME, OWS_VAULT_PATH);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
const result = (0, ows_1.createOWSWallet)(OWS_WALLET_NAME, OWS_WALLET_PASSPHRASE, OWS_VAULT_PATH);
|
|
112
|
+
publicKey = result.publicKey;
|
|
113
|
+
created = true;
|
|
114
|
+
}
|
|
115
|
+
const lines = [
|
|
116
|
+
created ? 'OWS Wallet Created' : 'OWS Wallet',
|
|
117
|
+
'',
|
|
118
|
+
`Wallet name: ${OWS_WALLET_NAME}`,
|
|
119
|
+
`Public key: ${publicKey}`,
|
|
120
|
+
];
|
|
121
|
+
let accountStatus = 'unknown';
|
|
122
|
+
try {
|
|
123
|
+
const bal = await (0, ows_1.getOWSBalance)(OWS_WALLET_NAME, OWS_VAULT_PATH);
|
|
124
|
+
const xlmNum = parseFloat(bal.xlm);
|
|
125
|
+
const usdcNum = parseFloat(bal.usdc);
|
|
126
|
+
if (xlmNum >= 2 && usdcNum === 0) {
|
|
127
|
+
// Wallet is funded but no USDC trustline yet — add it automatically
|
|
128
|
+
lines.push('');
|
|
129
|
+
lines.push('USDC trustline: adding…');
|
|
130
|
+
try {
|
|
131
|
+
const txHash = await (0, ows_1.addUsdcTrustlineOWS)({
|
|
132
|
+
walletName: OWS_WALLET_NAME,
|
|
133
|
+
passphrase: OWS_WALLET_PASSPHRASE,
|
|
134
|
+
vaultPath: OWS_VAULT_PATH,
|
|
135
|
+
});
|
|
136
|
+
lines.push(`USDC trustline: added (txid: ${txHash})`);
|
|
137
|
+
accountStatus = 'ready_no_usdc';
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
141
|
+
lines.push(`USDC trustline: could not add (${errMsg.slice(0, 120)})`);
|
|
142
|
+
lines.push(' This may mean the trustline already exists, or XLM balance is too low for fees.');
|
|
143
|
+
accountStatus = usdcNum > 0 ? 'ready' : 'funded_no_trustline';
|
|
144
|
+
}
|
|
145
|
+
// Re-fetch balance after trustline op
|
|
146
|
+
try {
|
|
147
|
+
const bal2 = await (0, ows_1.getOWSBalance)(OWS_WALLET_NAME, OWS_VAULT_PATH);
|
|
148
|
+
lines.push('');
|
|
149
|
+
lines.push(`XLM balance: ${bal2.xlm}`);
|
|
150
|
+
lines.push(`USDC balance: ${bal2.usdc}`);
|
|
151
|
+
lines.push('');
|
|
152
|
+
lines.push('Status: Wallet ready. Fund with USDC to purchase cards with USDC,');
|
|
153
|
+
lines.push(' or top up XLM to purchase with native XLM (no USDC needed).');
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
lines.push('');
|
|
157
|
+
lines.push(`XLM balance: ${bal.xlm}`);
|
|
158
|
+
lines.push(`USDC balance: ${bal.usdc}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (xlmNum >= 2 && usdcNum > 0) {
|
|
162
|
+
accountStatus = 'ready';
|
|
163
|
+
lines.push('');
|
|
164
|
+
lines.push(`XLM balance: ${bal.xlm}`);
|
|
165
|
+
lines.push(`USDC balance: ${bal.usdc}`);
|
|
166
|
+
lines.push('');
|
|
167
|
+
lines.push('Status: Ready to purchase cards.');
|
|
168
|
+
}
|
|
169
|
+
else if (xlmNum > 0 && xlmNum < 2) {
|
|
170
|
+
accountStatus = 'low_xlm';
|
|
171
|
+
lines.push('');
|
|
172
|
+
lines.push(`XLM balance: ${bal.xlm}`);
|
|
173
|
+
lines.push(`USDC balance: ${bal.usdc}`);
|
|
174
|
+
lines.push('');
|
|
175
|
+
lines.push('Status: Account active but XLM balance is low.');
|
|
176
|
+
lines.push(' Send at least 2 XLM total to cover reserves and fees.');
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
accountStatus = 'unfunded';
|
|
180
|
+
lines.push('');
|
|
181
|
+
lines.push(`XLM balance: ${bal.xlm}`);
|
|
182
|
+
lines.push(`USDC balance: ${bal.usdc}`);
|
|
183
|
+
lines.push('');
|
|
184
|
+
lines.push('Status: Account not yet funded. Send at least 2 XLM to activate.');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
189
|
+
if (errMsg.includes('404') ||
|
|
190
|
+
errMsg.toLowerCase().includes('not found') ||
|
|
191
|
+
errMsg.includes('request failed')) {
|
|
192
|
+
// Account does not exist on-chain yet (not activated)
|
|
193
|
+
accountStatus = 'not_activated';
|
|
194
|
+
lines.push('');
|
|
195
|
+
lines.push('Status: Account not activated (no on-chain balance).');
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// Network error or Horizon outage — don't guess account state
|
|
199
|
+
lines.push('');
|
|
200
|
+
lines.push(`Status: Could not fetch balance (${errMsg.slice(0, 120)})`);
|
|
201
|
+
lines.push('Check your network connection and try again.');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
lines.push('');
|
|
205
|
+
lines.push('Environment variables:');
|
|
206
|
+
lines.push(` OWS_WALLET_NAME — wallet identifier (set: "${OWS_WALLET_NAME}")`);
|
|
207
|
+
lines.push(` OWS_WALLET_PASSPHRASE — encryption passphrase (${OWS_WALLET_PASSPHRASE ? 'set' : 'not set'})`);
|
|
208
|
+
lines.push(` OWS_VAULT_PATH — vault file path (${OWS_VAULT_PATH ?? 'default: ~/.ows/vault'})`);
|
|
209
|
+
lines.push(' CARDS402_API_KEY — your cards402 API key');
|
|
210
|
+
if (accountStatus === 'not_activated' || accountStatus === 'unfunded') {
|
|
211
|
+
lines.push('');
|
|
212
|
+
lines.push('──────────────────────────────────────────────────────────────────');
|
|
213
|
+
lines.push('ACTION REQUIRED — copy this block and send it to your human operator');
|
|
214
|
+
lines.push('──────────────────────────────────────────────────────────────────');
|
|
215
|
+
lines.push('');
|
|
216
|
+
lines.push('Your AI agent has a Stellar wallet that needs funding before it can');
|
|
217
|
+
lines.push('purchase cards. Please send XLM to the address below.');
|
|
218
|
+
lines.push('');
|
|
219
|
+
lines.push(` Wallet address: ${publicKey}`);
|
|
220
|
+
lines.push(' (copy the G... address exactly — it is case-sensitive)');
|
|
221
|
+
lines.push('');
|
|
222
|
+
lines.push(' How much to send:');
|
|
223
|
+
lines.push(' Recommended (for a $10 card, XLM payment): ~72 XLM');
|
|
224
|
+
lines.push(' ↳ 2 XLM — activates the account (required minimum)');
|
|
225
|
+
lines.push(' ↳ ~70 XLM — covers a $10 card at current rates (~$0.14/XLM)');
|
|
226
|
+
lines.push(' Recommended (for a $10 card, USDC payment): 2 XLM + $10 USDC');
|
|
227
|
+
lines.push(' ↳ Send 2 XLM first to activate, then send USDC separately');
|
|
228
|
+
lines.push('');
|
|
229
|
+
lines.push(' Where to get XLM:');
|
|
230
|
+
lines.push(' Coinbase: coinbase.com → Buy XLM → Send → paste address above');
|
|
231
|
+
lines.push(' Lobstr: lobstr.co → Buy XLM → Send → paste address above');
|
|
232
|
+
lines.push(' Kraken: kraken.com → Buy XLM → Withdraw (Stellar) → paste address');
|
|
233
|
+
lines.push('');
|
|
234
|
+
lines.push(' After sending: tell your agent to run setup_wallet again to confirm.');
|
|
235
|
+
lines.push('──────────────────────────────────────────────────────────────────');
|
|
236
|
+
}
|
|
237
|
+
else if (accountStatus === 'low_xlm') {
|
|
238
|
+
lines.push('');
|
|
239
|
+
lines.push('──────────────────────────────────────────────────────────────────');
|
|
240
|
+
lines.push('ACTION REQUIRED — wallet needs more XLM');
|
|
241
|
+
lines.push('──────────────────────────────────────────────────────────────────');
|
|
242
|
+
lines.push('');
|
|
243
|
+
lines.push(` Wallet address: ${publicKey}`);
|
|
244
|
+
lines.push('');
|
|
245
|
+
lines.push(' Send at least 2 XLM total to cover Stellar reserves and fees.');
|
|
246
|
+
lines.push(' For a $10 card with XLM payment, send ~72 XLM total.');
|
|
247
|
+
lines.push('──────────────────────────────────────────────────────────────────');
|
|
248
|
+
}
|
|
249
|
+
else if (accountStatus === 'ready_no_usdc') {
|
|
250
|
+
lines.push('');
|
|
251
|
+
lines.push('Next steps:');
|
|
252
|
+
lines.push(` Wallet address: ${publicKey}`);
|
|
253
|
+
lines.push('');
|
|
254
|
+
lines.push(' To pay with XLM (recommended):');
|
|
255
|
+
lines.push(' Send more XLM to the address above, then call:');
|
|
256
|
+
lines.push(' purchase_vcc { amount_usdc: "10.00", payment_asset: "xlm" }');
|
|
257
|
+
lines.push('');
|
|
258
|
+
lines.push(' To pay with USDC:');
|
|
259
|
+
lines.push(' Send USDC to the address above (trustline is already set up), then call:');
|
|
260
|
+
lines.push(' purchase_vcc { amount_usdc: "10.00", payment_asset: "usdc" }');
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
catch (err) {
|
|
267
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
268
|
+
return {
|
|
269
|
+
content: [{ type: 'text', text: `Error in setup_wallet: ${message}` }],
|
|
270
|
+
isError: true,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (!API_KEY) {
|
|
275
|
+
return {
|
|
276
|
+
content: [
|
|
277
|
+
{
|
|
278
|
+
type: 'text',
|
|
279
|
+
text: 'Error: CARDS402_API_KEY environment variable is not set. Get your API key at https://cards402.com',
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
isError: true,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
if (name === 'purchase_vcc') {
|
|
286
|
+
if (!OWS_WALLET_NAME) {
|
|
287
|
+
return {
|
|
288
|
+
content: [
|
|
289
|
+
{
|
|
290
|
+
type: 'text',
|
|
291
|
+
text: 'Error: OWS_WALLET_NAME is not set. Run setup_wallet for configuration instructions.',
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
isError: true,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
// Validate and extract args explicitly — never trust MCP client types
|
|
298
|
+
const rawArgs = args;
|
|
299
|
+
const amount_usdc = String(rawArgs.amount_usdc ?? '').trim();
|
|
300
|
+
const raw_asset = String(rawArgs.payment_asset ?? 'usdc').toLowerCase();
|
|
301
|
+
if (!/^\d+(\.\d{1,8})?$/.test(amount_usdc) || parseFloat(amount_usdc) <= 0) {
|
|
302
|
+
return {
|
|
303
|
+
content: [
|
|
304
|
+
{ type: 'text', text: 'Error: amount_usdc must be a positive number, e.g. "10.00"' },
|
|
305
|
+
],
|
|
306
|
+
isError: true,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
if (raw_asset !== 'usdc' && raw_asset !== 'xlm') {
|
|
310
|
+
return {
|
|
311
|
+
content: [{ type: 'text', text: 'Error: payment_asset must be "usdc" or "xlm"' }],
|
|
312
|
+
isError: true,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const payment_asset = raw_asset;
|
|
316
|
+
// Pre-purchase balance check — give a specific, actionable error before
|
|
317
|
+
// attempting the payment so the agent isn't left guessing.
|
|
318
|
+
try {
|
|
319
|
+
const balance = await (0, ows_1.getOWSBalance)(OWS_WALLET_NAME, OWS_VAULT_PATH);
|
|
320
|
+
const publicKey = (0, ows_1.getOWSPublicKey)(OWS_WALLET_NAME, OWS_VAULT_PATH);
|
|
321
|
+
const xlmNum = parseFloat(balance.xlm);
|
|
322
|
+
const usdcNum = parseFloat(balance.usdc);
|
|
323
|
+
const amountNum = parseFloat(amount_usdc);
|
|
324
|
+
if (payment_asset === 'usdc') {
|
|
325
|
+
if (usdcNum < amountNum) {
|
|
326
|
+
const shortfall = (amountNum - usdcNum).toFixed(2);
|
|
327
|
+
return {
|
|
328
|
+
content: [
|
|
329
|
+
{
|
|
330
|
+
type: 'text',
|
|
331
|
+
text: [
|
|
332
|
+
'Insufficient USDC balance.',
|
|
333
|
+
'',
|
|
334
|
+
` You have: ${balance.usdc} USDC`,
|
|
335
|
+
` You need: ${amount_usdc} USDC`,
|
|
336
|
+
` Shortfall: ${shortfall} USDC`,
|
|
337
|
+
'',
|
|
338
|
+
`Send USDC to your wallet address:`,
|
|
339
|
+
` ${publicKey}`,
|
|
340
|
+
'',
|
|
341
|
+
'After funding, run purchase_vcc again.',
|
|
342
|
+
'Or switch to XLM payment: purchase_vcc { payment_asset: "xlm" }',
|
|
343
|
+
].join('\n'),
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
isError: true,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
// XLM: we do not know the exact rate yet (quote comes from the order),
|
|
352
|
+
// but we can gate on a hard floor of 3 XLM (2 reserve + 1 margin) to
|
|
353
|
+
// catch obviously-unfunded wallets before hitting the API.
|
|
354
|
+
if (xlmNum < 3) {
|
|
355
|
+
return {
|
|
356
|
+
content: [
|
|
357
|
+
{
|
|
358
|
+
type: 'text',
|
|
359
|
+
text: [
|
|
360
|
+
'XLM balance is too low to purchase a card.',
|
|
361
|
+
'',
|
|
362
|
+
` You have: ${balance.xlm} XLM`,
|
|
363
|
+
` Minimum: 3 XLM (for Stellar reserves and fees alone)`,
|
|
364
|
+
` Typical: ~${Math.ceil(amountNum / 0.14 + 2)} XLM for a $${amount_usdc} card at ~$0.14/XLM`,
|
|
365
|
+
'',
|
|
366
|
+
'The exact XLM amount is quoted when the order is created.',
|
|
367
|
+
'',
|
|
368
|
+
`Send XLM to your wallet address:`,
|
|
369
|
+
` ${publicKey}`,
|
|
370
|
+
'',
|
|
371
|
+
'Where to get XLM:',
|
|
372
|
+
' Coinbase: coinbase.com → Buy XLM → Send',
|
|
373
|
+
' Lobstr: lobstr.co → Buy XLM → Send',
|
|
374
|
+
'',
|
|
375
|
+
'After funding, run purchase_vcc again.',
|
|
376
|
+
].join('\n'),
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
isError: true,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
catch {
|
|
385
|
+
// Could not fetch balance (wallet not activated, network error, etc.) —
|
|
386
|
+
// let purchaseCardOWS proceed and surface the error with full context.
|
|
387
|
+
}
|
|
388
|
+
try {
|
|
389
|
+
const card = await (0, ows_1.purchaseCardOWS)({
|
|
390
|
+
apiKey: API_KEY,
|
|
391
|
+
walletName: OWS_WALLET_NAME,
|
|
392
|
+
amountUsdc: amount_usdc,
|
|
393
|
+
paymentAsset: payment_asset,
|
|
394
|
+
passphrase: OWS_WALLET_PASSPHRASE,
|
|
395
|
+
vaultPath: OWS_VAULT_PATH,
|
|
396
|
+
baseUrl: BASE_URL,
|
|
397
|
+
});
|
|
398
|
+
return {
|
|
399
|
+
content: [
|
|
400
|
+
{
|
|
401
|
+
type: 'text',
|
|
402
|
+
text: [
|
|
403
|
+
'Virtual Visa Card Ready',
|
|
404
|
+
'',
|
|
405
|
+
`Number: ${card.number}`,
|
|
406
|
+
`CVV: ${card.cvv}`,
|
|
407
|
+
`Expiry: ${card.expiry}`,
|
|
408
|
+
`Brand: ${card.brand ?? 'Visa'}`,
|
|
409
|
+
'',
|
|
410
|
+
`Order ID: ${card.order_id}`,
|
|
411
|
+
'',
|
|
412
|
+
'This is a one-time use virtual card. Keep these details safe.',
|
|
413
|
+
].join('\n'),
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
catch (err) {
|
|
419
|
+
// Only expose typed API errors — other errors may contain internal details
|
|
420
|
+
const message = err instanceof Error && err.constructor.name.endsWith('Error') && 'status' in err
|
|
421
|
+
? err.message
|
|
422
|
+
: err instanceof Error
|
|
423
|
+
? err.message.slice(0, 200)
|
|
424
|
+
: 'Purchase failed';
|
|
425
|
+
return {
|
|
426
|
+
content: [{ type: 'text', text: `Error purchasing card: ${message}` }],
|
|
427
|
+
isError: true,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (name === 'check_order') {
|
|
432
|
+
// Validate order_id before using it in a URL path
|
|
433
|
+
const rawOrderId = String(args.order_id ?? '').trim();
|
|
434
|
+
if (!/^[a-zA-Z0-9_-]{1,64}$/.test(rawOrderId)) {
|
|
435
|
+
return {
|
|
436
|
+
content: [{ type: 'text', text: 'Error: invalid order ID format' }],
|
|
437
|
+
isError: true,
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
const order_id = rawOrderId;
|
|
441
|
+
try {
|
|
442
|
+
const client = new client_1.Cards402Client({ apiKey: API_KEY, baseUrl: BASE_URL });
|
|
443
|
+
const order = await client.getOrder(order_id);
|
|
444
|
+
const lines = [
|
|
445
|
+
`Order: ${order.order_id}`,
|
|
446
|
+
`Status: ${order.status} (phase: ${order.phase})`,
|
|
447
|
+
`Amount: $${order.amount_usdc} USDC`,
|
|
448
|
+
`Asset: ${order.payment_asset}`,
|
|
449
|
+
`Created: ${order.created_at}`,
|
|
450
|
+
`Updated: ${order.updated_at}`,
|
|
451
|
+
];
|
|
452
|
+
if (order.phase === 'ready' && order.card) {
|
|
453
|
+
lines.push('');
|
|
454
|
+
lines.push('Card details:');
|
|
455
|
+
lines.push(` Number: ${order.card.number}`);
|
|
456
|
+
lines.push(` CVV: ${order.card.cvv}`);
|
|
457
|
+
lines.push(` Expiry: ${order.card.expiry}`);
|
|
458
|
+
lines.push(` Brand: ${order.card.brand ?? 'Visa'}`);
|
|
459
|
+
}
|
|
460
|
+
if (order.error) {
|
|
461
|
+
lines.push('');
|
|
462
|
+
lines.push(`Error: ${order.error}`);
|
|
463
|
+
}
|
|
464
|
+
if (order.refund) {
|
|
465
|
+
lines.push(`Refund txid: ${order.refund.stellar_txid}`);
|
|
466
|
+
}
|
|
467
|
+
if (order.note) {
|
|
468
|
+
lines.push(`Note: ${order.note}`);
|
|
469
|
+
}
|
|
470
|
+
return {
|
|
471
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
catch (err) {
|
|
475
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
476
|
+
return {
|
|
477
|
+
content: [{ type: 'text', text: `Error checking order: ${message}` }],
|
|
478
|
+
isError: true,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (name === 'check_budget') {
|
|
483
|
+
try {
|
|
484
|
+
const client = new client_1.Cards402Client({ apiKey: API_KEY, baseUrl: BASE_URL });
|
|
485
|
+
const usage = await client.getUsage();
|
|
486
|
+
const { budget, orders, label } = usage;
|
|
487
|
+
const lines = [
|
|
488
|
+
`Budget summary${label ? ` for "${label}"` : ''}`,
|
|
489
|
+
'',
|
|
490
|
+
`Spent: $${budget.spent_usdc} USDC`,
|
|
491
|
+
budget.limit_usdc ? `Limit: $${budget.limit_usdc} USDC` : 'Limit: unlimited',
|
|
492
|
+
budget.remaining_usdc !== null
|
|
493
|
+
? `Remaining: $${budget.remaining_usdc} USDC`
|
|
494
|
+
: 'Remaining: unlimited',
|
|
495
|
+
'',
|
|
496
|
+
`Orders — total: ${orders.total}, delivered: ${orders.delivered}, failed: ${orders.failed}, refunded: ${orders.refunded}, in progress: ${orders.in_progress}`,
|
|
497
|
+
];
|
|
498
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
499
|
+
}
|
|
500
|
+
catch (err) {
|
|
501
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
502
|
+
return {
|
|
503
|
+
content: [{ type: 'text', text: `Error checking budget: ${message}` }],
|
|
504
|
+
isError: true,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return {
|
|
509
|
+
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
|
|
510
|
+
isError: true,
|
|
511
|
+
};
|
|
512
|
+
});
|
|
513
|
+
async function main() {
|
|
514
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
515
|
+
await server.connect(transport);
|
|
516
|
+
}
|
|
517
|
+
main().catch((err) => {
|
|
518
|
+
process.stderr.write(`Fatal error: ${err}\n`);
|
|
519
|
+
process.exit(1);
|
|
520
|
+
});
|
|
521
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":";;;AACA,wEAAmE;AACnE,wEAAiF;AACjF,iEAAmG;AACnG,+BAMe;AACf,qCAA0C;AAC1C,8EAA8E;AAC9E,wEAAwE;AACxE,8BAA8B;AAC9B,iEAAiE;AACjE,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAiB,CAAC;AAEjE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;AACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,6BAA6B,CAAC;AAChF,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC;AAC1D,MAAM,qBAAq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