@moneygraph/mcp-server 1.1.2 → 2.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.
Files changed (115) hide show
  1. package/README.md +74 -224
  2. package/bin/mcp-http.js +6 -8
  3. package/bin/mcp-server.js +3 -4
  4. package/package.json +23 -52
  5. package/src/config.js +50 -0
  6. package/src/http.js +32 -0
  7. package/src/index.js +20 -0
  8. package/src/prompts.js +80 -0
  9. package/src/resources.js +54 -0
  10. package/src/server.js +36 -0
  11. package/src/tools.js +250 -0
  12. package/dist/config.d.ts +0 -28
  13. package/dist/config.d.ts.map +0 -1
  14. package/dist/config.js +0 -52
  15. package/dist/config.js.map +0 -1
  16. package/dist/http.d.ts +0 -15
  17. package/dist/http.d.ts.map +0 -1
  18. package/dist/http.js +0 -104
  19. package/dist/http.js.map +0 -1
  20. package/dist/index.d.ts +0 -18
  21. package/dist/index.d.ts.map +0 -1
  22. package/dist/index.js +0 -164
  23. package/dist/index.js.map +0 -1
  24. package/dist/prompts/check-rates.d.ts +0 -6
  25. package/dist/prompts/check-rates.d.ts.map +0 -1
  26. package/dist/prompts/check-rates.js +0 -29
  27. package/dist/prompts/check-rates.js.map +0 -1
  28. package/dist/prompts/crypto-deposit.d.ts +0 -6
  29. package/dist/prompts/crypto-deposit.d.ts.map +0 -1
  30. package/dist/prompts/crypto-deposit.js +0 -36
  31. package/dist/prompts/crypto-deposit.js.map +0 -1
  32. package/dist/prompts/issue-card.d.ts +0 -6
  33. package/dist/prompts/issue-card.d.ts.map +0 -1
  34. package/dist/prompts/issue-card.js +0 -33
  35. package/dist/prompts/issue-card.js.map +0 -1
  36. package/dist/prompts/onboard-customer.d.ts +0 -6
  37. package/dist/prompts/onboard-customer.d.ts.map +0 -1
  38. package/dist/prompts/onboard-customer.js +0 -31
  39. package/dist/prompts/onboard-customer.js.map +0 -1
  40. package/dist/prompts/payout-status.d.ts +0 -6
  41. package/dist/prompts/payout-status.d.ts.map +0 -1
  42. package/dist/prompts/payout-status.js +0 -29
  43. package/dist/prompts/payout-status.js.map +0 -1
  44. package/dist/prompts/send-money.d.ts +0 -6
  45. package/dist/prompts/send-money.d.ts.map +0 -1
  46. package/dist/prompts/send-money.js +0 -34
  47. package/dist/prompts/send-money.js.map +0 -1
  48. package/dist/resources/corridors.d.ts +0 -8
  49. package/dist/resources/corridors.d.ts.map +0 -1
  50. package/dist/resources/corridors.js +0 -137
  51. package/dist/resources/corridors.js.map +0 -1
  52. package/dist/resources/status.d.ts +0 -7
  53. package/dist/resources/status.d.ts.map +0 -1
  54. package/dist/resources/status.js +0 -32
  55. package/dist/resources/status.js.map +0 -1
  56. package/dist/resources/wallets.d.ts +0 -7
  57. package/dist/resources/wallets.d.ts.map +0 -1
  58. package/dist/resources/wallets.js +0 -37
  59. package/dist/resources/wallets.js.map +0 -1
  60. package/dist/tools/cards.d.ts +0 -10
  61. package/dist/tools/cards.d.ts.map +0 -1
  62. package/dist/tools/cards.js +0 -229
  63. package/dist/tools/cards.js.map +0 -1
  64. package/dist/tools/crypto.d.ts +0 -10
  65. package/dist/tools/crypto.d.ts.map +0 -1
  66. package/dist/tools/crypto.js +0 -265
  67. package/dist/tools/crypto.js.map +0 -1
  68. package/dist/tools/currencies.d.ts +0 -10
  69. package/dist/tools/currencies.d.ts.map +0 -1
  70. package/dist/tools/currencies.js +0 -137
  71. package/dist/tools/currencies.js.map +0 -1
  72. package/dist/tools/customers.d.ts +0 -7
  73. package/dist/tools/customers.d.ts.map +0 -1
  74. package/dist/tools/customers.js +0 -311
  75. package/dist/tools/customers.js.map +0 -1
  76. package/dist/tools/directors.d.ts +0 -7
  77. package/dist/tools/directors.d.ts.map +0 -1
  78. package/dist/tools/directors.js +0 -148
  79. package/dist/tools/directors.js.map +0 -1
  80. package/dist/tools/fx.d.ts +0 -10
  81. package/dist/tools/fx.d.ts.map +0 -1
  82. package/dist/tools/fx.js +0 -193
  83. package/dist/tools/fx.js.map +0 -1
  84. package/dist/tools/ledger.d.ts +0 -7
  85. package/dist/tools/ledger.d.ts.map +0 -1
  86. package/dist/tools/ledger.js +0 -101
  87. package/dist/tools/ledger.js.map +0 -1
  88. package/dist/tools/payments.d.ts +0 -7
  89. package/dist/tools/payments.d.ts.map +0 -1
  90. package/dist/tools/payments.js +0 -93
  91. package/dist/tools/payments.js.map +0 -1
  92. package/dist/tools/payouts.d.ts +0 -10
  93. package/dist/tools/payouts.d.ts.map +0 -1
  94. package/dist/tools/payouts.js +0 -352
  95. package/dist/tools/payouts.js.map +0 -1
  96. package/dist/tools/recipients.d.ts +0 -7
  97. package/dist/tools/recipients.d.ts.map +0 -1
  98. package/dist/tools/recipients.js +0 -150
  99. package/dist/tools/recipients.js.map +0 -1
  100. package/dist/tools/recurring.d.ts +0 -7
  101. package/dist/tools/recurring.d.ts.map +0 -1
  102. package/dist/tools/recurring.js +0 -94
  103. package/dist/tools/recurring.js.map +0 -1
  104. package/dist/tools/reference.d.ts +0 -7
  105. package/dist/tools/reference.d.ts.map +0 -1
  106. package/dist/tools/reference.js +0 -83
  107. package/dist/tools/reference.js.map +0 -1
  108. package/dist/tools/transactions.d.ts +0 -7
  109. package/dist/tools/transactions.d.ts.map +0 -1
  110. package/dist/tools/transactions.js +0 -88
  111. package/dist/tools/transactions.js.map +0 -1
  112. package/dist/tools/wallets.d.ts +0 -7
  113. package/dist/tools/wallets.d.ts.map +0 -1
  114. package/dist/tools/wallets.js +0 -129
  115. package/dist/tools/wallets.js.map +0 -1
