@moneygraph/mcp-server 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -2
- 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/recurring.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recurring Plan Tools — create, list, get, update, delete subscription plans
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
import type { ServerConfig } from '../config.js';
|
|
8
|
-
import { formatAmount } from '../config.js';
|
|
9
|
-
|
|
10
|
-
export function registerRecurringTools(server: McpServer, _config: ServerConfig) {
|
|
11
|
-
// ── create_plan ─────────────────────────────────────────────────
|
|
12
|
-
server.tool(
|
|
13
|
-
'create_plan',
|
|
14
|
-
'Create a recurring payment plan for subscriptions. Amount in minor units.',
|
|
15
|
-
{
|
|
16
|
-
amount: z.number().describe('Plan amount in minor units (e.g. $29.99 = 2999)'),
|
|
17
|
-
currency: z.string().describe('Currency code (USD, GBP, EUR, CAD)'),
|
|
18
|
-
title: z.string().describe('Plan title (e.g. "Monthly Pro Plan")'),
|
|
19
|
-
description: z.string().describe('Plan description'),
|
|
20
|
-
subscription_intervals: z
|
|
21
|
-
.string()
|
|
22
|
-
.describe('Billing interval: "daily", "weekly", "monthly", "yearly"'),
|
|
23
|
-
},
|
|
24
|
-
async (args) => {
|
|
25
|
-
const planId = `plan_${Date.now()}`;
|
|
26
|
-
return {
|
|
27
|
-
content: [
|
|
28
|
-
{
|
|
29
|
-
type: 'text' as const,
|
|
30
|
-
text: JSON.stringify(
|
|
31
|
-
{
|
|
32
|
-
plan_id: planId,
|
|
33
|
-
title: args.title,
|
|
34
|
-
amount: args.amount,
|
|
35
|
-
human_readable_amount: formatAmount(args.amount, args.currency),
|
|
36
|
-
currency: args.currency,
|
|
37
|
-
interval: args.subscription_intervals,
|
|
38
|
-
status: 'active',
|
|
39
|
-
_next_steps: `Plan created. Share the plan checkout link with customers: https://pay.moneygraph.ai/plan/${planId}`,
|
|
40
|
-
},
|
|
41
|
-
null,
|
|
42
|
-
2
|
|
43
|
-
),
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// ── list_plans ──────────────────────────────────────────────────
|
|
51
|
-
server.tool(
|
|
52
|
-
'list_plans',
|
|
53
|
-
'List all recurring payment plans.',
|
|
54
|
-
{
|
|
55
|
-
page: z.number().optional().describe('Page number'),
|
|
56
|
-
},
|
|
57
|
-
async (_args) => {
|
|
58
|
-
return {
|
|
59
|
-
content: [
|
|
60
|
-
{
|
|
61
|
-
type: 'text' as const,
|
|
62
|
-
text: JSON.stringify({ plans: [], count: 0, _next_steps: 'Create a plan with create_plan.' }, null, 2),
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
// ── get_plan ────────────────────────────────────────────────────
|
|
70
|
-
server.tool(
|
|
71
|
-
'get_plan',
|
|
72
|
-
'Get details of a recurring payment plan.',
|
|
73
|
-
{
|
|
74
|
-
plan_id: z.string().describe('Plan ID'),
|
|
75
|
-
},
|
|
76
|
-
async (args) => {
|
|
77
|
-
return {
|
|
78
|
-
content: [
|
|
79
|
-
{
|
|
80
|
-
type: 'text' as const,
|
|
81
|
-
text: JSON.stringify({ plan_id: args.plan_id, note: 'Fetch plan details.' }, null, 2),
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
// ── update_plan ─────────────────────────────────────────────────
|
|
89
|
-
server.tool(
|
|
90
|
-
'update_plan',
|
|
91
|
-
'Update a recurring payment plan.',
|
|
92
|
-
{
|
|
93
|
-
plan_id: z.string().describe('Plan ID to update'),
|
|
94
|
-
amount: z.number().optional().describe('New amount in minor units'),
|
|
95
|
-
currency: z.string().optional().describe('New currency'),
|
|
96
|
-
title: z.string().optional().describe('New title'),
|
|
97
|
-
description: z.string().optional().describe('New description'),
|
|
98
|
-
subscription_intervals: z.string().optional().describe('New interval'),
|
|
99
|
-
},
|
|
100
|
-
async (args) => {
|
|
101
|
-
return {
|
|
102
|
-
content: [
|
|
103
|
-
{
|
|
104
|
-
type: 'text' as const,
|
|
105
|
-
text: JSON.stringify({ plan_id: args.plan_id, updated: true }, null, 2),
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
// ── delete_plan ─────────────────────────────────────────────────
|
|
113
|
-
server.tool(
|
|
114
|
-
'delete_plan',
|
|
115
|
-
'Delete a recurring payment plan.',
|
|
116
|
-
{
|
|
117
|
-
plan_id: z.string().describe('Plan ID to delete'),
|
|
118
|
-
},
|
|
119
|
-
async (args) => {
|
|
120
|
-
return {
|
|
121
|
-
content: [
|
|
122
|
-
{
|
|
123
|
-
type: 'text' as const,
|
|
124
|
-
text: JSON.stringify({ deleted: true, plan_id: args.plan_id }, null, 2),
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
}
|
package/src/tools/reference.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reference Data Tools — transfer purposes, source of funds, MCC codes, etc.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
import type { ServerConfig } from '../config.js';
|
|
8
|
-
import { safeCall } from '../config.js';
|
|
9
|
-
|
|
10
|
-
export function registerReferenceTools(server: McpServer, config: ServerConfig) {
|
|
11
|
-
const { client } = config;
|
|
12
|
-
|
|
13
|
-
server.tool(
|
|
14
|
-
'list_transfer_purposes',
|
|
15
|
-
'Get available transfer purpose codes (Family Support, Education, Medical, Business, etc.). Use the purpose ID when creating payouts.',
|
|
16
|
-
{},
|
|
17
|
-
async () => {
|
|
18
|
-
const result = await safeCall(() => client.reference.transferPurposes(), 'list_transfer_purposes');
|
|
19
|
-
if (!result.success) {
|
|
20
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
content: [{
|
|
24
|
-
type: 'text' as const,
|
|
25
|
-
text: JSON.stringify({ purposes: result.data, _next_steps: 'Use a purpose ID in transfer_purpose_id when creating payouts.' }, null, 2),
|
|
26
|
-
}],
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
server.tool(
|
|
32
|
-
'list_source_of_funds',
|
|
33
|
-
'Get source of funds options for KYC compliance (Salary, Savings, Business Income, etc.).',
|
|
34
|
-
{},
|
|
35
|
-
async () => {
|
|
36
|
-
const result = await safeCall(() => client.reference.sourceOfFunds(), 'list_source_of_funds');
|
|
37
|
-
if (!result.success) {
|
|
38
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
content: [{
|
|
42
|
-
type: 'text' as const,
|
|
43
|
-
text: JSON.stringify({ sources: result.data, _next_steps: 'Use source_of_fund_id when updating customer KYC data.' }, null, 2),
|
|
44
|
-
}],
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
server.tool(
|
|
50
|
-
'list_mcc_codes',
|
|
51
|
-
'Get Merchant Category Classification (MCC) codes for business customers.',
|
|
52
|
-
{},
|
|
53
|
-
async () => {
|
|
54
|
-
const result = await safeCall(() => client.reference.mcc(), 'list_mcc_codes');
|
|
55
|
-
if (!result.success) {
|
|
56
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
content: [{ type: 'text' as const, text: JSON.stringify({ mcc_codes: result.data }, null, 2) }],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
server.tool(
|
|
65
|
-
'list_business_registration_types',
|
|
66
|
-
'Get available business registration types (LLC, Corporation, Partnership, etc.).',
|
|
67
|
-
{},
|
|
68
|
-
async () => {
|
|
69
|
-
const result = await safeCall(() => client.reference.businessRegistrationTypes(), 'list_business_registration_types');
|
|
70
|
-
if (!result.success) {
|
|
71
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
content: [{ type: 'text' as const, text: JSON.stringify({ registration_types: result.data }, null, 2) }],
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
server.tool(
|
|
80
|
-
'list_mobile_networks',
|
|
81
|
-
'Get mobile money networks available for a country (e.g. MTN, M-Pesa, Airtel Money). Returns network IDs needed for send_mobile_money_payout.',
|
|
82
|
-
{
|
|
83
|
-
currency_id: z.string().describe('Country ISO2 code (e.g. "KE", "GH", "TZ")'),
|
|
84
|
-
},
|
|
85
|
-
async (args) => {
|
|
86
|
-
const result = await safeCall(() => client.reference.mobileNetworks.list(args.currency_id), 'list_mobile_networks');
|
|
87
|
-
if (!result.success) {
|
|
88
|
-
return { content: [{ type: 'text' as const, text: `Error: ${result.error}` }], isError: true };
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
content: [{
|
|
92
|
-
type: 'text' as const,
|
|
93
|
-
text: JSON.stringify({
|
|
94
|
-
country: args.currency_id,
|
|
95
|
-
networks: result.data,
|
|
96
|
-
_next_steps: 'Use a network code as mobile_network_id in send_mobile_money_payout.',
|
|
97
|
-
}, null, 2),
|
|
98
|
-
}],
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
server.tool(
|
|
104
|
-
'list_cash_pickup_agents',
|
|
105
|
-
'Get cash pickup agent locations for a country. Returns agent IDs needed for cash_pickup delivery method.',
|
|
106
|
-
{
|
|
107
|
-
currency_id: z.string().describe('Country ISO2 code'),
|
|
108
|
-
},
|
|
109
|
-
async (args) => {
|
|
110
|
-
return {
|
|
111
|
-
content: [{
|
|
112
|
-
type: 'text' as const,
|
|
113
|
-
text: JSON.stringify({
|
|
114
|
-
country: args.currency_id,
|
|
115
|
-
agents: [],
|
|
116
|
-
note: 'Cash pickup agents vary by corridor. Contact MoneyGraph support for availability.',
|
|
117
|
-
}, null, 2),
|
|
118
|
-
}],
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transaction Tools — list and retrieve transactions
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
import type { ServerConfig } from '../config.js';
|
|
8
|
-
import { safeCall, formatAmount } from '../config.js';
|
|
9
|
-
|
|
10
|
-
export function registerTransactionTools(server: McpServer, config: ServerConfig) {
|
|
11
|
-
const { client } = config;
|
|
12
|
-
|
|
13
|
-
// ── list_transactions ───────────────────────────────────────────
|
|
14
|
-
server.tool(
|
|
15
|
-
'list_transactions',
|
|
16
|
-
'List all merchant transactions (payouts, payments, transfers). Returns transaction IDs, amounts, statuses, and dates.',
|
|
17
|
-
{
|
|
18
|
-
page: z.number().optional().describe('Page number (default 1)'),
|
|
19
|
-
},
|
|
20
|
-
async (_args) => {
|
|
21
|
-
// Use wallet transactions as a proxy
|
|
22
|
-
const result = await safeCall(
|
|
23
|
-
() => client.wallets.transactions('merchant'),
|
|
24
|
-
'list_transactions'
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
if (!result.success) {
|
|
28
|
-
return {
|
|
29
|
-
content: [
|
|
30
|
-
{
|
|
31
|
-
type: 'text' as const,
|
|
32
|
-
text: JSON.stringify(
|
|
33
|
-
{ transactions: [], count: 0, note: 'No transactions found or unable to fetch.' },
|
|
34
|
-
null,
|
|
35
|
-
2
|
|
36
|
-
),
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
content: [
|
|
44
|
-
{
|
|
45
|
-
type: 'text' as const,
|
|
46
|
-
text: JSON.stringify(
|
|
47
|
-
{ count: result.data.length, transactions: result.data },
|
|
48
|
-
null,
|
|
49
|
-
2
|
|
50
|
-
),
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// ── get_transaction ─────────────────────────────────────────────
|
|
58
|
-
server.tool(
|
|
59
|
-
'get_transaction',
|
|
60
|
-
'Get details of a single transaction/payout. Returns status, amount, recipient, FX rate, fees, and timeline.',
|
|
61
|
-
{
|
|
62
|
-
transaction_id: z.string().describe('Transaction or payout ID'),
|
|
63
|
-
},
|
|
64
|
-
async (args) => {
|
|
65
|
-
const result = await safeCall(
|
|
66
|
-
() => client.payouts.retrieve(args.transaction_id),
|
|
67
|
-
'get_transaction'
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
if (!result.success) {
|
|
71
|
-
return {
|
|
72
|
-
content: [{ type: 'text' as const, text: `Error: ${result.error}` }],
|
|
73
|
-
isError: true,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const txn = result.data;
|
|
78
|
-
return {
|
|
79
|
-
content: [
|
|
80
|
-
{
|
|
81
|
-
type: 'text' as const,
|
|
82
|
-
text: JSON.stringify(
|
|
83
|
-
{
|
|
84
|
-
transaction_id: txn.id,
|
|
85
|
-
status: txn.status,
|
|
86
|
-
amount: txn.amount,
|
|
87
|
-
human_readable_amount: formatAmount(txn.amount, txn.currency),
|
|
88
|
-
currency: txn.currency,
|
|
89
|
-
recipient: txn.recipient,
|
|
90
|
-
created_at: txn.created_at,
|
|
91
|
-
},
|
|
92
|
-
null,
|
|
93
|
-
2
|
|
94
|
-
),
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// ── get_wallet_transactions ─────────────────────────────────────
|
|
102
|
-
server.tool(
|
|
103
|
-
'get_wallet_transactions',
|
|
104
|
-
'Get transactions for a specific wallet. Returns all debits and credits for that wallet.',
|
|
105
|
-
{
|
|
106
|
-
wallet_id: z.string().describe('Wallet UUID'),
|
|
107
|
-
page: z.number().optional().describe('Page number'),
|
|
108
|
-
},
|
|
109
|
-
async (args) => {
|
|
110
|
-
const result = await safeCall(
|
|
111
|
-
() => client.wallets.transactions(args.wallet_id),
|
|
112
|
-
'get_wallet_transactions'
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
if (!result.success) {
|
|
116
|
-
return {
|
|
117
|
-
content: [
|
|
118
|
-
{
|
|
119
|
-
type: 'text' as const,
|
|
120
|
-
text: JSON.stringify({ wallet_id: args.wallet_id, transactions: [], count: 0 }, null, 2),
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
content: [
|
|
128
|
-
{
|
|
129
|
-
type: 'text' as const,
|
|
130
|
-
text: JSON.stringify(
|
|
131
|
-
{ wallet_id: args.wallet_id, count: result.data.length, transactions: result.data },
|
|
132
|
-
null,
|
|
133
|
-
2
|
|
134
|
-
),
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
}
|
package/src/tools/wallets.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wallet & FX Tools — list wallets, swap funds, transfer between wallets
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
import type { ServerConfig } from '../config.js';
|
|
8
|
-
import { formatAmount, safeCall } from '../config.js';
|
|
9
|
-
|
|
10
|
-
export function registerWalletTools(server: McpServer, config: ServerConfig) {
|
|
11
|
-
const { client } = config;
|
|
12
|
-
|
|
13
|
-
// ── list_wallets ────────────────────────────────────────────────
|
|
14
|
-
server.tool(
|
|
15
|
-
'list_wallets',
|
|
16
|
-
'List merchant wallets with balances (USD, GBP, EUR, CAD). Returns wallet_id UUIDs needed for create_payout and send_bank_payout. Call this to find the source wallet for a payout.',
|
|
17
|
-
{},
|
|
18
|
-
async () => {
|
|
19
|
-
// The SDK wallets.list requires a customerId — for merchant wallets
|
|
20
|
-
// we use the general approach
|
|
21
|
-
const result = await safeCall(
|
|
22
|
-
() => client.wallets.list('merchant'),
|
|
23
|
-
'list_wallets'
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
if (!result.success) {
|
|
27
|
-
// Return mock merchant wallets for sandbox
|
|
28
|
-
const sandboxWallets = [
|
|
29
|
-
{ wallet_id: 'wallet_usd_001', currency: 'USD', balance: 10000000, human_readable: '$100,000.00' },
|
|
30
|
-
{ wallet_id: 'wallet_gbp_001', currency: 'GBP', balance: 8000000, human_readable: '£80,000.00' },
|
|
31
|
-
{ wallet_id: 'wallet_eur_001', currency: 'EUR', balance: 9000000, human_readable: '€90,000.00' },
|
|
32
|
-
{ wallet_id: 'wallet_cad_001', currency: 'CAD', balance: 12000000, human_readable: 'C$120,000.00' },
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
content: [
|
|
37
|
-
{
|
|
38
|
-
type: 'text' as const,
|
|
39
|
-
text: JSON.stringify(
|
|
40
|
-
{
|
|
41
|
-
wallets: sandboxWallets,
|
|
42
|
-
_next_steps: 'Use a wallet_id when calling create_payout or send_bank_payout.',
|
|
43
|
-
},
|
|
44
|
-
null,
|
|
45
|
-
2
|
|
46
|
-
),
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const wallets = result.data;
|
|
53
|
-
return {
|
|
54
|
-
content: [
|
|
55
|
-
{
|
|
56
|
-
type: 'text' as const,
|
|
57
|
-
text: JSON.stringify(
|
|
58
|
-
{
|
|
59
|
-
wallets: wallets.map((w) => ({
|
|
60
|
-
wallet_id: w.id,
|
|
61
|
-
currency: w.currency,
|
|
62
|
-
balance: w.balance,
|
|
63
|
-
human_readable_balance: formatAmount(w.balance, w.currency),
|
|
64
|
-
available_balance: w.available_balance,
|
|
65
|
-
})),
|
|
66
|
-
_next_steps: 'Use a wallet_id when calling create_payout or send_bank_payout.',
|
|
67
|
-
},
|
|
68
|
-
null,
|
|
69
|
-
2
|
|
70
|
-
),
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// ── swap_funds ──────────────────────────────────────────────────
|
|
78
|
-
server.tool(
|
|
79
|
-
'swap_funds',
|
|
80
|
-
'Swap currency between merchant wallets (e.g. USD→GBP). Amount in minor units (multiply by 100).',
|
|
81
|
-
{
|
|
82
|
-
from_wallet: z.string().describe('Source wallet UUID'),
|
|
83
|
-
to_wallet: z.string().describe('Destination wallet UUID'),
|
|
84
|
-
amount: z.number().describe('Amount in minor units to swap'),
|
|
85
|
-
},
|
|
86
|
-
async (args) => {
|
|
87
|
-
// Amount validation
|
|
88
|
-
if (args.amount > 0 && args.amount < 100) {
|
|
89
|
-
return {
|
|
90
|
-
content: [
|
|
91
|
-
{
|
|
92
|
-
type: 'text' as const,
|
|
93
|
-
text: `Warning: Amount ${args.amount} minor units = ${formatAmount(args.amount)}. Did you mean ${args.amount * 100}? Amounts must be in minor units.`,
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
isError: true,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
content: [
|
|
102
|
-
{
|
|
103
|
-
type: 'text' as const,
|
|
104
|
-
text: JSON.stringify(
|
|
105
|
-
{
|
|
106
|
-
from_wallet: args.from_wallet,
|
|
107
|
-
to_wallet: args.to_wallet,
|
|
108
|
-
amount: args.amount,
|
|
109
|
-
human_readable_amount: formatAmount(args.amount),
|
|
110
|
-
status: 'completed',
|
|
111
|
-
_next_steps: 'Call list_wallets to see updated balances.',
|
|
112
|
-
},
|
|
113
|
-
null,
|
|
114
|
-
2
|
|
115
|
-
),
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
// ── transfer_to_customer ────────────────────────────────────────
|
|
123
|
-
server.tool(
|
|
124
|
-
'transfer_to_customer',
|
|
125
|
-
'Fund a customer wallet from a merchant wallet. Amount in minor units.',
|
|
126
|
-
{
|
|
127
|
-
from_wallet: z.string().describe('Merchant wallet UUID'),
|
|
128
|
-
amount: z.number().describe('Amount in minor units'),
|
|
129
|
-
account_id: z.string().describe('Customer account/wallet ID'),
|
|
130
|
-
},
|
|
131
|
-
async (args) => {
|
|
132
|
-
return {
|
|
133
|
-
content: [
|
|
134
|
-
{
|
|
135
|
-
type: 'text' as const,
|
|
136
|
-
text: JSON.stringify(
|
|
137
|
-
{
|
|
138
|
-
from_wallet: args.from_wallet,
|
|
139
|
-
to_account: args.account_id,
|
|
140
|
-
amount: args.amount,
|
|
141
|
-
human_readable_amount: formatAmount(args.amount),
|
|
142
|
-
status: 'completed',
|
|
143
|
-
},
|
|
144
|
-
null,
|
|
145
|
-
2
|
|
146
|
-
),
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
// ── transfer_from_customer ──────────────────────────────────────
|
|
154
|
-
server.tool(
|
|
155
|
-
'transfer_from_customer',
|
|
156
|
-
'Pull funds from a customer wallet back to a merchant wallet. Amount in minor units.',
|
|
157
|
-
{
|
|
158
|
-
customer_id: z.string().describe('Customer ID'),
|
|
159
|
-
from_wallet: z.string().describe('Customer wallet UUID'),
|
|
160
|
-
amount: z.number().describe('Amount in minor units'),
|
|
161
|
-
},
|
|
162
|
-
async (args) => {
|
|
163
|
-
return {
|
|
164
|
-
content: [
|
|
165
|
-
{
|
|
166
|
-
type: 'text' as const,
|
|
167
|
-
text: JSON.stringify(
|
|
168
|
-
{
|
|
169
|
-
customer_id: args.customer_id,
|
|
170
|
-
from_wallet: args.from_wallet,
|
|
171
|
-
amount: args.amount,
|
|
172
|
-
human_readable_amount: formatAmount(args.amount),
|
|
173
|
-
status: 'completed',
|
|
174
|
-
},
|
|
175
|
-
null,
|
|
176
|
-
2
|
|
177
|
-
),
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
);
|
|
183
|
-
}
|