@moneygraph/mcp-server 1.0.2 → 1.1.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/config.d.ts.map +1 -1
- package/dist/config.js +4 -5
- package/dist/config.js.map +1 -1
- package/dist/http.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/resources/status.js +2 -2
- package/dist/tools/currencies.d.ts.map +1 -1
- package/dist/tools/currencies.js +56 -3
- package/dist/tools/currencies.js.map +1 -1
- package/dist/tools/customers.d.ts.map +1 -1
- package/dist/tools/customers.js +9 -8
- package/dist/tools/customers.js.map +1 -1
- package/package.json +11 -3
- package/scripts/patch-sdk.mjs +32 -0
- package/.claude/settings.local.json +0 -13
- package/src/config.ts +0 -73
- package/src/http.ts +0 -118
- package/src/index.ts +0 -184
- package/src/prompts/check-rates.ts +0 -36
- package/src/prompts/crypto-deposit.ts +0 -43
- package/src/prompts/issue-card.ts +0 -40
- package/src/prompts/onboard-customer.ts +0 -39
- package/src/prompts/payout-status.ts +0 -36
- package/src/prompts/send-money.ts +0 -41
- package/src/resources/corridors.ts +0 -190
- package/src/resources/status.ts +0 -44
- package/src/resources/wallets.ts +0 -48
- package/src/tools/cards.ts +0 -302
- package/src/tools/crypto.ts +0 -382
- package/src/tools/currencies.ts +0 -122
- package/src/tools/customers.ts +0 -458
- package/src/tools/directors.ts +0 -209
- package/src/tools/fx.ts +0 -253
- package/src/tools/ledger.ts +0 -133
- package/src/tools/payments.ts +0 -118
- package/src/tools/payouts.ts +0 -452
- package/src/tools/recipients.ts +0 -204
- package/src/tools/recurring.ts +0 -130
- package/src/tools/reference.ts +0 -122
- package/src/tools/transactions.ts +0 -140
- package/src/tools/wallets.ts +0 -183
- package/test/smoke.test.mjs +0 -196
- package/tsconfig.json +0 -21
package/src/tools/crypto.ts
DELETED
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Crypto Tools — deposit addresses, deposit tracking, settings, conversion
|
|
3
|
-
*
|
|
4
|
-
* Maps to SDK: mg.crypto.addresses, mg.crypto.deposits, mg.crypto.settings,
|
|
5
|
-
* mg.crypto.convert, mg.payouts.crypto
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
import type { ServerConfig } from '../config.js';
|
|
11
|
-
import { safeCall, nextSteps } from '../config.js';
|
|
12
|
-
|
|
13
|
-
export function registerCryptoTools(server: McpServer, config: ServerConfig) {
|
|
14
|
-
const { client } = config;
|
|
15
|
-
|
|
16
|
-
// ── create_crypto_address ───────────────────────────────────────
|
|
17
|
-
server.tool(
|
|
18
|
-
'create_crypto_address',
|
|
19
|
-
'Generate a crypto deposit address for a customer. Supports USDC, USDT, BTC, ETH on multiple networks (Ethereum, Tron, Polygon, Base, Solana). Returns the address and QR code URL.',
|
|
20
|
-
{
|
|
21
|
-
customer_id: z.string().describe('Customer ID (must have APPROVED KYC)'),
|
|
22
|
-
currency: z.string().describe('Crypto currency: "USDC", "USDT", "BTC", "ETH"'),
|
|
23
|
-
network: z.string().describe('Blockchain network: "ethereum", "tron", "polygon", "base", "solana", "bitcoin"'),
|
|
24
|
-
label: z.string().optional().describe('Friendly label for the address'),
|
|
25
|
-
},
|
|
26
|
-
async (args) => {
|
|
27
|
-
const result = await safeCall(
|
|
28
|
-
() => client.crypto.addresses.create({
|
|
29
|
-
customer_id: args.customer_id,
|
|
30
|
-
currency: args.currency,
|
|
31
|
-
network: args.network,
|
|
32
|
-
label: args.label,
|
|
33
|
-
}),
|
|
34
|
-
'create_crypto_address'
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
if (!result.success) {
|
|
38
|
-
return { content: [{ type: 'text' as const, text: `Error creating crypto address: ${result.error}` }], isError: true };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const addr = result.data;
|
|
42
|
-
return {
|
|
43
|
-
content: [{
|
|
44
|
-
type: 'text' as const,
|
|
45
|
-
text: JSON.stringify({
|
|
46
|
-
address_id: addr.id,
|
|
47
|
-
address: addr.address,
|
|
48
|
-
currency: addr.currency,
|
|
49
|
-
network: addr.network,
|
|
50
|
-
...(addr.memo && { memo: addr.memo }),
|
|
51
|
-
qr_code_url: addr.qr_code_url,
|
|
52
|
-
label: addr.label,
|
|
53
|
-
created_at: addr.created_at,
|
|
54
|
-
_next_steps: nextSteps(
|
|
55
|
-
'share the address with the sender',
|
|
56
|
-
`track deposits with list_crypto_deposits customer_id="${args.customer_id}"`
|
|
57
|
-
),
|
|
58
|
-
}, null, 2),
|
|
59
|
-
}],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
// ── list_crypto_addresses ───────────────────────────────────────
|
|
65
|
-
server.tool(
|
|
66
|
-
'list_crypto_addresses',
|
|
67
|
-
'List all crypto deposit addresses for a customer.',
|
|
68
|
-
{
|
|
69
|
-
customer_id: z.string().describe('Customer ID'),
|
|
70
|
-
},
|
|
71
|
-
async (args) => {
|
|
72
|
-
const result = await safeCall(
|
|
73
|
-
() => client.crypto.addresses.list(args.customer_id),
|
|
74
|
-
'list_crypto_addresses'
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
if (!result.success) {
|
|
78
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
content: [{
|
|
83
|
-
type: 'text' as const,
|
|
84
|
-
text: JSON.stringify({
|
|
85
|
-
customer_id: args.customer_id,
|
|
86
|
-
count: result.data.length,
|
|
87
|
-
addresses: result.data.map((a) => ({
|
|
88
|
-
address_id: a.id,
|
|
89
|
-
address: a.address,
|
|
90
|
-
currency: a.currency,
|
|
91
|
-
network: a.network,
|
|
92
|
-
label: a.label,
|
|
93
|
-
total_received: a.total_received,
|
|
94
|
-
})),
|
|
95
|
-
}, null, 2),
|
|
96
|
-
}],
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// ── get_crypto_address ──────────────────────────────────────────
|
|
102
|
-
server.tool(
|
|
103
|
-
'get_crypto_address',
|
|
104
|
-
'Get details of a specific crypto deposit address.',
|
|
105
|
-
{
|
|
106
|
-
address_id: z.string().describe('Crypto address ID'),
|
|
107
|
-
},
|
|
108
|
-
async (args) => {
|
|
109
|
-
const result = await safeCall(
|
|
110
|
-
() => client.crypto.addresses.retrieve(args.address_id),
|
|
111
|
-
'get_crypto_address'
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
if (!result.success) {
|
|
115
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
content: [{ type: 'text' as const, text: JSON.stringify(result.data, null, 2) }],
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
// ── list_crypto_deposits ────────────────────────────────────────
|
|
125
|
-
server.tool(
|
|
126
|
-
'list_crypto_deposits',
|
|
127
|
-
'List crypto deposits for a customer. Shows pending, confirming, and confirmed deposits with transaction hashes.',
|
|
128
|
-
{
|
|
129
|
-
customer_id: z.string().describe('Customer ID'),
|
|
130
|
-
},
|
|
131
|
-
async (args) => {
|
|
132
|
-
const result = await safeCall(
|
|
133
|
-
() => client.crypto.deposits.list({ customer_id: args.customer_id }),
|
|
134
|
-
'list_crypto_deposits'
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
if (!result.success) {
|
|
138
|
-
return {
|
|
139
|
-
content: [{
|
|
140
|
-
type: 'text' as const,
|
|
141
|
-
text: JSON.stringify({ customer_id: args.customer_id, deposits: [], count: 0 }, null, 2),
|
|
142
|
-
}],
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return {
|
|
147
|
-
content: [{
|
|
148
|
-
type: 'text' as const,
|
|
149
|
-
text: JSON.stringify({
|
|
150
|
-
customer_id: args.customer_id,
|
|
151
|
-
count: result.data.length,
|
|
152
|
-
deposits: result.data.map((d) => ({
|
|
153
|
-
deposit_id: d.id,
|
|
154
|
-
amount: d.amount,
|
|
155
|
-
currency: d.currency,
|
|
156
|
-
network: d.network,
|
|
157
|
-
status: d.status,
|
|
158
|
-
confirmations: `${d.confirmations}/${d.required_confirmations}`,
|
|
159
|
-
tx_hash: d.tx_hash,
|
|
160
|
-
...(d.credited_amount && {
|
|
161
|
-
credited_amount: d.credited_amount,
|
|
162
|
-
credited_currency: d.credited_currency,
|
|
163
|
-
credited_at: d.credited_at,
|
|
164
|
-
}),
|
|
165
|
-
created_at: d.created_at,
|
|
166
|
-
})),
|
|
167
|
-
}, null, 2),
|
|
168
|
-
}],
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
// ── get_crypto_deposit ──────────────────────────────────────────
|
|
174
|
-
server.tool(
|
|
175
|
-
'get_crypto_deposit',
|
|
176
|
-
'Get details of a specific crypto deposit including confirmation status and tx hash.',
|
|
177
|
-
{
|
|
178
|
-
deposit_id: z.string().describe('Deposit ID'),
|
|
179
|
-
},
|
|
180
|
-
async (args) => {
|
|
181
|
-
const result = await safeCall(
|
|
182
|
-
() => client.crypto.deposits.retrieve(args.deposit_id),
|
|
183
|
-
'get_crypto_deposit'
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
if (!result.success) {
|
|
187
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return {
|
|
191
|
-
content: [{ type: 'text' as const, text: JSON.stringify(result.data, null, 2) }],
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
// ── get_crypto_settings ─────────────────────────────────────────
|
|
197
|
-
server.tool(
|
|
198
|
-
'get_crypto_settings',
|
|
199
|
-
'Get crypto settings for a customer (auto-convert preferences, accepted currencies, etc.).',
|
|
200
|
-
{
|
|
201
|
-
customer_id: z.string().describe('Customer ID'),
|
|
202
|
-
},
|
|
203
|
-
async (args) => {
|
|
204
|
-
const result = await safeCall(
|
|
205
|
-
() => client.crypto.settings.get(args.customer_id),
|
|
206
|
-
'get_crypto_settings'
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
if (!result.success) {
|
|
210
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return {
|
|
214
|
-
content: [{ type: 'text' as const, text: JSON.stringify(result.data, null, 2) }],
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
// ── update_crypto_settings ──────────────────────────────────────
|
|
220
|
-
server.tool(
|
|
221
|
-
'update_crypto_settings',
|
|
222
|
-
'Update crypto settings for a customer (auto-convert, accepted currencies).',
|
|
223
|
-
{
|
|
224
|
-
customer_id: z.string().describe('Customer ID'),
|
|
225
|
-
auto_convert: z.boolean().optional().describe('Auto-convert deposits to fiat'),
|
|
226
|
-
auto_convert_currency: z.string().optional().describe('Target fiat currency for auto-convert (e.g. "USD")'),
|
|
227
|
-
},
|
|
228
|
-
async (args) => {
|
|
229
|
-
const params: Record<string, unknown> = {};
|
|
230
|
-
if (args.auto_convert !== undefined) params.auto_convert = args.auto_convert;
|
|
231
|
-
if (args.auto_convert_currency) params.auto_convert_currency = args.auto_convert_currency;
|
|
232
|
-
|
|
233
|
-
const result = await safeCall(
|
|
234
|
-
() => client.crypto.settings.update(args.customer_id, params),
|
|
235
|
-
'update_crypto_settings'
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
if (!result.success) {
|
|
239
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return {
|
|
243
|
-
content: [{
|
|
244
|
-
type: 'text' as const,
|
|
245
|
-
text: JSON.stringify({
|
|
246
|
-
customer_id: args.customer_id,
|
|
247
|
-
updated: true,
|
|
248
|
-
settings: result.data,
|
|
249
|
-
}, null, 2),
|
|
250
|
-
}],
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
// ── crypto_convert_quote ────────────────────────────────────────
|
|
256
|
-
server.tool(
|
|
257
|
-
'crypto_convert_quote',
|
|
258
|
-
'Get a quote for converting between crypto and fiat (e.g. USDC→USD, BTC→GBP). Quotes expire in 2 minutes.',
|
|
259
|
-
{
|
|
260
|
-
from_currency: z.string().describe('Source currency (e.g. "USDC", "BTC", "USD")'),
|
|
261
|
-
to_currency: z.string().describe('Target currency (e.g. "USD", "USDC", "EUR")'),
|
|
262
|
-
amount: z.number().describe('Amount to convert'),
|
|
263
|
-
},
|
|
264
|
-
async (args) => {
|
|
265
|
-
const result = await safeCall(
|
|
266
|
-
() => client.crypto.convert.quote({
|
|
267
|
-
from_currency: args.from_currency,
|
|
268
|
-
to_currency: args.to_currency,
|
|
269
|
-
amount: args.amount,
|
|
270
|
-
}),
|
|
271
|
-
'crypto_convert_quote'
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
if (!result.success) {
|
|
275
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const q = result.data;
|
|
279
|
-
return {
|
|
280
|
-
content: [{
|
|
281
|
-
type: 'text' as const,
|
|
282
|
-
text: JSON.stringify({
|
|
283
|
-
quote_id: q.id,
|
|
284
|
-
from: `${q.from_amount} ${q.from_currency}`,
|
|
285
|
-
to: `${q.to_amount} ${q.to_currency}`,
|
|
286
|
-
rate: q.rate,
|
|
287
|
-
fee: q.fee,
|
|
288
|
-
expires_at: q.expires_at,
|
|
289
|
-
_warning: 'Quote expires in 2 minutes. Call crypto_convert_execute to confirm.',
|
|
290
|
-
_next_steps: nextSteps(
|
|
291
|
-
`call crypto_convert_execute with quote_id="${q.id}" to execute the conversion`
|
|
292
|
-
),
|
|
293
|
-
}, null, 2),
|
|
294
|
-
}],
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
// ── crypto_convert_execute ──────────────────────────────────────
|
|
300
|
-
server.tool(
|
|
301
|
-
'crypto_convert_execute',
|
|
302
|
-
'Execute a previously quoted crypto conversion. Must be called within 2 minutes of the quote.',
|
|
303
|
-
{
|
|
304
|
-
quote_id: z.string().describe('Quote ID from crypto_convert_quote'),
|
|
305
|
-
},
|
|
306
|
-
async (args) => {
|
|
307
|
-
const result = await safeCall(
|
|
308
|
-
() => client.crypto.convert.execute({ quote_id: args.quote_id }),
|
|
309
|
-
'crypto_convert_execute'
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
if (!result.success) {
|
|
313
|
-
if (result.error.toLowerCase().includes('expire')) {
|
|
314
|
-
return {
|
|
315
|
-
content: [{ type: 'text' as const, text: 'Error: Quote has expired. Quotes are valid for 2 minutes. Get a new quote with crypto_convert_quote.' }],
|
|
316
|
-
isError: true,
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
return {
|
|
323
|
-
content: [{
|
|
324
|
-
type: 'text' as const,
|
|
325
|
-
text: JSON.stringify({
|
|
326
|
-
conversion_id: result.data.id,
|
|
327
|
-
status: result.data.status,
|
|
328
|
-
note: 'Conversion executed successfully.',
|
|
329
|
-
}, null, 2),
|
|
330
|
-
}],
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
// ── send_crypto_payout ──────────────────────────────────────────
|
|
336
|
-
server.tool(
|
|
337
|
-
'send_crypto_payout',
|
|
338
|
-
'Send a crypto payout to an external wallet address. Supports USDC, USDT, BTC, ETH. Requires APPROVED KYC.',
|
|
339
|
-
{
|
|
340
|
-
customer_id: z.string().describe('Customer ID (must have APPROVED KYC)'),
|
|
341
|
-
currency: z.string().describe('Crypto currency: "USDC", "USDT", "BTC", "ETH"'),
|
|
342
|
-
network: z.string().describe('Blockchain network: "ethereum", "tron", "polygon", "base", "solana", "bitcoin"'),
|
|
343
|
-
amount: z.number().describe('Amount to send'),
|
|
344
|
-
to_address: z.string().describe('Destination wallet address'),
|
|
345
|
-
memo: z.string().optional().describe('Memo/tag (required for some networks)'),
|
|
346
|
-
idempotency_key: z.string().optional().describe('Unique key to prevent duplicate payouts'),
|
|
347
|
-
},
|
|
348
|
-
async (args) => {
|
|
349
|
-
const result = await safeCall(
|
|
350
|
-
() => client.payouts.crypto.create({
|
|
351
|
-
customer_id: args.customer_id,
|
|
352
|
-
currency: args.currency,
|
|
353
|
-
network: args.network,
|
|
354
|
-
amount: args.amount,
|
|
355
|
-
to_address: args.to_address,
|
|
356
|
-
memo: args.memo,
|
|
357
|
-
idempotency_key: args.idempotency_key || `crypto-${Date.now()}`,
|
|
358
|
-
}),
|
|
359
|
-
'send_crypto_payout'
|
|
360
|
-
);
|
|
361
|
-
|
|
362
|
-
if (!result.success) {
|
|
363
|
-
return { content: [{ type: 'text' as const, text: `Error creating crypto payout: ${result.error}` }], isError: true };
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
const p = result.data;
|
|
367
|
-
return {
|
|
368
|
-
content: [{
|
|
369
|
-
type: 'text' as const,
|
|
370
|
-
text: JSON.stringify({
|
|
371
|
-
transaction_id: p.id,
|
|
372
|
-
status: p.status,
|
|
373
|
-
amount: p.amount,
|
|
374
|
-
currency: p.currency,
|
|
375
|
-
created_at: p.created_at,
|
|
376
|
-
_next_steps: `Track with get_transaction transaction_id="${p.id}".`,
|
|
377
|
-
}, null, 2),
|
|
378
|
-
}],
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
);
|
|
382
|
-
}
|
package/src/tools/currencies.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Currency & Rate Tools — FX rates, corridors, delivery windows
|
|
3
|
-
*
|
|
4
|
-
* get_currencies is THE most important tool in the entire MCP server.
|
|
5
|
-
* It returns everything needed to construct a valid payout.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
import type { ServerConfig } from '../config.js';
|
|
11
|
-
import { safeCall } from '../config.js';
|
|
12
|
-
|
|
13
|
-
export function registerCurrencyTools(server: McpServer, config: ServerConfig) {
|
|
14
|
-
const { client } = config;
|
|
15
|
-
|
|
16
|
-
// ── get_currencies ──────────────────────────────────────────────
|
|
17
|
-
server.tool(
|
|
18
|
-
'get_currencies',
|
|
19
|
-
`THE critical tool — call this BEFORE any payout. Returns FX rates, corridor UUIDs (needed for create_recipient), delivery window UUIDs (needed for create_payout), delivery methods, account types, fees, and limits for a country. Use the iso2 param with the DESTINATION country code (e.g. "NG" for Nigeria, "KE" for Kenya, "GH" for Ghana, "GB" for UK). The response contains: international_remittance[].id (corridor UUID), delivery_windows[].id (window UUID), delivery_methods, rates, and fees.`,
|
|
20
|
-
{
|
|
21
|
-
iso2: z.string().describe('Destination country ISO2 code (e.g. "NG", "KE", "GH", "US", "GB")'),
|
|
22
|
-
},
|
|
23
|
-
async (args) => {
|
|
24
|
-
// Use the reference.countries + fx.rates approach since the SDK
|
|
25
|
-
// doesn't have a direct getCurrencies method. We'll call fx.rates
|
|
26
|
-
// and reference data to build the corridor info.
|
|
27
|
-
const ratesResult = await safeCall(() => client.fx.rates(), 'get_currencies');
|
|
28
|
-
|
|
29
|
-
if (!ratesResult.success) {
|
|
30
|
-
return {
|
|
31
|
-
content: [{ type: 'text' as const, text: `Error fetching currencies: ${ratesResult.error}` }],
|
|
32
|
-
isError: true,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Also get banks for this country
|
|
37
|
-
const banksResult = await safeCall(
|
|
38
|
-
() => client.reference.banks.list(args.iso2),
|
|
39
|
-
'get_currencies_banks'
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
// Get mobile networks
|
|
43
|
-
const mobileResult = await safeCall(
|
|
44
|
-
() => client.reference.mobileNetworks.list(args.iso2),
|
|
45
|
-
'get_currencies_mobile'
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const rates = ratesResult.data;
|
|
49
|
-
const banks = banksResult.success ? banksResult.data : [];
|
|
50
|
-
const mobileNetworks = mobileResult.success ? mobileResult.data : [];
|
|
51
|
-
|
|
52
|
-
// Filter rates relevant to the destination country
|
|
53
|
-
// Rates are keyed like "USD_NGN", "GBP_NGN" etc.
|
|
54
|
-
const iso2Upper = args.iso2.toUpperCase();
|
|
55
|
-
const relevantRates: Record<string, number> = {};
|
|
56
|
-
for (const [pair, rate] of Object.entries(rates as Record<string, number>)) {
|
|
57
|
-
if (pair.includes(`_${iso2Upper}`) || pair.endsWith(`_${iso2Upper}`)) {
|
|
58
|
-
relevantRates[pair] = rate;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
content: [
|
|
64
|
-
{
|
|
65
|
-
type: 'text' as const,
|
|
66
|
-
text: JSON.stringify(
|
|
67
|
-
{
|
|
68
|
-
country: args.iso2,
|
|
69
|
-
summary: `Found ${Object.keys(relevantRates).length} FX rate pairs for ${iso2Upper}. Use corridor IDs when creating recipients, and delivery window IDs when creating payouts.`,
|
|
70
|
-
rates: relevantRates,
|
|
71
|
-
banks: banks.slice(0, 20), // Top 20 banks
|
|
72
|
-
mobile_networks: mobileNetworks,
|
|
73
|
-
delivery_methods: {
|
|
74
|
-
bank: { available: true, routing_types: ['SWIFT', 'ACH_CODE'] },
|
|
75
|
-
mobile_money: { available: mobileNetworks.length > 0 },
|
|
76
|
-
cash_pickup: { available: false, note: 'Call list_cash_pickup_agents to check availability' },
|
|
77
|
-
},
|
|
78
|
-
_next_steps:
|
|
79
|
-
'Use a corridor rate pair to determine the exchange rate. Then call list_wallets to find your source wallet, and proceed with send_bank_payout or send_mobile_money_payout.',
|
|
80
|
-
},
|
|
81
|
-
null,
|
|
82
|
-
2
|
|
83
|
-
),
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// ── list_countries ──────────────────────────────────────────────
|
|
91
|
-
server.tool(
|
|
92
|
-
'list_countries',
|
|
93
|
-
'List all supported countries with their ISO2 codes. Use these codes with get_currencies to look up corridors and rates.',
|
|
94
|
-
{
|
|
95
|
-
page: z.number().optional().describe('Page number (default 1)'),
|
|
96
|
-
},
|
|
97
|
-
async (_args) => {
|
|
98
|
-
const result = await safeCall(() => client.reference.countries(), 'list_countries');
|
|
99
|
-
|
|
100
|
-
if (!result.success) {
|
|
101
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
content: [
|
|
106
|
-
{
|
|
107
|
-
type: 'text' as const,
|
|
108
|
-
text: JSON.stringify(
|
|
109
|
-
{
|
|
110
|
-
count: result.data.length,
|
|
111
|
-
countries: result.data,
|
|
112
|
-
_next_steps: 'Use a country code with get_currencies to see available corridors and rates.',
|
|
113
|
-
},
|
|
114
|
-
null,
|
|
115
|
-
2
|
|
116
|
-
),
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
}
|