package/README.md CHANGED
@@ -1,42 +1,48 @@
1
- # MoneyGraph MCP Server
1
+ # @moneygraph/mcp-server
2
2
 
3
- **Send money to 82+ countries from any AI agent.** Built by [MoneyGraph.ai](https://moneygraph.ai).
3
+ MCP server for the [MoneyGraph API](https://app.moneygraph.ai/docs/guide/introduction). Lets Claude, Cursor, Windsurf, VS Code, Cline, and any MCP client call cross-border payouts, FX swaps, virtual cards, virtual accounts, invoices, and payment collection as native tools.
4
4
 
5
- The first MCP server for real cross-border money movement. 328 FX pairs, 4 base currencies, bank transfers, mobile money, SWIFT, virtual cards and crypto — all through natural language.
5
+ Wraps `@moneygraph/sdk` v4+. All requests are HMAC-signed with per-request idempotency keys. One base URL for test and live — the key ID decides the mode.
6
6
 
7
+ - **40+ tools** covering the full API, plus an `mg_request` escape hatch
8
+ - **4 live-state resources** (assets, countries, transfer purposes, customers)
9
+ - **6 flow prompts** (send_money, onboard_customer, check_corridor, track_payout, issue_card, collect_payment)
10
+ - stdio and HTTP transports
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install -g @moneygraph/mcp-server
7
16
  ```
8
- npx @moneygraph/mcp-server
17
+
18
+ Or run on demand with `npx`:
19
+
20
+ ```bash
21
+ npx -y @moneygraph/mcp-server
9
22
  ```
10
23
 
11
- ## Quick Start
24
+ Requires Node.js 18+.
12
25
 
13
- ### Claude Desktop
26
+ ## Configuration
14
27
 
15
- Add to your `claude_desktop_config.json`:
28
+ Create a key in the dashboard: https://app.moneygraph.ai → **Developers → API keys**. Set:
16
29
 
17
- ```json
18
- {
19
- "mcpServers": {
20
- "moneygraph": {
21
- "command": "npx",
22
- "args": ["-y", "@moneygraph/mcp-server"],
23
- "env": {
24
- "MONEYGRAPH_API_KEY": "sk_sandbox_demo"
25
- }
26
- }
27
- }
28
- }
30
+ ```bash
31
+ export MG_KEY_ID=kid_...
32
+ export MG_SECRET=... # 64 chars, shown once at creation
29
33
  ```
30
34
 
31
- ### Claude Code
35
+ Optional:
32
36
 
33
37
  ```bash
34
- claude mcp add moneygraph -- npx -y @moneygraph/mcp-server
38
+ export MG_BASE_URL=https://app.moneygraph.ai/api/v1 # default
39
+ export MONEYGRAPH_TRANSPORT=http # default: stdio
40
+ export PORT=3200 # HTTP mode only
35
41
  ```
36
42
 
37
- ### Cursor
43
+ ## Use with Claude Desktop
38
44
 
39
- Add to `.cursor/mcp.json`:
45
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
40
46
 
41
47
  ```json
42
48
  {
@@ -45,222 +51,66 @@ Add to `.cursor/mcp.json`:
45
51
  "command": "npx",
46
52
  "args": ["-y", "@moneygraph/mcp-server"],
47
53
  "env": {
48
- "MONEYGRAPH_API_KEY": "sk_sandbox_demo"
54
+ "MG_KEY_ID": "kid_...",
55
+ "MG_SECRET": "..."
49
56
  }
50
57
  }
51
58
  }
52
59
  }
53
60
  ```
54
61
 
55
- ### VS Code
62
+ Restart Claude Desktop. The `send_money`, `onboard_customer`, and `collect_payment` prompts appear in the + menu.
56
63
 
57
- Add to `.vscode/settings.json`:
64
+ ## Use with Cursor / VS Code / Windsurf / Cline
58
65
 
59
- ```json
60
- {
61
- "mcp.servers": {
62
- "moneygraph": {
63
- "command": "npx",
64
- "args": ["-y", "@moneygraph/mcp-server"],
65
- "env": {
66
- "MONEYGRAPH_API_KEY": "sk_sandbox_demo"
67
- }
68
- }
69
- }
70
- }
71
- ```
72
-
73
- ## Demo
74
-
75
- > **You:** Send $500 to Friday Okoro at GTBank Nigeria, account 0123456789
76
-
77
- > **Claude:**
78
- > 1. Looked up USD→NGN corridor — rate: 1,580.50, fee: 1.5%
79
- > 2. Created recipient at GTBank (SWIFT: GTBINGLA)
80
- > 3. Created payout for 50000 minor units ($500.00)
81
- > 4. ✅ Transaction `txn_abc123` — estimated delivery: 1-2 business days
82
-
83
- All without writing a single line of code.
84
-
85
- ## Tools (77)
86
-
87
- ### Customers
88
- | Tool | Description |
89
- |------|-------------|
90
- | `create_customer` | Create a personal customer |
91
- | `create_business_customer` | Create a business customer with company details |
92
- | `get_customer` | Get customer details by ID |
93
- | `list_customers` | List all customers |
94
- | `update_customer` | Update customer KYC data |
95
- | `submit_kyc` | Submit KYC for review (auto-approves in sandbox) |
96
- | `get_customer_wallets` | Get wallets for a customer |
97
- | `check_kyc_status` | Check KYC status and whether the customer can make payouts |
98
- | `upload_kyc_document` | Upload a KYC document (ID, proof of address, etc.) |
99
- | `create_mock_customer` | Sandbox only: create a pre-configured test customer |
100
-
101
- ### Directors (KYB)
102
- | Tool | Description |
103
- |------|-------------|
104
- | `create_director` | Add a director to a business customer |
105
- | `list_directors` | List directors for a customer |
106
- | `update_director` | Update director details |
107
- | `delete_director` | Remove a director |
108
-
109
- ### Currencies & Rates
110
- | Tool | Description |
111
- |------|-------------|
112
- | `get_currencies` | **THE critical tool** — returns FX rates, corridor UUIDs, delivery windows, fees, limits |
113
- | `list_countries` | List all supported countries |
114
- | `list_account_fiat_currencies` | Fiat currencies available on your account |
115
- | `list_account_crypto_currencies` | Crypto currencies available on your account |
116
-
117
- ### FX & Smart Payouts
118
- | Tool | Description |
119
- |------|-------------|
120
- | `get_fx_quote` | Live FX quote for a currency pair (expires in 2 minutes) |
121
- | `confirm_fx_quote` | Lock a quoted rate for the payout |
122
- | `get_exchange_rates` | All current FX rates across supported pairs |
123
- | `smart_payout` | **HERO** — picks the best rail (local bank, SWIFT or mobile money) automatically |
124
- | `send_swift_payout` | International wire transfer via SWIFT |
125
-
126
- ### Recipients
127
- | Tool | Description |
128
- |------|-------------|
129
- | `create_recipient` | Create a payment recipient |
130
- | `list_recipients` | List all recipients |
131
- | `get_recipient` | Get recipient details |
132
- | `update_recipient` | Update recipient |
133
- | `delete_recipient` | Delete recipient |
134
-
135
- ### Payouts
136
- | Tool | Description |
137
- |------|-------------|
138
- | `create_payout` | Create a payout to an existing recipient |
139
- | `send_bank_payout` | **HERO** — one-call bank transfer (creates recipient + payout) |
140
- | `send_mobile_money_payout` | **HERO** — one-call mobile money transfer |
141
- | `simulate_payout_success` | Sandbox: mark payout as successful |
142
- | `simulate_payout_decline` | Sandbox: mark payout as declined |
143
- | `verify_bank` | Verify a bank by routing code |
144
-
145
- ### Wallets
146
- | Tool | Description |
147
- |------|-------------|
148
- | `list_wallets` | List merchant wallets with balances |
149
- | `swap_funds` | Swap currency between wallets |
150
- | `transfer_to_customer` | Fund a customer wallet |
151
- | `transfer_from_customer` | Pull funds from customer |
152
-
153
- ### Payments
154
- | Tool | Description |
155
- |------|-------------|
156
- | `initiate_payment` | Start collecting a payment (returns checkout URL) |
157
- | `verify_payment` | Check payment status |
158
-
159
- ### Recurring Plans
160
- | Tool | Description |
161
- |------|-------------|
162
- | `create_plan` | Create a recurring payment plan |
163
- | `list_plans` | List all plans |
164
- | `get_plan` | Get plan details |
165
- | `update_plan` | Update a plan |
166
- | `delete_plan` | Delete a plan |
167
-
168
- ### Transactions
169
- | Tool | Description |
170
- |------|-------------|
171
- | `list_transactions` | List all transactions |
172
- | `get_transaction` | Get transaction details |
173
- | `get_wallet_transactions` | Get transactions for a wallet |
174
-
175
- ### Reference Data
176
- | Tool | Description |
177
- |------|-------------|
178
- | `list_transfer_purposes` | Transfer purpose codes |
179
- | `list_source_of_funds` | Source of funds options |
180
- | `list_mcc_codes` | MCC codes for businesses |
181
- | `list_business_registration_types` | Business registration types |
182
- | `list_mobile_networks` | Mobile money networks by country |
183
- | `list_cash_pickup_agents` | Cash pickup agents by country |
184
-
185
- ### Virtual Cards
186
- | Tool | Description |
187
- |------|-------------|
188
- | `create_card` | Issue a virtual or physical debit card (requires approved KYC) |
189
- | `get_card` | Card details, balance, status and masked card number |
190
- | `list_cards` | List all cards for a customer |
191
- | `fund_card` | Add funds to a card from a wallet |
192
- | `freeze_card` | Temporarily freeze a card |
193
- | `unfreeze_card` | Unfreeze a card |
194
- | `cancel_card` | Permanently cancel a card (balance returns to the wallet) |
195
- | `get_card_transactions` | Card transaction history |
196
-
197
- ### Crypto
198
- | Tool | Description |
199
- |------|-------------|
200
- | `create_crypto_address` | Deposit address for USDC, USDT, BTC or ETH on Ethereum, Tron, Polygon, Base or Solana |
201
- | `list_crypto_addresses` | List a customer's deposit addresses |
202
- | `get_crypto_address` | Get one deposit address |
203
- | `list_crypto_deposits` | List deposits with confirmation status and transaction hashes |
204
- | `get_crypto_deposit` | Get one deposit |
205
- | `get_crypto_settings` | Auto-convert and accepted-currency settings |
206
- | `update_crypto_settings` | Change auto-convert and accepted currencies |
207
- | `crypto_convert_quote` | Quote a crypto ↔ fiat conversion (expires in 2 minutes) |
208
- | `crypto_convert_execute` | Execute a quoted conversion |
209
- | `send_crypto_payout` | Send crypto to an external wallet (requires approved KYC) |
210
-
211
- ### Blockchain Ledger
212
- | Tool | Description |
213
- |------|-------------|
214
- | `create_ledger_entity` | Create an on-chain audit entity |
215
- | `get_ledger_entity` | Get entity details |
216
- | `ledger_credit` | Credit an entity |
217
- | `ledger_debit` | Debit an entity |
218
- | `ledger_transfer` | Transfer between entities |
219
-
220
- ## Resources (6)
221
-
222
- | URI | Description |
223
- |-----|-------------|
224
- | `moneygraph://status` | Server mode, API health, rate limits |
225
- | `moneygraph://wallets` | Live wallet balances (USD, GBP, EUR, CAD) |
226
- | `moneygraph://rates/{base}` | All FX rates from a base currency |
227
- | `moneygraph://rates/{from}/{to}` | Specific corridor rate |
228
- | `moneygraph://corridors/{base}` | Remittance corridors with UUIDs |
229
- | `moneygraph://delivery-windows/{currency}` | Delivery windows and speeds |
230
-
231
- ## Prompts (6)
232
-
233
- | Prompt | Description |
234
- |--------|-------------|
235
- | `send-money` | Guided cross-border payment flow |
236
- | `onboard-customer` | Customer creation + KYC walkthrough |
237
- | `check-rates` | FX rate comparison |
238
- | `track-payout` | Payout status check |
239
- | `issue-card` | Guided card issuance |
240
- | `crypto-deposit` | Guided crypto deposit setup and tracking |
66
+ The same block goes into each client's `mcp` config. See each client's docs.
241
67
 
242
- ## Configuration
243
-
244
- | Variable | Description | Default |
245
- |----------|-------------|---------|
246
- | `MONEYGRAPH_API_KEY` | Your MoneyGraph API key | Sandbox mode |
68
+ ## HTTP mode
247
69
 
248
- - **No key** or `sk_sandbox_*` / `sk_test_*` → Sandbox mode (in-memory data, auto-KYC, test rates)
249
- - `sk_live_*` → Production mode (real money, real compliance, 30 req/min)
70
+ For web clients or hosted deployments:
250
71
 
251
- ## Key Concepts
72
+ ```bash
73
+ MONEYGRAPH_TRANSPORT=http MG_KEY_ID=... MG_SECRET=... moneygraph-mcp-http
74
+ # → MoneyGraph MCP server listening on http://0.0.0.0:3200/mcp
75
+ ```
252
76
 
253
- - **Amounts are in minor units**: $500.00 = `50000`. Always multiply by 100.
254
- - **Two-step payout flow**: Create recipient → Create payout. Or use `send_bank_payout` / `send_mobile_money_payout` for one step.
255
- - **`get_currencies` first**: Always call this before any payout to get corridor UUIDs and delivery window UUIDs.
256
- - **KYC required**: Only APPROVED customers can send payouts. In sandbox, `submit_kyc` auto-approves.
77
+ Deploy to Railway, Fly, Render — the included `railway.json` has defaults.
78
+
79
+ ## Tool index
80
+
81
+ | Category | Tools |
82
+ |---|---|
83
+ | Lookups | `mg_list_countries`, `mg_list_assets`, `mg_list_mccs`, `mg_list_source_of_funds`, `mg_list_business_registration_types`, `mg_list_transfer_purposes` |
84
+ | Customers | `mg_create_customer`, `mg_list_customers`, `mg_get_customer`, `mg_get_customer_assets`, `mg_generate_kyc_link`, `mg_submit_kyc` |
85
+ | Counterparties | `mg_create_counterparty`, `mg_list_counterparties`, `mg_get_counterparty`, `mg_delete_counterparty` |
86
+ | Files | `mg_create_file`, `mg_list_files`, `mg_get_file` |
87
+ | Quotes & payouts | `mg_create_quote`, `mg_fund_quote`, `mg_list_quotes`, `mg_get_quote` |
88
+ | Transfers | `mg_transfer_asset` |
89
+ | Transactions | `mg_list_transactions`, `mg_get_transaction` |
90
+ | Virtual accounts | `mg_create_virtual_account`, `mg_list_virtual_accounts`, `mg_get_virtual_account` |
91
+ | Crypto wallets | `mg_create_crypto_wallet`, `mg_list_crypto_wallets`, `mg_get_crypto_wallet` |
92
+ | Cards | `mg_create_cardholder`, `mg_create_card`, `mg_list_cards`, `mg_get_card`, `mg_fund_card`, `mg_withdraw_card`, `mg_activate_card`, `mg_deactivate_card`, `mg_fetch_card_balance` |
93
+ | Payment collection | `mg_create_payment_session`, `mg_verify_payment` |
94
+ | Invoices | `mg_create_invoice`, `mg_list_invoices`, `mg_get_invoice`, `mg_create_invoice_recipient`, `mg_list_invoice_recipients` |
95
+ | Test simulators (test keys only) | `mg_test_approve_kyc`, `mg_test_approve_cardholder`, `mg_test_approve_virtual_account_holder`, `mg_test_payout_success`, `mg_test_payout_decline`, `mg_test_swap_success`, `mg_test_swap_decline`, `mg_test_virtual_account`, `mg_test_crypto_wallet`, `mg_test_online_card_transaction` |
96
+ | Escape hatch | `mg_request` — any method + path |
97
+
98
+ ## Key facts for AI agents
99
+
100
+ The server's instructions tell the model:
101
+
102
+ - Amounts are **plain numbers in the source currency** — not minor units × 100.
103
+ - Payouts are **two-step**: `mg_create_quote` → `mg_fund_quote`. Quotes expire in 10 minutes.
104
+ - Dates in customer bodies are **DD-MM-YYYY**.
105
+ - `account_id` is an opaque string; everything else (`wallet_id`, `rail_id`, `counterparty_id`, `quote_id`, `file_id`) is a UUID.
106
+ - Errors return `{ok:false, code, http_status, field_errors}`. Branch on `code`.
257
107
 
258
108
  ## Links
259
109
 
260
- - [MoneyGraph Docs](https://docs.moneygraph.ai)
261
- - [MoneyGraph SDK](https://www.npmjs.com/package/@moneygraph/sdk)
262
- - [MoneyGraph Dashboard](https://app.moneygraph.ai)
263
- - [Pricing](https://moneygraph.ai/pricing)
110
+ - API docs: https://app.moneygraph.ai/docs/guide/introduction
111
+ - Dashboard: https://app.moneygraph.ai
112
+ - SDK (wrapped by this server): https://www.npmjs.com/package/@moneygraph/sdk
113
+ - Issues: https://github.com/moneygraph/mcp-server/issues
264
114
 
265
115
  ## License
266
116
 
package/bin/mcp-http.js CHANGED
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env node
2
-
3
2
  process.env.MONEYGRAPH_TRANSPORT = 'http';
4
-
5
- import { startServer } from '../dist/index.js';
6
-
7
- startServer().catch((error) => {
8
- console.error('Fatal: Failed to start MoneyGraph MCP HTTP Server:', error.message);
9
- process.exit(1);
10
- });
3
+ import('../src/index.js').then(({ startServer }) =>
4
+ startServer().catch((err) => {
5
+ console.error('MoneyGraph MCP server (HTTP) failed to start:', err instanceof Error ? err.message : err);
6
+ process.exit(1);
7
+ }),
8
+ );
package/bin/mcp-server.js CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import { startServer } from '../src/index.js';
2
3
 
3
- import { startServer } from '../dist/index.js';
4
-
5
- startServer().catch((error) => {
6
- console.error('Fatal: Failed to start MoneyGraph MCP Server:', error.message);
4
+ startServer().catch((err) => {
5
+ console.error('MoneyGraph MCP server failed to start:', err instanceof Error ? err.message : err);
7
6
  process.exit(1);
8
7
  });
package/package.json CHANGED
@@ -1,70 +1,41 @@
1
1
  {
2
2
  "name": "@moneygraph/mcp-server",
3
- "version": "1.1.2",
4
- "description": "MoneyGraph.ai MCP server for cross-border payments, cards, and crypto — 77 tools, 82+ countries via Claude, Cursor, VS Code",
3
+ "version": "2.0.0",
4
+ "description": "MoneyGraph MCP server — cross-border payouts, FX swaps, virtual cards, virtual accounts, invoices, and payment collection for AI agents. Wraps @moneygraph/sdk.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "@moneygraph/mcp-server": "./bin/mcp-server.js",
8
8
  "moneygraph-mcp": "./bin/mcp-server.js",
9
9
  "moneygraph-mcp-http": "./bin/mcp-http.js"
10
10
  },
11
- "files": [
12
- "dist/",
13
- "bin/",
14
- "README.md",
15
- "railway.json"
16
- ],
17
- "main": "./dist/index.js",
18
- "types": "./dist/index.d.ts",
19
- "scripts": {
20
- "start": "node dist/index.js",
21
- "start:http": "MONEYGRAPH_TRANSPORT=http node dist/index.js"
11
+ "files": ["src/", "bin/", "README.md", "LICENSE", "railway.json"],
12
+ "main": "./src/index.js",
13
+ "exports": {
14
+ ".": { "import": "./src/index.js" }
22
15
  },
23
- "engines": {
24
- "node": ">=18"
16
+ "scripts": {
17
+ "start": "node bin/mcp-server.js",
18
+ "start:http": "node bin/mcp-http.js",
19
+ "test": "node test/smoke.mjs"
25
20
  },
21
+ "engines": { "node": ">=18" },
26
22
  "keywords": [
27
- "mcp",
28
- "model-context-protocol",
29
- "payments",
30
- "cross-border",
31
- "remittance",
32
- "moneygraph",
33
- "ai-agent",
34
- "claude",
35
- "fintech",
36
- "payout",
37
- "fx",
38
- "mobile-money",
39
- "swift",
40
- "africa",
41
- "virtual-cards",
42
- "card-issuance",
43
- "crypto",
44
- "usdc",
45
- "usdt",
46
- "bitcoin",
47
- "ethereum",
48
- "stablecoin"
23
+ "mcp", "model-context-protocol", "mcp-server",
24
+ "moneygraph", "moneygraph-mcp",
25
+ "payments", "payouts", "cross-border", "remittance",
26
+ "fx", "currency-swap", "mobile-money", "swift", "sepa", "ach",
27
+ "virtual-cards", "virtual-accounts", "invoicing", "payment-collection",
28
+ "ai-agent", "claude", "cursor", "windsurf", "cline",
29
+ "fintech", "africa"
49
30
  ],
50
- "author": "MoneyGraph <support@moneygraph.ai>",
31
+ "author": "MoneyGraph <dev@moneygraph.ai>",
51
32
  "license": "MIT",
52
- "homepage": "https://moneygraph.ai",
53
- "repository": {
54
- "type": "git",
55
- "url": "https://github.com/moneygraph/mcp-server"
56
- },
57
- "bugs": {
58
- "url": "https://github.com/moneygraph/mcp-server/issues"
59
- },
33
+ "homepage": "https://app.moneygraph.ai/docs/guide/introduction",
34
+ "repository": { "type": "git", "url": "git+https://github.com/moneygraph/mcp-server.git" },
35
+ "bugs": { "url": "https://github.com/moneygraph/mcp-server/issues" },
60
36
  "dependencies": {
61
37
  "@modelcontextprotocol/sdk": "^1.26.0",
62
- "@moneygraph/sdk": "^3.1.1",
38
+ "@moneygraph/sdk": "^4.0.3",
63
39
  "zod": "^3.23.0"
64
- },
65
- "devDependencies": {
66
- "@types/node": "^20.0.0",
67
- "tsx": "^4.21.0",
68
- "typescript": "^5.5.0"
69
40
  }
70
41
  }
package/src/config.js ADDED
@@ -0,0 +1,50 @@
1
+ // Config loader + shared helpers.
2
+
3
+ import { MoneyGraphClient, MoneyGraphError } from '@moneygraph/sdk';
4
+
5
+ export function loadConfig() {
6
+ const keyId = process.env.MG_KEY_ID || process.env.MONEYGRAPH_KEY_ID;
7
+ const secret = process.env.MG_SECRET || process.env.MONEYGRAPH_SECRET;
8
+ const baseUrl = process.env.MG_BASE_URL || process.env.MONEYGRAPH_BASE_URL;
9
+ if (!keyId || !secret) {
10
+ throw new Error(
11
+ 'MoneyGraph MCP server needs MG_KEY_ID and MG_SECRET environment variables. ' +
12
+ 'Create a key in https://app.moneygraph.ai under Developers > API keys.'
13
+ );
14
+ }
15
+ const client = new MoneyGraphClient({
16
+ keyId, secret, baseUrl,
17
+ userAgent: `@moneygraph/mcp-server/${MCP_VERSION}`,
18
+ });
19
+ const mode = keyId.startsWith('kid_') ? 'live-or-test' : 'unknown';
20
+ return { client, keyId, mode };
21
+ }
22
+
23
+ export const MCP_VERSION = '2.0.0';
24
+
25
+ // Wrap an SDK call so a thrown MoneyGraphError becomes an MCP tool result
26
+ // with the error details captured, instead of crashing the transport.
27
+ export async function safeCall(fn) {
28
+ try {
29
+ const data = await fn();
30
+ return { ok: true, data };
31
+ } catch (e) {
32
+ if (e instanceof MoneyGraphError) {
33
+ return {
34
+ ok: false,
35
+ error: e.message,
36
+ code: e.code,
37
+ http_status: e.httpStatus,
38
+ field_errors: e.errors || undefined,
39
+ };
40
+ }
41
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
42
+ }
43
+ }
44
+
45
+ export function toMcpResult(result) {
46
+ return {
47
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
48
+ isError: result.ok === false,
49
+ };
50
+ }
package/src/http.js ADDED
@@ -0,0 +1,32 @@
1
+ // HTTP (streamable) transport for web clients.
2
+
3
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
4
+ import { createServer } from 'node:http';
5
+ import { randomUUID } from 'node:crypto';
6
+
7
+ const PORT = parseInt(process.env.PORT || process.env.MCP_HTTP_PORT || '3200', 10);
8
+ const PATH = process.env.MCP_HTTP_PATH || '/mcp';
9
+
10
+ export async function startHttp(mcpServer) {
11
+ const transport = new StreamableHTTPServerTransport({
12
+ sessionIdGenerator: () => randomUUID(),
13
+ });
14
+ await mcpServer.connect(transport);
15
+
16
+ const http = createServer(async (req, res) => {
17
+ if (req.url?.split('?')[0] !== PATH) {
18
+ res.writeHead(404).end('not found');
19
+ return;
20
+ }
21
+ try {
22
+ await transport.handleRequest(req, res);
23
+ } catch (e) {
24
+ if (!res.headersSent) res.writeHead(500);
25
+ res.end(JSON.stringify({ error: e instanceof Error ? e.message : String(e) }));
26
+ }
27
+ });
28
+
29
+ await new Promise((r) => http.listen(PORT, r));
30
+ console.error(`MoneyGraph MCP server listening on http://0.0.0.0:${PORT}${PATH}`);
31
+ return http;
32
+ }
package/src/index.js ADDED
@@ -0,0 +1,20 @@
1
+ // Entrypoint — picks transport based on MONEYGRAPH_TRANSPORT env.
2
+ // Default: stdio (Claude Desktop, Cursor, VS Code).
3
+ // MONEYGRAPH_TRANSPORT=http: HTTP transport for web clients.
4
+
5
+ import { buildServer } from './server.js';
6
+
7
+ export async function startServer() {
8
+ const transport = (process.env.MONEYGRAPH_TRANSPORT || 'stdio').toLowerCase();
9
+ const { server } = buildServer();
10
+
11
+ if (transport === 'http') {
12
+ const { startHttp } = await import('./http.js');
13
+ return startHttp(server);
14
+ }
15
+
16
+ const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
17
+ const t = new StdioServerTransport();
18
+ await server.connect(t);
19
+ // stdio stays open until the parent closes stdin
20
+ }
package/src/prompts.js ADDED
@@ -0,0 +1,80 @@
1
+ // Common-flow prompts the AI agent can offer to the end-user.
2
+
3
+ export function registerPrompts(server) {
4
+ const P = (name, description, args, body) =>
5
+ server.registerPrompt(name, { description, argsSchema: args }, async (a) => ({
6
+ messages: [{ role: 'user', content: { type: 'text', text: body(a) } }],
7
+ }));
8
+
9
+ P('send_money',
10
+ 'Walk through creating a cross-border payout: pick corridor, save recipient, quote, fund.',
11
+ {
12
+ destination_country: { description: 'ISO2 country code (e.g. "NG")', required: true },
13
+ amount: { description: 'Amount in source currency (e.g. 100)', required: true },
14
+ source_currency: { description: 'USD, GBP, EUR or CAD', required: false },
15
+ },
16
+ (a) => `I want to send ${a.amount} ${a.source_currency || 'USD'} to ${a.destination_country}.
17
+
18
+ Please help me:
19
+ 1. Call mg_list_assets to find the source wallet + the correct rail_id for ${a.destination_country}.
20
+ 2. If I don't have a saved recipient yet, call mg_create_counterparty with rail_id, country, entity_type, and the recipient's bank details (ask me if needed).
21
+ 3. Call mg_create_quote with type="fiat_payout", counterparty_id, asset_id (source), amount=${a.amount}.
22
+ 4. Show me the quote (rate, fees, destination amount). I'll confirm before funding.
23
+ 5. Call mg_fund_quote with the quote_id, my external_id, and a transfer_purpose from mg_list_transfer_purposes.`);
24
+
25
+ P('onboard_customer',
26
+ 'Create a customer and run them through KYC.',
27
+ {
28
+ type: { description: 'personal or business', required: true },
29
+ country: { description: 'ISO2 country (e.g. "US")', required: true },
30
+ },
31
+ (a) => `Onboard a new ${a.type} customer in ${a.country}.
32
+
33
+ Steps:
34
+ 1. If personal: call mg_list_source_of_funds first; I'll pick one.
35
+ If business: call mg_list_business_registration_types and mg_list_mccs; I'll pick.
36
+ 2. Call mg_create_customer with the full body (ask me field by field).
37
+ 3. Options for KYC:
38
+ (a) call mg_generate_kyc_link so the customer completes KYC themselves, OR
39
+ (b) ask me for docs (base64) and call mg_submit_kyc directly.
40
+ 4. In test mode, call mg_test_approve_kyc to approve instantly.
41
+ 5. Call mg_get_customer to confirm status.`);
42
+
43
+ P('check_corridor',
44
+ 'Look up rates, fees and limits for a payout corridor before committing.',
45
+ {
46
+ destination_country: { description: 'ISO2 country code', required: true },
47
+ source_currency: { description: 'USD, GBP, EUR or CAD', required: false },
48
+ },
49
+ (a) => `Show me the live rates and fees for sending ${a.source_currency || 'USD'} to ${a.destination_country}.
50
+
51
+ Call mg_list_assets and find the entry whose settings.payout.rails[*].supported_countries includes "${a.destination_country}". For each matching rail, report: rail name, method (bank/mobile/cash), duration, min/max limits, fee (flat + percent + VAT), FX margin, and whether supporting docs or specific purpose codes are required.`);
52
+
53
+ P('track_payout',
54
+ 'Check the current state of a payout.',
55
+ { reference: { description: 'Transaction ID or external_id', required: true } },
56
+ (a) => `Call mg_get_transaction with reference="${a.reference}". Report: status, amount debited, destination amount, counterparty, delivery window. If status is "pending" and we're in test mode, offer to simulate success/decline with mg_test_payout_success or mg_test_payout_decline.`);
57
+
58
+ P('issue_card',
59
+ 'Issue a USD virtual card to an approved customer.',
60
+ { account_id: { description: 'Customer account_id', required: true } },
61
+ (a) => `Issue a virtual card to customer ${a.account_id}.
62
+
63
+ 1. Call mg_create_cardholder with account_id="${a.account_id}".
64
+ 2. In test mode, call mg_test_approve_cardholder to approve.
65
+ 3. Call mg_create_card with account_id="${a.account_id}". The card details arrive via the card_issued webhook — explain that.
66
+ 4. Optionally fund the card: ask me for amount, then mg_fund_card.`);
67
+
68
+ P('collect_payment',
69
+ 'Accept a payment from a buyer using a hosted payment session.',
70
+ {
71
+ amount: { description: 'Amount in source currency', required: true },
72
+ currency: { description: '3-letter currency code', required: true },
73
+ external_reference: { description: 'Your unique order ID', required: true },
74
+ },
75
+ (a) => `Create a payment session to collect ${a.amount} ${a.currency} for order ${a.external_reference}.
76
+
77
+ 1. Call mg_create_payment_session with currency, amount, external_reference, customer {email, first_name, last_name, ip_address}, billing_address, callback_url, title, description.
78
+ 2. Return the checkout URL / client payload to the buyer.
79
+ 3. After payment, call mg_verify_payment with external_reference="${a.external_reference}".`);
80
+ }