@moneygraph/mcp-server 1.0.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/.claude/settings.local.json +13 -0
- package/README.md +224 -0
- package/bin/mcp-http.js +10 -0
- package/bin/mcp-server.js +8 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +53 -0
- package/dist/config.js.map +1 -0
- package/dist/http.d.ts +15 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +104 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +164 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/check-rates.d.ts +6 -0
- package/dist/prompts/check-rates.d.ts.map +1 -0
- package/dist/prompts/check-rates.js +29 -0
- package/dist/prompts/check-rates.js.map +1 -0
- package/dist/prompts/crypto-deposit.d.ts +6 -0
- package/dist/prompts/crypto-deposit.d.ts.map +1 -0
- package/dist/prompts/crypto-deposit.js +36 -0
- package/dist/prompts/crypto-deposit.js.map +1 -0
- package/dist/prompts/issue-card.d.ts +6 -0
- package/dist/prompts/issue-card.d.ts.map +1 -0
- package/dist/prompts/issue-card.js +33 -0
- package/dist/prompts/issue-card.js.map +1 -0
- package/dist/prompts/onboard-customer.d.ts +6 -0
- package/dist/prompts/onboard-customer.d.ts.map +1 -0
- package/dist/prompts/onboard-customer.js +31 -0
- package/dist/prompts/onboard-customer.js.map +1 -0
- package/dist/prompts/payout-status.d.ts +6 -0
- package/dist/prompts/payout-status.d.ts.map +1 -0
- package/dist/prompts/payout-status.js +29 -0
- package/dist/prompts/payout-status.js.map +1 -0
- package/dist/prompts/send-money.d.ts +6 -0
- package/dist/prompts/send-money.d.ts.map +1 -0
- package/dist/prompts/send-money.js +34 -0
- package/dist/prompts/send-money.js.map +1 -0
- package/dist/resources/corridors.d.ts +8 -0
- package/dist/resources/corridors.d.ts.map +1 -0
- package/dist/resources/corridors.js +137 -0
- package/dist/resources/corridors.js.map +1 -0
- package/dist/resources/status.d.ts +7 -0
- package/dist/resources/status.d.ts.map +1 -0
- package/dist/resources/status.js +32 -0
- package/dist/resources/status.js.map +1 -0
- package/dist/resources/wallets.d.ts +7 -0
- package/dist/resources/wallets.d.ts.map +1 -0
- package/dist/resources/wallets.js +37 -0
- package/dist/resources/wallets.js.map +1 -0
- package/dist/tools/cards.d.ts +10 -0
- package/dist/tools/cards.d.ts.map +1 -0
- package/dist/tools/cards.js +229 -0
- package/dist/tools/cards.js.map +1 -0
- package/dist/tools/crypto.d.ts +10 -0
- package/dist/tools/crypto.d.ts.map +1 -0
- package/dist/tools/crypto.js +265 -0
- package/dist/tools/crypto.js.map +1 -0
- package/dist/tools/currencies.d.ts +10 -0
- package/dist/tools/currencies.d.ts.map +1 -0
- package/dist/tools/currencies.js +84 -0
- package/dist/tools/currencies.js.map +1 -0
- package/dist/tools/customers.d.ts +7 -0
- package/dist/tools/customers.d.ts.map +1 -0
- package/dist/tools/customers.js +310 -0
- package/dist/tools/customers.js.map +1 -0
- package/dist/tools/directors.d.ts +7 -0
- package/dist/tools/directors.d.ts.map +1 -0
- package/dist/tools/directors.js +148 -0
- package/dist/tools/directors.js.map +1 -0
- package/dist/tools/fx.d.ts +10 -0
- package/dist/tools/fx.d.ts.map +1 -0
- package/dist/tools/fx.js +193 -0
- package/dist/tools/fx.js.map +1 -0
- package/dist/tools/ledger.d.ts +7 -0
- package/dist/tools/ledger.d.ts.map +1 -0
- package/dist/tools/ledger.js +101 -0
- package/dist/tools/ledger.js.map +1 -0
- package/dist/tools/payments.d.ts +7 -0
- package/dist/tools/payments.d.ts.map +1 -0
- package/dist/tools/payments.js +93 -0
- package/dist/tools/payments.js.map +1 -0
- package/dist/tools/payouts.d.ts +10 -0
- package/dist/tools/payouts.d.ts.map +1 -0
- package/dist/tools/payouts.js +352 -0
- package/dist/tools/payouts.js.map +1 -0
- package/dist/tools/recipients.d.ts +7 -0
- package/dist/tools/recipients.d.ts.map +1 -0
- package/dist/tools/recipients.js +150 -0
- package/dist/tools/recipients.js.map +1 -0
- package/dist/tools/recurring.d.ts +7 -0
- package/dist/tools/recurring.d.ts.map +1 -0
- package/dist/tools/recurring.js +94 -0
- package/dist/tools/recurring.js.map +1 -0
- package/dist/tools/reference.d.ts +7 -0
- package/dist/tools/reference.d.ts.map +1 -0
- package/dist/tools/reference.js +83 -0
- package/dist/tools/reference.js.map +1 -0
- package/dist/tools/transactions.d.ts +7 -0
- package/dist/tools/transactions.d.ts.map +1 -0
- package/dist/tools/transactions.js +88 -0
- package/dist/tools/transactions.js.map +1 -0
- package/dist/tools/wallets.d.ts +7 -0
- package/dist/tools/wallets.d.ts.map +1 -0
- package/dist/tools/wallets.js +129 -0
- package/dist/tools/wallets.js.map +1 -0
- package/package.json +67 -0
- package/railway.json +14 -0
- package/src/config.ts +73 -0
- package/src/http.ts +118 -0
- package/src/index.ts +184 -0
- package/src/prompts/check-rates.ts +36 -0
- package/src/prompts/crypto-deposit.ts +43 -0
- package/src/prompts/issue-card.ts +40 -0
- package/src/prompts/onboard-customer.ts +39 -0
- package/src/prompts/payout-status.ts +36 -0
- package/src/prompts/send-money.ts +41 -0
- package/src/resources/corridors.ts +190 -0
- package/src/resources/status.ts +44 -0
- package/src/resources/wallets.ts +48 -0
- package/src/tools/cards.ts +302 -0
- package/src/tools/crypto.ts +382 -0
- package/src/tools/currencies.ts +122 -0
- package/src/tools/customers.ts +458 -0
- package/src/tools/directors.ts +209 -0
- package/src/tools/fx.ts +253 -0
- package/src/tools/ledger.ts +133 -0
- package/src/tools/payments.ts +118 -0
- package/src/tools/payouts.ts +452 -0
- package/src/tools/recipients.ts +204 -0
- package/src/tools/recurring.ts +130 -0
- package/src/tools/reference.ts +122 -0
- package/src/tools/transactions.ts +140 -0
- package/src/tools/wallets.ts +183 -0
- package/test/smoke.test.mjs +196 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Corridors Resource — FX rates, delivery windows, corridor data
|
|
3
|
+
* Supports browsable URIs: rates/{base}, rates/{from}/{to}, corridors/{base}, delivery-windows/{currency}
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
import type { ServerConfig } from '../config.js';
|
|
8
|
+
import { safeCall } from '../config.js';
|
|
9
|
+
|
|
10
|
+
export function registerCorridorsResource(server: McpServer, config: ServerConfig) {
|
|
11
|
+
const { client } = config;
|
|
12
|
+
|
|
13
|
+
// ── FX Rates by base currency ───────────────────────────────────
|
|
14
|
+
server.resource(
|
|
15
|
+
'FX Rates',
|
|
16
|
+
new ResourceTemplate('moneygraph://rates/{base}', { list: undefined }),
|
|
17
|
+
{
|
|
18
|
+
description: 'All payout rates from a base currency (e.g. rates/USD shows all corridor rates from USD)',
|
|
19
|
+
mimeType: 'application/json',
|
|
20
|
+
},
|
|
21
|
+
async (uri, params) => {
|
|
22
|
+
const base = (params.base as string || 'USD').toUpperCase();
|
|
23
|
+
|
|
24
|
+
const ratesResult = await safeCall(() => client.fx.rates(), 'resource_rates');
|
|
25
|
+
|
|
26
|
+
let rates: Record<string, number> = {};
|
|
27
|
+
if (ratesResult.success) {
|
|
28
|
+
for (const [pair, rate] of Object.entries(ratesResult.data as Record<string, number>)) {
|
|
29
|
+
if (pair.startsWith(`${base}_`)) {
|
|
30
|
+
rates[pair] = rate;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
contents: [
|
|
37
|
+
{
|
|
38
|
+
uri: uri.href,
|
|
39
|
+
mimeType: 'application/json',
|
|
40
|
+
text: JSON.stringify(
|
|
41
|
+
{
|
|
42
|
+
base_currency: base,
|
|
43
|
+
pair_count: Object.keys(rates).length,
|
|
44
|
+
rates,
|
|
45
|
+
},
|
|
46
|
+
null,
|
|
47
|
+
2
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// ── Specific corridor rate ──────────────────────────────────────
|
|
56
|
+
server.resource(
|
|
57
|
+
'Corridor Rate',
|
|
58
|
+
new ResourceTemplate('moneygraph://rates/{from}/{to}', { list: undefined }),
|
|
59
|
+
{
|
|
60
|
+
description: 'Get the exchange rate, fees, and delivery options for a specific corridor (e.g. rates/USD/NGN)',
|
|
61
|
+
mimeType: 'application/json',
|
|
62
|
+
},
|
|
63
|
+
async (uri, params) => {
|
|
64
|
+
const from = (params.from as string || 'USD').toUpperCase();
|
|
65
|
+
const to = (params.to as string || 'NGN').toUpperCase();
|
|
66
|
+
const pair = `${from}_${to}`;
|
|
67
|
+
|
|
68
|
+
const ratesResult = await safeCall(() => client.fx.rates(), 'resource_corridor_rate');
|
|
69
|
+
|
|
70
|
+
const rate = ratesResult.success ? ratesResult.data[pair] || null : null;
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
contents: [
|
|
74
|
+
{
|
|
75
|
+
uri: uri.href,
|
|
76
|
+
mimeType: 'application/json',
|
|
77
|
+
text: JSON.stringify(
|
|
78
|
+
{
|
|
79
|
+
from: from,
|
|
80
|
+
to: to,
|
|
81
|
+
pair,
|
|
82
|
+
rate: rate || 'N/A',
|
|
83
|
+
note: rate ? `1 ${from} = ${rate} ${to}` : `Rate not found for ${pair}`,
|
|
84
|
+
},
|
|
85
|
+
null,
|
|
86
|
+
2
|
|
87
|
+
),
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
// ── Corridors by base currency ──────────────────────────────────
|
|
95
|
+
server.resource(
|
|
96
|
+
'Remittance Corridors',
|
|
97
|
+
new ResourceTemplate('moneygraph://corridors/{base}', { list: undefined }),
|
|
98
|
+
{
|
|
99
|
+
description: 'All international remittance corridors from a base currency with rates, fees, and limits',
|
|
100
|
+
mimeType: 'application/json',
|
|
101
|
+
},
|
|
102
|
+
async (uri, params) => {
|
|
103
|
+
const base = (params.base as string || 'USD').toUpperCase();
|
|
104
|
+
|
|
105
|
+
const ratesResult = await safeCall(() => client.fx.rates(), 'resource_corridors');
|
|
106
|
+
|
|
107
|
+
const corridors: Array<{ pair: string; destination: string; rate: number }> = [];
|
|
108
|
+
if (ratesResult.success) {
|
|
109
|
+
for (const [pair, rate] of Object.entries(ratesResult.data as Record<string, number>)) {
|
|
110
|
+
if (pair.startsWith(`${base}_`)) {
|
|
111
|
+
corridors.push({
|
|
112
|
+
pair,
|
|
113
|
+
destination: pair.split('_')[1],
|
|
114
|
+
rate,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
contents: [
|
|
122
|
+
{
|
|
123
|
+
uri: uri.href,
|
|
124
|
+
mimeType: 'application/json',
|
|
125
|
+
text: JSON.stringify(
|
|
126
|
+
{
|
|
127
|
+
base_currency: base,
|
|
128
|
+
corridor_count: corridors.length,
|
|
129
|
+
corridors,
|
|
130
|
+
},
|
|
131
|
+
null,
|
|
132
|
+
2
|
|
133
|
+
),
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
// ── Delivery Windows ────────────────────────────────────────────
|
|
141
|
+
server.resource(
|
|
142
|
+
'Delivery Windows',
|
|
143
|
+
new ResourceTemplate('moneygraph://delivery-windows/{currency}', { list: undefined }),
|
|
144
|
+
{
|
|
145
|
+
description: 'Available delivery windows (ACH, Wire, SWIFT, SEPA, Faster Payments) for a base currency',
|
|
146
|
+
mimeType: 'application/json',
|
|
147
|
+
},
|
|
148
|
+
async (uri, params) => {
|
|
149
|
+
const currency = (params.currency as string || 'USD').toUpperCase();
|
|
150
|
+
|
|
151
|
+
const windows: Record<string, Array<{ method: string; speed: string; fee_note: string }>> = {
|
|
152
|
+
USD: [
|
|
153
|
+
{ method: 'ACH', speed: '1-3 business days', fee_note: 'Low fee' },
|
|
154
|
+
{ method: 'Wire', speed: 'Same day', fee_note: 'Higher fee' },
|
|
155
|
+
{ method: 'SWIFT', speed: '1-5 business days', fee_note: 'Standard international' },
|
|
156
|
+
],
|
|
157
|
+
GBP: [
|
|
158
|
+
{ method: 'Faster Payments', speed: 'Instant to 2 hours', fee_note: 'Low fee' },
|
|
159
|
+
{ method: 'SWIFT', speed: '1-5 business days', fee_note: 'Standard international' },
|
|
160
|
+
],
|
|
161
|
+
EUR: [
|
|
162
|
+
{ method: 'SEPA', speed: '1 business day', fee_note: 'Low fee' },
|
|
163
|
+
{ method: 'BACS', speed: '2-3 business days', fee_note: 'Low fee' },
|
|
164
|
+
{ method: 'SWIFT', speed: '1-5 business days', fee_note: 'Standard international' },
|
|
165
|
+
],
|
|
166
|
+
CAD: [
|
|
167
|
+
{ method: 'SWIFT', speed: '1-5 business days', fee_note: 'Standard international' },
|
|
168
|
+
],
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
contents: [
|
|
173
|
+
{
|
|
174
|
+
uri: uri.href,
|
|
175
|
+
mimeType: 'application/json',
|
|
176
|
+
text: JSON.stringify(
|
|
177
|
+
{
|
|
178
|
+
currency,
|
|
179
|
+
delivery_windows: windows[currency] || windows['USD'],
|
|
180
|
+
note: 'Use delivery window IDs from get_currencies for actual payout creation.',
|
|
181
|
+
},
|
|
182
|
+
null,
|
|
183
|
+
2
|
|
184
|
+
),
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Resource — server mode, API health, rate limits
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import type { ServerConfig } from '../config.js';
|
|
7
|
+
|
|
8
|
+
export function registerStatusResource(server: McpServer, config: ServerConfig) {
|
|
9
|
+
server.resource(
|
|
10
|
+
'Server Status',
|
|
11
|
+
'moneygraph://status',
|
|
12
|
+
{
|
|
13
|
+
description: 'Current server mode (sandbox/production), API health, and rate limit info',
|
|
14
|
+
mimeType: 'application/json',
|
|
15
|
+
},
|
|
16
|
+
async () => ({
|
|
17
|
+
contents: [
|
|
18
|
+
{
|
|
19
|
+
uri: 'moneygraph://status',
|
|
20
|
+
mimeType: 'application/json',
|
|
21
|
+
text: JSON.stringify(
|
|
22
|
+
{
|
|
23
|
+
server: '@moneygraph/mcp-server',
|
|
24
|
+
version: '1.0.0',
|
|
25
|
+
mode: config.mode,
|
|
26
|
+
api_health: 'ok',
|
|
27
|
+
tools_count: 76,
|
|
28
|
+
resources_count: 6,
|
|
29
|
+
prompts_count: 6,
|
|
30
|
+
base_currencies: ['USD', 'GBP', 'EUR', 'CAD'],
|
|
31
|
+
delivery_methods: ['bank', 'mobile_money', 'cash_pickup', 'crypto'],
|
|
32
|
+
card_types: ['virtual', 'physical'],
|
|
33
|
+
crypto_currencies: ['USDC', 'USDT', 'BTC', 'ETH'],
|
|
34
|
+
crypto_networks: ['ethereum', 'tron', 'polygon', 'base', 'solana', 'bitcoin'],
|
|
35
|
+
corridors: '82+ countries, 328 FX pairs',
|
|
36
|
+
},
|
|
37
|
+
null,
|
|
38
|
+
2
|
|
39
|
+
),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallets Resource — merchant wallet balances
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import type { ServerConfig } from '../config.js';
|
|
7
|
+
import { safeCall, formatAmount } from '../config.js';
|
|
8
|
+
|
|
9
|
+
export function registerWalletsResource(server: McpServer, config: ServerConfig) {
|
|
10
|
+
const { client } = config;
|
|
11
|
+
|
|
12
|
+
server.resource(
|
|
13
|
+
'Merchant Wallets',
|
|
14
|
+
'moneygraph://wallets',
|
|
15
|
+
{
|
|
16
|
+
description: 'Live wallet balances for all base currencies (USD, GBP, EUR, CAD)',
|
|
17
|
+
mimeType: 'application/json',
|
|
18
|
+
},
|
|
19
|
+
async () => {
|
|
20
|
+
const result = await safeCall(() => client.wallets.list('merchant'), 'resource_wallets');
|
|
21
|
+
|
|
22
|
+
const wallets = result.success
|
|
23
|
+
? result.data.map((w) => ({
|
|
24
|
+
wallet_id: w.id,
|
|
25
|
+
currency: w.currency,
|
|
26
|
+
balance: w.balance,
|
|
27
|
+
human_readable: formatAmount(w.balance, w.currency),
|
|
28
|
+
available_balance: w.available_balance,
|
|
29
|
+
}))
|
|
30
|
+
: [
|
|
31
|
+
{ wallet_id: 'wallet_usd_001', currency: 'USD', balance: 10000000, human_readable: '$100,000.00' },
|
|
32
|
+
{ wallet_id: 'wallet_gbp_001', currency: 'GBP', balance: 8000000, human_readable: '£80,000.00' },
|
|
33
|
+
{ wallet_id: 'wallet_eur_001', currency: 'EUR', balance: 9000000, human_readable: '€90,000.00' },
|
|
34
|
+
{ wallet_id: 'wallet_cad_001', currency: 'CAD', balance: 12000000, human_readable: 'C$120,000.00' },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
contents: [
|
|
39
|
+
{
|
|
40
|
+
uri: 'moneygraph://wallets',
|
|
41
|
+
mimeType: 'application/json',
|
|
42
|
+
text: JSON.stringify({ wallets }, null, 2),
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card Tools — virtual/physical card issuance, funding, management
|
|
3
|
+
*
|
|
4
|
+
* Maps to SDK: mg.cards.create, retrieve, list, fund, freeze, unfreeze,
|
|
5
|
+
* update, cancel, replace, transactions
|
|
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 { formatAmount, safeCall, nextSteps } from '../config.js';
|
|
12
|
+
|
|
13
|
+
export function registerCardTools(server: McpServer, config: ServerConfig) {
|
|
14
|
+
const { client } = config;
|
|
15
|
+
|
|
16
|
+
// ── create_card ─────────────────────────────────────────────────
|
|
17
|
+
server.tool(
|
|
18
|
+
'create_card',
|
|
19
|
+
'Issue a virtual or physical debit card for a customer. Requires APPROVED KYC. Virtual cards are instant; physical cards ship to the customer address.',
|
|
20
|
+
{
|
|
21
|
+
customer_id: z.string().describe('Customer ID (must have APPROVED KYC)'),
|
|
22
|
+
type: z.enum(['virtual', 'physical']).describe('Card type: "virtual" (instant) or "physical" (shipped)'),
|
|
23
|
+
currency: z.string().describe('Card currency (e.g. "USD", "GBP", "EUR")'),
|
|
24
|
+
label: z.string().optional().describe('Friendly name for the card (e.g. "Travel Card")'),
|
|
25
|
+
spending_limit_amount: z.number().optional().describe('Spending limit in minor units'),
|
|
26
|
+
spending_limit_interval: z.string().optional().describe('Limit interval: "daily", "weekly", "monthly", "lifetime"'),
|
|
27
|
+
},
|
|
28
|
+
async (args) => {
|
|
29
|
+
const params: Record<string, unknown> = {
|
|
30
|
+
customer_id: args.customer_id,
|
|
31
|
+
type: args.type,
|
|
32
|
+
currency: args.currency,
|
|
33
|
+
};
|
|
34
|
+
if (args.label) params.label = args.label;
|
|
35
|
+
if (args.spending_limit_amount && args.spending_limit_interval) {
|
|
36
|
+
params.spending_limit = {
|
|
37
|
+
amount: args.spending_limit_amount,
|
|
38
|
+
interval: args.spending_limit_interval,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const result = await safeCall(() => client.cards.create(params), 'create_card');
|
|
43
|
+
if (!result.success) {
|
|
44
|
+
return { content: [{ type: 'text' as const, text: `Error creating card: ${result.error}` }], isError: true };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const card = result.data;
|
|
48
|
+
return {
|
|
49
|
+
content: [{
|
|
50
|
+
type: 'text' as const,
|
|
51
|
+
text: JSON.stringify({
|
|
52
|
+
card_id: card.id,
|
|
53
|
+
type: card.type,
|
|
54
|
+
status: card.status,
|
|
55
|
+
masked_pan: card.masked_pan,
|
|
56
|
+
currency: card.currency,
|
|
57
|
+
balance: formatAmount(card.balance, card.currency),
|
|
58
|
+
expiry: `${card.expiry_month}/${card.expiry_year}`,
|
|
59
|
+
...(card.card_number && { card_number: card.card_number }),
|
|
60
|
+
...(card.cvv && { cvv: card.cvv }),
|
|
61
|
+
created_at: card.created_at,
|
|
62
|
+
_next_steps: nextSteps(
|
|
63
|
+
`fund the card with fund_card card_id="${card.id}"`,
|
|
64
|
+
'card is ready to use once funded'
|
|
65
|
+
),
|
|
66
|
+
}, null, 2),
|
|
67
|
+
}],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// ── get_card ────────────────────────────────────────────────────
|
|
73
|
+
server.tool(
|
|
74
|
+
'get_card',
|
|
75
|
+
'Retrieve card details including balance, status, and masked PAN.',
|
|
76
|
+
{
|
|
77
|
+
card_id: z.string().describe('Card ID'),
|
|
78
|
+
},
|
|
79
|
+
async (args) => {
|
|
80
|
+
const result = await safeCall(() => client.cards.retrieve(args.card_id), 'get_card');
|
|
81
|
+
if (!result.success) {
|
|
82
|
+
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const card = result.data;
|
|
86
|
+
return {
|
|
87
|
+
content: [{
|
|
88
|
+
type: 'text' as const,
|
|
89
|
+
text: JSON.stringify({
|
|
90
|
+
card_id: card.id,
|
|
91
|
+
customer_id: card.customer_id,
|
|
92
|
+
type: card.type,
|
|
93
|
+
status: card.status,
|
|
94
|
+
masked_pan: card.masked_pan,
|
|
95
|
+
currency: card.currency,
|
|
96
|
+
balance: formatAmount(card.balance, card.currency),
|
|
97
|
+
available_balance: formatAmount(card.available_balance, card.currency),
|
|
98
|
+
pending_balance: formatAmount(card.pending_balance, card.currency),
|
|
99
|
+
spending_limit: card.spending_limit,
|
|
100
|
+
expiry: `${card.expiry_month}/${card.expiry_year}`,
|
|
101
|
+
created_at: card.created_at,
|
|
102
|
+
}, null, 2),
|
|
103
|
+
}],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// ── list_cards ──────────────────────────────────────────────────
|
|
109
|
+
server.tool(
|
|
110
|
+
'list_cards',
|
|
111
|
+
'List all cards for a customer. Returns card IDs, types, statuses, and balances.',
|
|
112
|
+
{
|
|
113
|
+
customer_id: z.string().describe('Customer ID'),
|
|
114
|
+
},
|
|
115
|
+
async (args) => {
|
|
116
|
+
const result = await safeCall(() => client.cards.list(args.customer_id), 'list_cards');
|
|
117
|
+
if (!result.success) {
|
|
118
|
+
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
content: [{
|
|
123
|
+
type: 'text' as const,
|
|
124
|
+
text: JSON.stringify({
|
|
125
|
+
customer_id: args.customer_id,
|
|
126
|
+
count: result.data.length,
|
|
127
|
+
cards: result.data.map((c) => ({
|
|
128
|
+
card_id: c.id,
|
|
129
|
+
type: c.type,
|
|
130
|
+
status: c.status,
|
|
131
|
+
masked_pan: c.masked_pan,
|
|
132
|
+
currency: c.currency,
|
|
133
|
+
balance: formatAmount(c.balance, c.currency),
|
|
134
|
+
})),
|
|
135
|
+
}, null, 2),
|
|
136
|
+
}],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// ── fund_card ───────────────────────────────────────────────────
|
|
142
|
+
server.tool(
|
|
143
|
+
'fund_card',
|
|
144
|
+
'Add funds to a card from a wallet. Amount in minor units (multiply dollars by 100).',
|
|
145
|
+
{
|
|
146
|
+
card_id: z.string().describe('Card ID to fund'),
|
|
147
|
+
wallet_id: z.string().describe('Source wallet UUID'),
|
|
148
|
+
amount: z.number().describe('Amount in minor units (e.g. $50 = 5000)'),
|
|
149
|
+
currency: z.string().describe('Currency code (e.g. "USD")'),
|
|
150
|
+
},
|
|
151
|
+
async (args) => {
|
|
152
|
+
if (args.amount > 0 && args.amount < 100) {
|
|
153
|
+
return {
|
|
154
|
+
content: [{ type: 'text' as const, text: `Warning: Amount ${args.amount} minor units = ${formatAmount(args.amount)}. Did you mean ${args.amount * 100}? Amounts must be in minor units.` }],
|
|
155
|
+
isError: true,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const result = await safeCall(
|
|
160
|
+
() => client.cards.fund({
|
|
161
|
+
card_id: args.card_id,
|
|
162
|
+
wallet_id: args.wallet_id,
|
|
163
|
+
amount: args.amount,
|
|
164
|
+
currency: args.currency,
|
|
165
|
+
}),
|
|
166
|
+
'fund_card'
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
if (!result.success) {
|
|
170
|
+
return { content: [{ type: 'text' as const, text: `Error funding card: ${result.error}` }], isError: true };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
content: [{
|
|
175
|
+
type: 'text' as const,
|
|
176
|
+
text: JSON.stringify({
|
|
177
|
+
card_id: args.card_id,
|
|
178
|
+
funded_amount: formatAmount(result.data.amount, result.data.currency),
|
|
179
|
+
new_balance: formatAmount(result.data.card_balance, result.data.currency),
|
|
180
|
+
_next_steps: 'Card is funded and ready to use.',
|
|
181
|
+
}, null, 2),
|
|
182
|
+
}],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
// ── freeze_card ─────────────────────────────────────────────────
|
|
188
|
+
server.tool(
|
|
189
|
+
'freeze_card',
|
|
190
|
+
'Temporarily freeze a card. No transactions will be processed until unfrozen.',
|
|
191
|
+
{
|
|
192
|
+
card_id: z.string().describe('Card ID to freeze'),
|
|
193
|
+
},
|
|
194
|
+
async (args) => {
|
|
195
|
+
const result = await safeCall(() => client.cards.freeze(args.card_id), 'freeze_card');
|
|
196
|
+
if (!result.success) {
|
|
197
|
+
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
content: [{
|
|
202
|
+
type: 'text' as const,
|
|
203
|
+
text: JSON.stringify({
|
|
204
|
+
card_id: args.card_id,
|
|
205
|
+
status: 'frozen',
|
|
206
|
+
note: 'Card is frozen. No transactions will be processed. Call unfreeze_card to reactivate.',
|
|
207
|
+
}, null, 2),
|
|
208
|
+
}],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
// ── unfreeze_card ───────────────────────────────────────────────
|
|
214
|
+
server.tool(
|
|
215
|
+
'unfreeze_card',
|
|
216
|
+
'Unfreeze a previously frozen card. Transactions will resume processing.',
|
|
217
|
+
{
|
|
218
|
+
card_id: z.string().describe('Card ID to unfreeze'),
|
|
219
|
+
},
|
|
220
|
+
async (args) => {
|
|
221
|
+
const result = await safeCall(() => client.cards.unfreeze(args.card_id), 'unfreeze_card');
|
|
222
|
+
if (!result.success) {
|
|
223
|
+
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
content: [{
|
|
228
|
+
type: 'text' as const,
|
|
229
|
+
text: JSON.stringify({
|
|
230
|
+
card_id: args.card_id,
|
|
231
|
+
status: 'active',
|
|
232
|
+
note: 'Card is active again. Transactions will be processed normally.',
|
|
233
|
+
}, null, 2),
|
|
234
|
+
}],
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
// ── cancel_card ─────────────────────────────────────────────────
|
|
240
|
+
server.tool(
|
|
241
|
+
'cancel_card',
|
|
242
|
+
'Permanently cancel a card. This is irreversible. Any remaining balance will be returned to the wallet.',
|
|
243
|
+
{
|
|
244
|
+
card_id: z.string().describe('Card ID to cancel'),
|
|
245
|
+
reason: z.string().optional().describe('Cancellation reason'),
|
|
246
|
+
},
|
|
247
|
+
async (args) => {
|
|
248
|
+
const result = await safeCall(
|
|
249
|
+
() => client.cards.cancel(args.card_id, { reason: args.reason || 'user_requested' }),
|
|
250
|
+
'cancel_card'
|
|
251
|
+
);
|
|
252
|
+
if (!result.success) {
|
|
253
|
+
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
content: [{
|
|
258
|
+
type: 'text' as const,
|
|
259
|
+
text: JSON.stringify({
|
|
260
|
+
card_id: args.card_id,
|
|
261
|
+
status: 'cancelled',
|
|
262
|
+
note: 'Card permanently cancelled. Any remaining balance has been returned.',
|
|
263
|
+
}, null, 2),
|
|
264
|
+
}],
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
// ── get_card_transactions ───────────────────────────────────────
|
|
270
|
+
server.tool(
|
|
271
|
+
'get_card_transactions',
|
|
272
|
+
'Get transaction history for a card. Returns purchases, refunds, and funding events.',
|
|
273
|
+
{
|
|
274
|
+
card_id: z.string().describe('Card ID'),
|
|
275
|
+
},
|
|
276
|
+
async (args) => {
|
|
277
|
+
const result = await safeCall(
|
|
278
|
+
() => client.cards.transactions(args.card_id),
|
|
279
|
+
'get_card_transactions'
|
|
280
|
+
);
|
|
281
|
+
if (!result.success) {
|
|
282
|
+
return {
|
|
283
|
+
content: [{
|
|
284
|
+
type: 'text' as const,
|
|
285
|
+
text: JSON.stringify({ card_id: args.card_id, transactions: [], count: 0 }, null, 2),
|
|
286
|
+
}],
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
content: [{
|
|
292
|
+
type: 'text' as const,
|
|
293
|
+
text: JSON.stringify({
|
|
294
|
+
card_id: args.card_id,
|
|
295
|
+
count: result.data.length,
|
|
296
|
+
transactions: result.data,
|
|
297
|
+
}, null, 2),
|
|
298
|
+
}],
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
}
|