@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
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# MoneyGraph MCP Server
|
|
2
|
+
|
|
3
|
+
**Send money to 82+ countries from any AI agent.**
|
|
4
|
+
|
|
5
|
+
The first MCP server for real cross-border money movement. 328 FX pairs, 4 base currencies, bank transfers, mobile money, SWIFT — all through natural language.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npx @moneygraph/mcp-server
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Claude Desktop
|
|
14
|
+
|
|
15
|
+
Add to your `claude_desktop_config.json`:
|
|
16
|
+
|
|
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
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Claude Code
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
claude mcp add moneygraph -- npx -y @moneygraph/mcp-server
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Cursor
|
|
38
|
+
|
|
39
|
+
Add to `.cursor/mcp.json`:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcpServers": {
|
|
44
|
+
"moneygraph": {
|
|
45
|
+
"command": "npx",
|
|
46
|
+
"args": ["-y", "@moneygraph/mcp-server"],
|
|
47
|
+
"env": {
|
|
48
|
+
"MONEYGRAPH_API_KEY": "sk_sandbox_demo"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### VS Code
|
|
56
|
+
|
|
57
|
+
Add to `.vscode/settings.json`:
|
|
58
|
+
|
|
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 (45)
|
|
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
|
+
|
|
98
|
+
### Directors (KYB)
|
|
99
|
+
| Tool | Description |
|
|
100
|
+
|------|-------------|
|
|
101
|
+
| `create_director` | Add a director to a business customer |
|
|
102
|
+
| `list_directors` | List directors for a customer |
|
|
103
|
+
| `delete_director` | Remove a director |
|
|
104
|
+
|
|
105
|
+
### Currencies & Rates
|
|
106
|
+
| Tool | Description |
|
|
107
|
+
|------|-------------|
|
|
108
|
+
| `get_currencies` | **THE critical tool** — returns FX rates, corridor UUIDs, delivery windows, fees, limits |
|
|
109
|
+
| `list_countries` | List all supported countries |
|
|
110
|
+
|
|
111
|
+
### Recipients
|
|
112
|
+
| Tool | Description |
|
|
113
|
+
|------|-------------|
|
|
114
|
+
| `create_recipient` | Create a payment recipient |
|
|
115
|
+
| `list_recipients` | List all recipients |
|
|
116
|
+
| `get_recipient` | Get recipient details |
|
|
117
|
+
| `update_recipient` | Update recipient |
|
|
118
|
+
| `delete_recipient` | Delete recipient |
|
|
119
|
+
|
|
120
|
+
### Payouts
|
|
121
|
+
| Tool | Description |
|
|
122
|
+
|------|-------------|
|
|
123
|
+
| `create_payout` | Create a payout to an existing recipient |
|
|
124
|
+
| `send_bank_payout` | **HERO** — one-call bank transfer (creates recipient + payout) |
|
|
125
|
+
| `send_mobile_money_payout` | **HERO** — one-call mobile money transfer |
|
|
126
|
+
| `simulate_payout_success` | Sandbox: mark payout as successful |
|
|
127
|
+
| `simulate_payout_decline` | Sandbox: mark payout as declined |
|
|
128
|
+
| `verify_bank` | Verify a bank by routing code |
|
|
129
|
+
|
|
130
|
+
### Wallets
|
|
131
|
+
| Tool | Description |
|
|
132
|
+
|------|-------------|
|
|
133
|
+
| `list_wallets` | List merchant wallets with balances |
|
|
134
|
+
| `swap_funds` | Swap currency between wallets |
|
|
135
|
+
| `transfer_to_customer` | Fund a customer wallet |
|
|
136
|
+
| `transfer_from_customer` | Pull funds from customer |
|
|
137
|
+
|
|
138
|
+
### Payments
|
|
139
|
+
| Tool | Description |
|
|
140
|
+
|------|-------------|
|
|
141
|
+
| `initiate_payment` | Start collecting a payment (returns checkout URL) |
|
|
142
|
+
| `verify_payment` | Check payment status |
|
|
143
|
+
|
|
144
|
+
### Recurring Plans
|
|
145
|
+
| Tool | Description |
|
|
146
|
+
|------|-------------|
|
|
147
|
+
| `create_plan` | Create a recurring payment plan |
|
|
148
|
+
| `list_plans` | List all plans |
|
|
149
|
+
| `get_plan` | Get plan details |
|
|
150
|
+
| `update_plan` | Update a plan |
|
|
151
|
+
| `delete_plan` | Delete a plan |
|
|
152
|
+
|
|
153
|
+
### Transactions
|
|
154
|
+
| Tool | Description |
|
|
155
|
+
|------|-------------|
|
|
156
|
+
| `list_transactions` | List all transactions |
|
|
157
|
+
| `get_transaction` | Get transaction details |
|
|
158
|
+
| `get_wallet_transactions` | Get transactions for a wallet |
|
|
159
|
+
|
|
160
|
+
### Reference Data
|
|
161
|
+
| Tool | Description |
|
|
162
|
+
|------|-------------|
|
|
163
|
+
| `list_transfer_purposes` | Transfer purpose codes |
|
|
164
|
+
| `list_source_of_funds` | Source of funds options |
|
|
165
|
+
| `list_mcc_codes` | MCC codes for businesses |
|
|
166
|
+
| `list_business_registration_types` | Business registration types |
|
|
167
|
+
| `list_mobile_networks` | Mobile money networks by country |
|
|
168
|
+
| `list_cash_pickup_agents` | Cash pickup agents by country |
|
|
169
|
+
|
|
170
|
+
### Blockchain Ledger
|
|
171
|
+
| Tool | Description |
|
|
172
|
+
|------|-------------|
|
|
173
|
+
| `create_ledger_entity` | Create an on-chain audit entity |
|
|
174
|
+
| `get_ledger_entity` | Get entity details |
|
|
175
|
+
| `ledger_credit` | Credit an entity |
|
|
176
|
+
| `ledger_debit` | Debit an entity |
|
|
177
|
+
| `ledger_transfer` | Transfer between entities |
|
|
178
|
+
|
|
179
|
+
## Resources (6)
|
|
180
|
+
|
|
181
|
+
| URI | Description |
|
|
182
|
+
|-----|-------------|
|
|
183
|
+
| `moneygraph://status` | Server mode, API health, rate limits |
|
|
184
|
+
| `moneygraph://wallets` | Live wallet balances (USD, GBP, EUR, CAD) |
|
|
185
|
+
| `moneygraph://rates/{base}` | All FX rates from a base currency |
|
|
186
|
+
| `moneygraph://rates/{from}/{to}` | Specific corridor rate |
|
|
187
|
+
| `moneygraph://corridors/{base}` | Remittance corridors with UUIDs |
|
|
188
|
+
| `moneygraph://delivery-windows/{currency}` | Delivery windows and speeds |
|
|
189
|
+
|
|
190
|
+
## Prompts (4)
|
|
191
|
+
|
|
192
|
+
| Prompt | Description |
|
|
193
|
+
|--------|-------------|
|
|
194
|
+
| `send-money` | Guided cross-border payment flow |
|
|
195
|
+
| `onboard-customer` | Customer creation + KYC walkthrough |
|
|
196
|
+
| `check-rates` | FX rate comparison |
|
|
197
|
+
| `track-payout` | Payout status check |
|
|
198
|
+
|
|
199
|
+
## Configuration
|
|
200
|
+
|
|
201
|
+
| Variable | Description | Default |
|
|
202
|
+
|----------|-------------|---------|
|
|
203
|
+
| `MONEYGRAPH_API_KEY` | Your MoneyGraph API key | Sandbox mode |
|
|
204
|
+
|
|
205
|
+
- **No key** or `sk_sandbox_*` / `sk_test_*` → Sandbox mode (in-memory data, auto-KYC, test rates)
|
|
206
|
+
- `sk_live_*` → Production mode (real money, real compliance, 30 req/min)
|
|
207
|
+
|
|
208
|
+
## Key Concepts
|
|
209
|
+
|
|
210
|
+
- **Amounts are in minor units**: $500.00 = `50000`. Always multiply by 100.
|
|
211
|
+
- **Two-step payout flow**: Create recipient → Create payout. Or use `send_bank_payout` / `send_mobile_money_payout` for one step.
|
|
212
|
+
- **`get_currencies` first**: Always call this before any payout to get corridor UUIDs and delivery window UUIDs.
|
|
213
|
+
- **KYC required**: Only APPROVED customers can send payouts. In sandbox, `submit_kyc` auto-approves.
|
|
214
|
+
|
|
215
|
+
## Links
|
|
216
|
+
|
|
217
|
+
- [MoneyGraph Docs](https://docs.moneygraph.ai)
|
|
218
|
+
- [MoneyGraph SDK](https://www.npmjs.com/package/@moneygraph/sdk)
|
|
219
|
+
- [MoneyGraph Dashboard](https://app.moneygraph.ai)
|
|
220
|
+
- [Pricing](https://moneygraph.ai/pricing)
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT
|
package/bin/mcp-http.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
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
|
+
});
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MoneyGraph MCP Server — Configuration
|
|
3
|
+
*/
|
|
4
|
+
export type ServerMode = 'sandbox' | 'production';
|
|
5
|
+
export interface ServerConfig {
|
|
6
|
+
mode: ServerMode;
|
|
7
|
+
apiKey: string;
|
|
8
|
+
client: any;
|
|
9
|
+
}
|
|
10
|
+
export declare function loadConfig(): ServerConfig;
|
|
11
|
+
/** Format minor units to human-readable */
|
|
12
|
+
export declare function formatAmount(minorUnits: number, currency?: string): string;
|
|
13
|
+
/** Build _next_steps hint */
|
|
14
|
+
export declare function nextSteps(...steps: string[]): string;
|
|
15
|
+
/** Result type for safeCall */
|
|
16
|
+
export type SafeResult<T> = {
|
|
17
|
+
success: true;
|
|
18
|
+
data: T;
|
|
19
|
+
error?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
success: false;
|
|
22
|
+
error: string;
|
|
23
|
+
context: string;
|
|
24
|
+
data?: undefined;
|
|
25
|
+
};
|
|
26
|
+
/** Wrap an SDK call with error handling */
|
|
27
|
+
export declare function safeCall<T = any>(fn: () => Promise<T>, context: string): Promise<SafeResult<T>>;
|
|
28
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,GAAG,CAAC;CACb;AAQD,wBAAgB,UAAU,IAAI,YAAY,CAazC;AAED,2CAA2C;AAC3C,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAc,GAAG,MAAM,CAEjF;AAED,6BAA6B;AAC7B,wBAAgB,SAAS,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEpD;AAED,+BAA+B;AAC/B,MAAM,MAAM,UAAU,CAAC,CAAC,IACpB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GAC7C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAEzE,2CAA2C;AAC3C,wBAAsB,QAAQ,CAAC,CAAC,GAAG,GAAG,EACpC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAexB"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MoneyGraph MCP Server — Configuration
|
|
3
|
+
*/
|
|
4
|
+
// @ts-ignore - SDK uses default export that TypeScript doesn't resolve cleanly
|
|
5
|
+
import MoneyGraphModule from '@moneygraph/sdk';
|
|
6
|
+
// Handle ESM/CJS interop
|
|
7
|
+
const MoneyGraph = MoneyGraphModule.default || MoneyGraphModule;
|
|
8
|
+
function resolveMode(apiKey) {
|
|
9
|
+
if (!apiKey)
|
|
10
|
+
return 'sandbox';
|
|
11
|
+
if (apiKey.startsWith('sk_live_'))
|
|
12
|
+
return 'production';
|
|
13
|
+
return 'sandbox';
|
|
14
|
+
}
|
|
15
|
+
export function loadConfig() {
|
|
16
|
+
const apiKey = process.env.MONEYGRAPH_API_KEY || 'sk_test_mcp_sandbox_default';
|
|
17
|
+
const mode = resolveMode(process.env.MONEYGRAPH_API_KEY);
|
|
18
|
+
// @ts-ignore - constructor works at runtime
|
|
19
|
+
const client = new MoneyGraph({
|
|
20
|
+
apiKey,
|
|
21
|
+
...(mode === 'production'
|
|
22
|
+
? { baseUrl: 'https://api.moneygraph.ai/v1' }
|
|
23
|
+
: { baseUrl: 'https://sandbox.moneygraph.ai/v1' }),
|
|
24
|
+
});
|
|
25
|
+
return { mode, apiKey, client };
|
|
26
|
+
}
|
|
27
|
+
/** Format minor units to human-readable */
|
|
28
|
+
export function formatAmount(minorUnits, currency = 'USD') {
|
|
29
|
+
return `${currency} ${(minorUnits / 100).toFixed(2)}`;
|
|
30
|
+
}
|
|
31
|
+
/** Build _next_steps hint */
|
|
32
|
+
export function nextSteps(...steps) {
|
|
33
|
+
return steps.join(' → ');
|
|
34
|
+
}
|
|
35
|
+
/** Wrap an SDK call with error handling */
|
|
36
|
+
export async function safeCall(fn, context) {
|
|
37
|
+
try {
|
|
38
|
+
const data = await fn();
|
|
39
|
+
return { success: true, data };
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
43
|
+
if (message.includes('429') || message.toLowerCase().includes('rate limit')) {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
error: 'Rate limited. MoneyGraph allows 30 API calls per minute. Please wait and retry.',
|
|
47
|
+
context,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { success: false, error: message, context };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+EAA+E;AAC/E,OAAO,gBAAgB,MAAM,iBAAiB,CAA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AE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACjC,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5E,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,iFAAiF;gBACxF,OAAO;aACR,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACrD,CAAC;AACH,CAAC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MoneyGraph MCP Server — HTTP Transport
|
|
3
|
+
*
|
|
4
|
+
* Runs the MCP server over HTTP using StreamableHTTPServerTransport.
|
|
5
|
+
* Supports SSE streaming for server-to-client messages.
|
|
6
|
+
*
|
|
7
|
+
* Routes:
|
|
8
|
+
* POST /mcp — Handle MCP JSON-RPC messages
|
|
9
|
+
* GET /mcp — SSE stream for server-to-client notifications
|
|
10
|
+
* DELETE /mcp — Close session
|
|
11
|
+
* GET /health — Health check (for Railway, load balancers)
|
|
12
|
+
*/
|
|
13
|
+
import type { ServerConfig } from './config.js';
|
|
14
|
+
export declare function startHTTPServer(config: ServerConfig): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA4BhD,wBAAsB,eAAe,CAAC,MAAM,EAAE,YAAY,iBAyEzD"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MoneyGraph MCP Server — HTTP Transport
|
|
3
|
+
*
|
|
4
|
+
* Runs the MCP server over HTTP using StreamableHTTPServerTransport.
|
|
5
|
+
* Supports SSE streaming for server-to-client messages.
|
|
6
|
+
*
|
|
7
|
+
* Routes:
|
|
8
|
+
* POST /mcp — Handle MCP JSON-RPC messages
|
|
9
|
+
* GET /mcp — SSE stream for server-to-client notifications
|
|
10
|
+
* DELETE /mcp — Close session
|
|
11
|
+
* GET /health — Health check (for Railway, load balancers)
|
|
12
|
+
*/
|
|
13
|
+
import { createServer as createHTTPServer } from 'node:http';
|
|
14
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
15
|
+
import { createServer } from './index.js';
|
|
16
|
+
const ALLOWED_ORIGINS = [
|
|
17
|
+
'http://localhost:5173', // Vite dev server
|
|
18
|
+
'http://localhost:8888', // Netlify dev
|
|
19
|
+
'https://moneygraph.netlify.app',
|
|
20
|
+
];
|
|
21
|
+
function setCORSHeaders(req, res) {
|
|
22
|
+
const origin = req.headers.origin || '';
|
|
23
|
+
// Allow configured origins, or any origin in development
|
|
24
|
+
if (ALLOWED_ORIGINS.includes(origin) || process.env.CORS_ALLOW_ALL === 'true') {
|
|
25
|
+
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
26
|
+
}
|
|
27
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
|
|
28
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, mcp-session-id');
|
|
29
|
+
res.setHeader('Access-Control-Expose-Headers', 'mcp-session-id');
|
|
30
|
+
}
|
|
31
|
+
function readBody(req) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const chunks = [];
|
|
34
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
35
|
+
req.on('end', () => resolve(Buffer.concat(chunks).toString()));
|
|
36
|
+
req.on('error', reject);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export async function startHTTPServer(config) {
|
|
40
|
+
const port = parseInt(process.env.PORT || '3001', 10);
|
|
41
|
+
const httpServer = createHTTPServer(async (req, res) => {
|
|
42
|
+
setCORSHeaders(req, res);
|
|
43
|
+
// Handle CORS preflight
|
|
44
|
+
if (req.method === 'OPTIONS') {
|
|
45
|
+
res.writeHead(204);
|
|
46
|
+
res.end();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const url = new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);
|
|
50
|
+
// ── Health check ────────────────────────────────────────
|
|
51
|
+
if (url.pathname === '/health') {
|
|
52
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
53
|
+
res.end(JSON.stringify({
|
|
54
|
+
status: 'ok',
|
|
55
|
+
server: '@moneygraph/mcp-server',
|
|
56
|
+
version: '1.0.0',
|
|
57
|
+
mode: config.mode,
|
|
58
|
+
transport: 'http',
|
|
59
|
+
tools: 76,
|
|
60
|
+
resources: 6,
|
|
61
|
+
prompts: 6,
|
|
62
|
+
}));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// ── MCP endpoint ────────────────────────────────────────
|
|
66
|
+
if (url.pathname === '/mcp') {
|
|
67
|
+
// Create a new server + transport per request (stateless mode)
|
|
68
|
+
const server = createServer(config);
|
|
69
|
+
const transport = new StreamableHTTPServerTransport({
|
|
70
|
+
sessionIdGenerator: undefined, // Stateless
|
|
71
|
+
});
|
|
72
|
+
// Connect MCP server to transport
|
|
73
|
+
await server.connect(transport);
|
|
74
|
+
// Parse body for POST requests
|
|
75
|
+
if (req.method === 'POST') {
|
|
76
|
+
const body = await readBody(req);
|
|
77
|
+
let parsed;
|
|
78
|
+
try {
|
|
79
|
+
parsed = JSON.parse(body);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
83
|
+
res.end(JSON.stringify({ error: 'Invalid JSON' }));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
await transport.handleRequest(req, res, parsed);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// GET (SSE) or DELETE
|
|
90
|
+
await transport.handleRequest(req, res);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
// ── 404 for everything else ─────────────────────────────
|
|
95
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
96
|
+
res.end(JSON.stringify({ error: 'Not found', endpoints: ['/mcp', '/health'] }));
|
|
97
|
+
});
|
|
98
|
+
httpServer.listen(port, () => {
|
|
99
|
+
console.error(`MoneyGraph MCP Server v1.0.0 — ${config.mode} mode — HTTP transport on port ${port} — 76 tools, 6 resources, 6 prompts`);
|
|
100
|
+
console.error(` MCP endpoint: http://localhost:${port}/mcp`);
|
|
101
|
+
console.error(` Health check: http://localhost:${port}/health`);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAA6C,MAAM,WAAW,CAAC;AACxG,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,eAAe,GAAG;IACtB,uBAAuB,EAAI,kBAAkB;IAC7C,uBAAuB,EAAI,cAAc;IACzC,gCAAgC;CACjC,CAAC;AAEF,SAAS,cAAc,CAAC,GAAoB,EAAE,GAAmB;IAC/D,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM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MCP Server — Main Entry Point
|
|
3
|
+
*
|
|
4
|
+
* The first MCP server for real cross-border money movement.
|
|
5
|
+
* 76 tools, 6 resources, 6 prompts.
|
|
6
|
+
* 82+ countries, 328 FX pairs, bank transfers, mobile money, SWIFT,
|
|
7
|
+
* virtual/physical cards, crypto on-ramp/off-ramp.
|
|
8
|
+
*
|
|
9
|
+
* Supports two transport modes:
|
|
10
|
+
* - stdio (default): For Claude Desktop, Cursor, VS Code
|
|
11
|
+
* - http: For web clients (moneygraph-chat, Claude connector)
|
|
12
|
+
* Set MONEYGRAPH_TRANSPORT=http to enable
|
|
13
|
+
*/
|
|
14
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
15
|
+
import { type ServerConfig } from './config.js';
|
|
16
|
+
export declare function createServer(config: ServerConfig): McpServer;
|
|
17
|
+
export declare function startServer(): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAsF5D,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CA8C5D;AAGD,wBAAsB,WAAW,kBAkBhC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MoneyGraph MCP Server — Main Entry Point
|
|
3
|
+
*
|
|
4
|
+
* The first MCP server for real cross-border money movement.
|
|
5
|
+
* 76 tools, 6 resources, 6 prompts.
|
|
6
|
+
* 82+ countries, 328 FX pairs, bank transfers, mobile money, SWIFT,
|
|
7
|
+
* virtual/physical cards, crypto on-ramp/off-ramp.
|
|
8
|
+
*
|
|
9
|
+
* Supports two transport modes:
|
|
10
|
+
* - stdio (default): For Claude Desktop, Cursor, VS Code
|
|
11
|
+
* - http: For web clients (moneygraph-chat, Claude connector)
|
|
12
|
+
* Set MONEYGRAPH_TRANSPORT=http to enable
|
|
13
|
+
*/
|
|
14
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
15
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
16
|
+
import { loadConfig } from './config.js';
|
|
17
|
+
// Tools
|
|
18
|
+
import { registerCustomerTools } from './tools/customers.js';
|
|
19
|
+
import { registerDirectorTools } from './tools/directors.js';
|
|
20
|
+
import { registerCurrencyTools } from './tools/currencies.js';
|
|
21
|
+
import { registerRecipientTools } from './tools/recipients.js';
|
|
22
|
+
import { registerPayoutTools } from './tools/payouts.js';
|
|
23
|
+
import { registerWalletTools } from './tools/wallets.js';
|
|
24
|
+
import { registerPaymentTools } from './tools/payments.js';
|
|
25
|
+
import { registerRecurringTools } from './tools/recurring.js';
|
|
26
|
+
import { registerTransactionTools } from './tools/transactions.js';
|
|
27
|
+
import { registerReferenceTools } from './tools/reference.js';
|
|
28
|
+
import { registerLedgerTools } from './tools/ledger.js';
|
|
29
|
+
import { registerCardTools } from './tools/cards.js';
|
|
30
|
+
import { registerCryptoTools } from './tools/crypto.js';
|
|
31
|
+
import { registerFXTools } from './tools/fx.js';
|
|
32
|
+
// Resources
|
|
33
|
+
import { registerStatusResource } from './resources/status.js';
|
|
34
|
+
import { registerWalletsResource } from './resources/wallets.js';
|
|
35
|
+
import { registerCorridorsResource } from './resources/corridors.js';
|
|
36
|
+
// Prompts
|
|
37
|
+
import { registerSendMoneyPrompt } from './prompts/send-money.js';
|
|
38
|
+
import { registerOnboardCustomerPrompt } from './prompts/onboard-customer.js';
|
|
39
|
+
import { registerCheckRatesPrompt } from './prompts/check-rates.js';
|
|
40
|
+
import { registerTrackPayoutPrompt } from './prompts/payout-status.js';
|
|
41
|
+
import { registerIssueCardPrompt } from './prompts/issue-card.js';
|
|
42
|
+
import { registerCryptoDepositPrompt } from './prompts/crypto-deposit.js';
|
|
43
|
+
// ── Server Instructions ───────────────────────────────────────────
|
|
44
|
+
function getServerInstructions(mode) {
|
|
45
|
+
return `MoneyGraph MCP Server — Cross-Border Payment Infrastructure
|
|
46
|
+
|
|
47
|
+
IMPORTANT CONCEPTS:
|
|
48
|
+
- DATE FORMAT: DD-MM-YYYY (e.g., "15-06-1990") — required for all dates
|
|
49
|
+
- FX EXPIRY: Quotes expire in 2 minutes — call confirm_fx_quote promptly
|
|
50
|
+
- IDEMPOTENCY: Always include unique idempotency_key for payouts to prevent duplicates
|
|
51
|
+
- TWO-STEP PAYOUT FLOW: (1) create recipient → (2) create payout. Or use convenience tools: send_bank_payout, send_mobile_money_payout, smart_payout.
|
|
52
|
+
- AMOUNTS IN MINOR UNITS: All monetary amounts are in minor units. $500.00 = 50000. Always multiply by 100.
|
|
53
|
+
- GET_CURRENCIES IS KEY: Before any payout, call get_currencies with the destination country code. Returns corridor UUIDs, delivery window UUIDs, rates, fees, and limits.
|
|
54
|
+
- CUSTOMER IDS: Numeric strings like "0605399" (not UUIDs)
|
|
55
|
+
- ALL OTHER IDS: UUIDs (wallet_id, recipient_id, corridor_id, delivery_window_id)
|
|
56
|
+
- KYC REQUIRED: Only APPROVED customers can send payouts or get cards. In sandbox, submit_kyc auto-approves.
|
|
57
|
+
|
|
58
|
+
RECOMMENDED FLOW FOR SENDING MONEY:
|
|
59
|
+
1. get_currencies (destination country) → corridor ID, delivery window ID, rate, fees
|
|
60
|
+
2. list_wallets → find source wallet (USD, GBP, EUR, or CAD)
|
|
61
|
+
3. Create or find customer → create_customer + submit_kyc (if new)
|
|
62
|
+
4. get_fx_quote → get live rate and fee → confirm_fx_quote → lock the rate
|
|
63
|
+
5. send_bank_payout / send_mobile_money_payout / smart_payout → execute transfer
|
|
64
|
+
6. Report confirmation with transaction ID, rate, fees, and estimated delivery
|
|
65
|
+
|
|
66
|
+
FX QUOTE FLOW (CRITICAL — 2 MIN EXPIRY):
|
|
67
|
+
1. get_fx_quote with source/destination currencies + amount
|
|
68
|
+
2. confirm_fx_quote with quote_id (MUST call within 2 minutes)
|
|
69
|
+
3. Use confirmed quote_id when creating payouts
|
|
70
|
+
|
|
71
|
+
CARD ISSUANCE FLOW:
|
|
72
|
+
1. Ensure customer has APPROVED KYC (check_kyc_status)
|
|
73
|
+
2. create_card with customer_id, type (virtual/physical), currency
|
|
74
|
+
3. fund_card to load balance from a wallet
|
|
75
|
+
4. Virtual cards are instant; physical cards are shipped
|
|
76
|
+
|
|
77
|
+
CRYPTO FLOW:
|
|
78
|
+
1. create_crypto_address → get deposit address + QR code
|
|
79
|
+
2. Track deposits with list_crypto_deposits
|
|
80
|
+
3. Convert crypto to fiat with crypto_convert_quote → crypto_convert_execute
|
|
81
|
+
4. Send crypto payouts with send_crypto_payout
|
|
82
|
+
|
|
83
|
+
PAYOUT RAILS:
|
|
84
|
+
- Bank: ACH (US), SEPA (EU), Faster Payments (UK), SWIFT (global)
|
|
85
|
+
- Mobile Money: M-Pesa, MTN, Airtel, Vodafone, Orange
|
|
86
|
+
- Crypto: USDC, USDT, BTC, ETH on Ethereum, Tron, Polygon, Base, Solana
|
|
87
|
+
- Cards: Virtual + Physical debit cards in USD, GBP, EUR
|
|
88
|
+
|
|
89
|
+
BASE CURRENCIES: USD, GBP, EUR, CAD
|
|
90
|
+
DELIVERY METHODS: bank, mobile_money, cash_pickup, crypto
|
|
91
|
+
CORRIDORS: 82+ countries per base currency, 328 total FX pairs
|
|
92
|
+
|
|
93
|
+
CURRENT MODE: ${mode}
|
|
94
|
+
${mode === 'sandbox' ? 'SANDBOX: All data is in-memory. KYC auto-approves. Use simulate_payout_success/decline to test. Use create_mock_customer for instant test personas.' : 'PRODUCTION: Real money movement. Real KYC. Real compliance. Rate limit: 30 req/min.'}`;
|
|
95
|
+
}
|
|
96
|
+
// ── Create Server (shared setup) ──────────────────────────────────
|
|
97
|
+
export function createServer(config) {
|
|
98
|
+
const server = new McpServer({
|
|
99
|
+
name: 'moneygraph',
|
|
100
|
+
version: '1.0.0',
|
|
101
|
+
}, {
|
|
102
|
+
capabilities: {
|
|
103
|
+
tools: {},
|
|
104
|
+
resources: {},
|
|
105
|
+
prompts: {},
|
|
106
|
+
},
|
|
107
|
+
instructions: getServerInstructions(config.mode),
|
|
108
|
+
});
|
|
109
|
+
// Register all tools (14 domains, 76 total)
|
|
110
|
+
registerCustomerTools(server, config);
|
|
111
|
+
registerDirectorTools(server, config);
|
|
112
|
+
registerCurrencyTools(server, config);
|
|
113
|
+
registerRecipientTools(server, config);
|
|
114
|
+
registerPayoutTools(server, config);
|
|
115
|
+
registerWalletTools(server, config);
|
|
116
|
+
registerPaymentTools(server, config);
|
|
117
|
+
registerRecurringTools(server, config);
|
|
118
|
+
registerTransactionTools(server, config);
|
|
119
|
+
registerReferenceTools(server, config);
|
|
120
|
+
registerLedgerTools(server, config);
|
|
121
|
+
registerCardTools(server, config);
|
|
122
|
+
registerCryptoTools(server, config);
|
|
123
|
+
registerFXTools(server, config);
|
|
124
|
+
// Register all 6 resources
|
|
125
|
+
registerStatusResource(server, config);
|
|
126
|
+
registerWalletsResource(server, config);
|
|
127
|
+
registerCorridorsResource(server, config);
|
|
128
|
+
// Register all 6 prompts
|
|
129
|
+
registerSendMoneyPrompt(server);
|
|
130
|
+
registerOnboardCustomerPrompt(server);
|
|
131
|
+
registerCheckRatesPrompt(server);
|
|
132
|
+
registerTrackPayoutPrompt(server);
|
|
133
|
+
registerIssueCardPrompt(server);
|
|
134
|
+
registerCryptoDepositPrompt(server);
|
|
135
|
+
return server;
|
|
136
|
+
}
|
|
137
|
+
// ── Start Server ──────────────────────────────────────────────────
|
|
138
|
+
export async function startServer() {
|
|
139
|
+
const config = loadConfig();
|
|
140
|
+
const transportMode = process.env.MONEYGRAPH_TRANSPORT || 'stdio';
|
|
141
|
+
if (transportMode === 'http') {
|
|
142
|
+
// Dynamic import to avoid loading http module when using stdio
|
|
143
|
+
const { startHTTPServer } = await import('./http.js');
|
|
144
|
+
await startHTTPServer(config);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// Default: stdio transport for CLI / IDE integrations
|
|
148
|
+
const server = createServer(config);
|
|
149
|
+
const transport = new StdioServerTransport();
|
|
150
|
+
await server.connect(transport);
|
|
151
|
+
console.error(`MoneyGraph MCP Server v1.0.0 — ${config.mode} mode — stdio transport — 76 tools, 6 resources, 6 prompts`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Auto-start when run directly
|
|
155
|
+
const isDirectRun = process.argv[1]?.endsWith('index.js') ||
|
|
156
|
+
process.argv[1]?.endsWith('mcp-server.js') ||
|
|
157
|
+
process.argv[1]?.endsWith('mcp-http.js');
|
|
158
|
+
if (isDirectRun) {
|
|
159
|
+
startServer().catch((err) => {
|
|
160
|
+
console.error('Fatal:', err);
|
|
161
|
+
process.exit(1);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=index.js.map
|