stables-mcp-server 1.1.0 → 1.3.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.
@@ -2,7 +2,23 @@
2
2
  * Stables API Client for MCP Server
3
3
  * Synced with OpenAPI spec from https://api.sandbox.stables.money/docs
4
4
  */
5
- // API Client
5
+ // ============ CUSTOM ERROR ============
6
+ export class StablesApiError extends Error {
7
+ statusCode;
8
+ endpoint;
9
+ errorBody;
10
+ constructor(message, statusCode, endpoint, errorBody) {
11
+ super(message);
12
+ this.statusCode = statusCode;
13
+ this.endpoint = endpoint;
14
+ this.errorBody = errorBody;
15
+ this.name = "StablesApiError";
16
+ }
17
+ }
18
+ // ============ API CLIENT ============
19
+ const REQUEST_TIMEOUT_MS = 30_000;
20
+ const MAX_RETRIES = 3;
21
+ const RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503, 504]);
6
22
  export class StablesApiClient {
7
23
  apiKey;
8
24
  baseUrl;
@@ -19,40 +35,90 @@ export class StablesApiClient {
19
35
  if (options.body) {
20
36
  headers["Content-Type"] = "application/json";
21
37
  }
22
- const response = await fetch(url, {
23
- ...options,
24
- headers,
25
- });
26
- if (!response.ok) {
27
- const errorBody = await response.json().catch(() => null);
28
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
29
- if (errorBody) {
30
- if (errorBody.error?.message) {
31
- errorMessage = errorBody.error.message;
38
+ const controller = new AbortController();
39
+ const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
40
+ try {
41
+ const response = await fetch(url, {
42
+ ...options,
43
+ headers,
44
+ signal: controller.signal,
45
+ });
46
+ if (!response.ok) {
47
+ // Handle rate limiting
48
+ if (response.status === 429) {
49
+ const retryAfter = response.headers.get("Retry-After");
50
+ const waitSecs = retryAfter ? parseInt(retryAfter, 10) : 60;
51
+ throw new StablesApiError(`Rate limited. Retry after ${waitSecs} seconds.`, 429, endpoint);
52
+ }
53
+ const errorBody = await response.json().catch(() => null);
54
+ let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
55
+ if (errorBody) {
56
+ if (errorBody.error?.message) {
57
+ errorMessage = errorBody.error.message;
58
+ }
59
+ else if (errorBody.message) {
60
+ errorMessage = errorBody.message;
61
+ }
62
+ else if (typeof errorBody.error === "string") {
63
+ errorMessage = errorBody.error;
64
+ }
32
65
  }
33
- else if (errorBody.message) {
34
- errorMessage = errorBody.message;
66
+ throw new StablesApiError(errorMessage, response.status, endpoint, errorBody);
67
+ }
68
+ // Handle empty responses (e.g., 204 No Content)
69
+ if (response.status === 204 || response.headers.get("content-length") === "0") {
70
+ return {};
71
+ }
72
+ return response.json();
73
+ }
74
+ catch (error) {
75
+ if (error instanceof StablesApiError) {
76
+ throw error;
77
+ }
78
+ if (error instanceof DOMException && error.name === "AbortError") {
79
+ throw new StablesApiError(`Request timed out after ${REQUEST_TIMEOUT_MS / 1000}s`, 0, endpoint);
80
+ }
81
+ throw error;
82
+ }
83
+ finally {
84
+ clearTimeout(timeoutId);
85
+ }
86
+ }
87
+ async requestWithRetry(endpoint, options = {}) {
88
+ let lastError;
89
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
90
+ try {
91
+ return await this.request(endpoint, options);
92
+ }
93
+ catch (error) {
94
+ lastError = error instanceof Error ? error : new Error(String(error));
95
+ // Don't retry client errors (except 429 rate limits)
96
+ if (error instanceof StablesApiError) {
97
+ if (error.statusCode >= 400 && error.statusCode < 500 && !RETRYABLE_STATUS_CODES.has(error.statusCode)) {
98
+ throw error;
99
+ }
35
100
  }
36
- else if (typeof errorBody.error === "string") {
37
- errorMessage = errorBody.error;
101
+ if (attempt < MAX_RETRIES) {
102
+ const delay = Math.min(1000 * Math.pow(2, attempt), 10000);
103
+ const jitter = Math.random() * 500;
104
+ await new Promise(resolve => setTimeout(resolve, delay + jitter));
38
105
  }
39
106
  }
40
- throw new Error(errorMessage);
41
107
  }
42
- return response.json();
108
+ throw lastError;
43
109
  }
44
110
  generateIdempotencyKey() {
45
111
  return crypto.randomUUID();
46
112
  }
47
113
  // ============ CUSTOMERS ============
48
114
  async listCustomers() {
49
- return this.request("/api/v1/customers");
115
+ return this.requestWithRetry("/api/v1/customers");
50
116
  }
51
117
  async getCustomer(customerId) {
52
- return this.request(`/api/v1/customers/${customerId}`);
118
+ return this.requestWithRetry(`/api/v1/customers/${customerId}`);
53
119
  }
54
120
  async createCustomer(data) {
55
- return this.request("/api/v1/customer", {
121
+ return this.requestWithRetry("/api/v1/customer", {
56
122
  method: "POST",
57
123
  body: JSON.stringify(data),
58
124
  headers: {
@@ -61,13 +127,13 @@ export class StablesApiClient {
61
127
  });
62
128
  }
63
129
  async updateCustomer(customerId, data) {
64
- return this.request(`/api/v1/customer/${customerId}`, {
130
+ return this.requestWithRetry(`/api/v1/customer/${customerId}`, {
65
131
  method: "PATCH",
66
132
  body: JSON.stringify(data),
67
133
  });
68
134
  }
69
135
  async updateMetadata(customerId, metadata) {
70
- await this.request(`/api/v1/customers/${customerId}/metadata`, {
136
+ await this.requestWithRetry(`/api/v1/customers/${customerId}/metadata`, {
71
137
  method: "PUT",
72
138
  body: JSON.stringify({ metadata }),
73
139
  headers: {
@@ -76,7 +142,7 @@ export class StablesApiClient {
76
142
  });
77
143
  }
78
144
  async generateVerificationLink(customerId, options) {
79
- return this.request(`/api/v1/customer/${customerId}/verification/link`, {
145
+ return this.requestWithRetry(`/api/v1/customer/${customerId}/verification/link`, {
80
146
  method: "POST",
81
147
  body: JSON.stringify(options || {}),
82
148
  headers: {
@@ -92,7 +158,7 @@ export class StablesApiClient {
92
158
  if (params?.limit)
93
159
  searchParams.set("limit", params.limit.toString());
94
160
  const query = searchParams.toString();
95
- return this.request(`/api/v1/virtual-accounts${query ? `?${query}` : ""}`);
161
+ return this.requestWithRetry(`/api/v1/virtual-accounts${query ? `?${query}` : ""}`);
96
162
  }
97
163
  async listVirtualAccounts(customerId, params) {
98
164
  const searchParams = new URLSearchParams();
@@ -101,10 +167,10 @@ export class StablesApiClient {
101
167
  if (params?.limit)
102
168
  searchParams.set("limit", params.limit.toString());
103
169
  const query = searchParams.toString();
104
- return this.request(`/api/v1/customers/${customerId}/virtual-accounts${query ? `?${query}` : ""}`);
170
+ return this.requestWithRetry(`/api/v1/customers/${customerId}/virtual-accounts${query ? `?${query}` : ""}`);
105
171
  }
106
172
  async createVirtualAccount(customerId, data) {
107
- return this.request(`/api/v1/customers/${customerId}/virtual-accounts`, {
173
+ return this.requestWithRetry(`/api/v1/customers/${customerId}/virtual-accounts`, {
108
174
  method: "POST",
109
175
  body: JSON.stringify(data),
110
176
  headers: {
@@ -113,13 +179,13 @@ export class StablesApiClient {
113
179
  });
114
180
  }
115
181
  async updateVirtualAccount(customerId, virtualAccountId, data) {
116
- return this.request(`/api/v1/customers/${customerId}/virtual-accounts/${virtualAccountId}`, {
182
+ return this.requestWithRetry(`/api/v1/customers/${customerId}/virtual-accounts/${virtualAccountId}`, {
117
183
  method: "PATCH",
118
184
  body: JSON.stringify(data),
119
185
  });
120
186
  }
121
187
  async deactivateVirtualAccount(customerId, virtualAccountId) {
122
- return this.request(`/api/v1/customers/${customerId}/virtual-accounts/${virtualAccountId}/deactivate`, {
188
+ return this.requestWithRetry(`/api/v1/customers/${customerId}/virtual-accounts/${virtualAccountId}/deactivate`, {
123
189
  method: "POST",
124
190
  headers: {
125
191
  "idempotency-key": this.generateIdempotencyKey(),
@@ -127,7 +193,7 @@ export class StablesApiClient {
127
193
  });
128
194
  }
129
195
  async reactivateVirtualAccount(customerId, virtualAccountId) {
130
- return this.request(`/api/v1/customers/${customerId}/virtual-accounts/${virtualAccountId}/reactivate`, {
196
+ return this.requestWithRetry(`/api/v1/customers/${customerId}/virtual-accounts/${virtualAccountId}/reactivate`, {
131
197
  method: "POST",
132
198
  headers: {
133
199
  "idempotency-key": this.generateIdempotencyKey(),
@@ -138,10 +204,14 @@ export class StablesApiClient {
138
204
  const searchParams = new URLSearchParams();
139
205
  if (params?.limit)
140
206
  searchParams.set("limit", params.limit.toString());
141
- if (params?.event_type)
142
- searchParams.set("event_type", params.event_type);
207
+ if (params?.depositId)
208
+ searchParams.set("deposit_id", params.depositId);
209
+ if (params?.startingAfter)
210
+ searchParams.set("starting_after", params.startingAfter);
211
+ if (params?.endingBefore)
212
+ searchParams.set("ending_before", params.endingBefore);
143
213
  const query = searchParams.toString();
144
- return this.request(`/api/v1/customers/${customerId}/virtual-accounts/${virtualAccountId}/history${query ? `?${query}` : ""}`);
214
+ return this.requestWithRetry(`/api/v1/customers/${customerId}/virtual-accounts/${virtualAccountId}/history${query ? `?${query}` : ""}`);
145
215
  }
146
216
  // ============ TRANSFERS ============
147
217
  async listTransfers(params) {
@@ -157,13 +227,13 @@ export class StablesApiClient {
157
227
  if (params?.pageToken)
158
228
  searchParams.set("pageToken", params.pageToken);
159
229
  const query = searchParams.toString();
160
- return this.request(`/api/v1/transfers${query ? `?${query}` : ""}`);
230
+ return this.requestWithRetry(`/api/v1/transfers${query ? `?${query}` : ""}`);
161
231
  }
162
232
  async getTransfer(transferId) {
163
- return this.request(`/api/v1/transfers/${transferId}`);
233
+ return this.requestWithRetry(`/api/v1/transfers/${transferId}`);
164
234
  }
165
235
  async createTransfer(data) {
166
- return this.request("/api/v1/transfer", {
236
+ return this.requestWithRetry("/api/v1/transfer", {
167
237
  method: "POST",
168
238
  body: JSON.stringify(data),
169
239
  headers: {
@@ -173,7 +243,7 @@ export class StablesApiClient {
173
243
  }
174
244
  // ============ QUOTES ============
175
245
  async createQuote(data) {
176
- return this.request("/api/v1/quotes", {
246
+ return this.requestWithRetry("/api/v1/quotes", {
177
247
  method: "POST",
178
248
  body: JSON.stringify(data),
179
249
  headers: {
@@ -182,7 +252,7 @@ export class StablesApiClient {
182
252
  });
183
253
  }
184
254
  async getQuote(quoteId) {
185
- return this.request(`/api/v1/quotes/${quoteId}`);
255
+ return this.requestWithRetry(`/api/v1/quotes/${quoteId}`);
186
256
  }
187
257
  // ============ API KEYS ============
188
258
  async listApiKeys(params) {
@@ -192,10 +262,10 @@ export class StablesApiClient {
192
262
  if (params?.pageToken)
193
263
  searchParams.set("pageToken", params.pageToken);
194
264
  const query = searchParams.toString();
195
- return this.request(`/api/v1/api-keys${query ? `?${query}` : ""}`);
265
+ return this.requestWithRetry(`/api/v1/api-keys${query ? `?${query}` : ""}`);
196
266
  }
197
267
  async createApiKey(data) {
198
- return this.request("/api/v1/api-keys", {
268
+ return this.requestWithRetry("/api/v1/api-keys", {
199
269
  method: "POST",
200
270
  body: JSON.stringify(data),
201
271
  headers: {
@@ -204,10 +274,10 @@ export class StablesApiClient {
204
274
  });
205
275
  }
206
276
  async getApiKey(apiKeyId) {
207
- return this.request(`/api/v1/api-keys/${apiKeyId}`);
277
+ return this.requestWithRetry(`/api/v1/api-keys/${apiKeyId}`);
208
278
  }
209
279
  async revokeApiKey(apiKeyId) {
210
- return this.request(`/api/v1/api-keys/${apiKeyId}`, {
280
+ return this.requestWithRetry(`/api/v1/api-keys/${apiKeyId}`, {
211
281
  method: "DELETE",
212
282
  headers: {
213
283
  "idempotency-key": this.generateIdempotencyKey(),
@@ -216,10 +286,10 @@ export class StablesApiClient {
216
286
  }
217
287
  // ============ WEBHOOKS ============
218
288
  async listWebhooks() {
219
- return this.request("/api/v1/webhooks");
289
+ return this.requestWithRetry("/api/v1/webhooks");
220
290
  }
221
291
  async createWebhook(data) {
222
- return this.request("/api/v1/webhooks", {
292
+ return this.requestWithRetry("/api/v1/webhooks", {
223
293
  method: "POST",
224
294
  body: JSON.stringify(data),
225
295
  headers: {
@@ -228,7 +298,7 @@ export class StablesApiClient {
228
298
  });
229
299
  }
230
300
  async deleteWebhook(subscriptionId) {
231
- return this.request(`/api/v1/webhooks/${subscriptionId}`, {
301
+ return this.requestWithRetry(`/api/v1/webhooks/${subscriptionId}`, {
232
302
  method: "DELETE",
233
303
  headers: {
234
304
  "idempotency-key": this.generateIdempotencyKey(),
@@ -243,6 +313,9 @@ export function createStablesClient() {
243
313
  if (!apiKey) {
244
314
  throw new Error("STABLES_API_KEY environment variable is required");
245
315
  }
316
+ if (!baseUrl.startsWith("https://")) {
317
+ throw new Error("STABLES_API_URL must use HTTPS");
318
+ }
246
319
  return new StablesApiClient(apiKey, baseUrl);
247
320
  }
248
321
  //# sourceMappingURL=stables-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stables-client.js","sourceRoot":"","sources":["../../src/lib/stables-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8UH,aAAa;AACb,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAS;IACf,OAAO,CAAS;IAExB,YAAY,MAAc,EAAE,OAAe;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEO,KAAK,CAAC,OAAO,CACnB,QAAgB,EAChB,UAAuB,EAAE;QAEzB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,QAAQ,EAAE,CAAC;QAEzC,MAAM,OAAO,GAA2B;YACtC,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;YACtC,GAAG,OAAO,CAAC,OAAiC;SAC7C,CAAC;QAEF,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QAC/C,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,GAAG,OAAO;YACV,OAAO;SACR,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YAC1D,IAAI,YAAY,GAAG,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;YAErE,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,SAAS,CAAC,K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,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,QAoUhF"}
1
+ {"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/tools/customers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAA0C,MAAM,0BAA0B,CAAC;AASpG,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,QAmahF"}
@@ -3,52 +3,143 @@
3
3
  * Synced with OpenAPI spec from https://api.sandbox.stables.money/docs
4
4
  */
5
5
  import { z } from "zod";
6
+ import { StablesApiError } from "../lib/stables-client.js";
7
+ function formatError(error) {
8
+ if (error instanceof StablesApiError) {
9
+ return `${error.message} (HTTP ${error.statusCode})`;
10
+ }
11
+ return error instanceof Error ? error.message : "Unknown error";
12
+ }
6
13
  export function registerCustomerTools(server, client) {
7
14
  // Create Customer
8
15
  server.tool("create_customer", "Create a new customer in Stables for KYC verification and transfers. Use 'individual' for personal accounts or 'business' for company accounts. Include entitlements like 'base_payout' to enable transactions.", {
9
- email: z.string().email().describe("Customer's email address"),
16
+ email: z.string().email().optional().describe("Customer's email address"),
10
17
  customerType: z.enum(["individual", "business"]).describe("Type of customer - 'individual' for personal, 'business' for companies"),
18
+ // Individual fields
11
19
  firstName: z.string().optional().describe("First name (required for individuals)"),
12
20
  lastName: z.string().optional().describe("Last name (required for individuals)"),
13
21
  middleName: z.string().optional().describe("Middle name"),
22
+ dob: z.string().optional().describe("Date of birth in YYYY-MM-DD format (e.g., '1990-01-15')"),
23
+ nationality: z.string().optional().describe("Two-letter country code (e.g., 'US', 'GB')"),
24
+ // Business fields
14
25
  companyName: z.string().optional().describe("Company name (required for businesses)"),
26
+ country: z.string().optional().describe("Country code ISO 3166-1 alpha-2 (required for businesses, e.g., 'US')"),
27
+ registrationNumber: z.string().optional().describe("Business registration number"),
28
+ incorporatedOn: z.string().optional().describe("Date of incorporation in YYYY-MM-DD format"),
29
+ type: z.string().optional().describe("Company type (e.g., 'Private Company Limited by Shares')"),
30
+ taxId: z.string().optional().describe("Tax ID (e.g., '12-3456789')"),
31
+ registrationLocation: z.string().optional().describe("Registration location (e.g., state for USA)"),
32
+ website: z.string().optional().describe("Website URL"),
33
+ describeBusiness: z.string().optional().describe("Description of the business"),
34
+ conductMoneyServices: z.boolean().optional().describe("Whether the company conducts money services"),
35
+ describeMoneyServices: z.string().optional().describe("Describe money services (required if conductMoneyServices is true)"),
36
+ describeComplianceControls: z.string().optional().describe("Description of compliance controls"),
37
+ mainSourceOfFunds: z.enum(["BUSINESS_LOANS", "GRANTS", "INTER_COMPANY_FUNDS", "INVESTMENT_PROCEEDS", "LEGAL_SETTLEMENT", "OWNERS_CAPITAL", "PENSION_RETIREMENT", "SALE_OF_ASSETS", "SALES_OF_GOODS_AND_SERVICES", "THIRD_PARTY_FUNDS", "TREASURY_RESERVES"]).optional().describe("Main source of funds"),
38
+ accountPurpose: z.enum(["CHARITABLE_DONATIONS", "ECOMMERCE_RETAIL_PAYMENTS", "INVESTMENT_PURPOSES", "PAYMENTS_TO_FRIENDS_OR_FAMILY_ABROAD", "PAYROLL", "PERSONAL_OR_LIVING_EXPENSES", "PROTECT_WEALTH", "PURCHASE_GOODS_AND_SERVICES", "RECEIVE_PAYMENTS_FOR_GOODS_AND_SERVICES", "TAX_OPTIMIZATION", "THIRD_PARTY_MONEY_TRANSMISSION", "TREASURY_MANAGEMENT", "OTHER"]).optional().describe("What will you use Stables for?"),
39
+ accountPurposeOther: z.string().optional().describe("Explain purpose (required if accountPurpose is OTHER)"),
40
+ isYourBusinessADao: z.boolean().optional().describe("Is your business a DAO?"),
41
+ industrySelection: z.string().optional().describe("NAICS industry code (e.g., '5415')"),
42
+ expectedAnnualRevenue: z.enum(["0_99999", "100000_999999", "1000000_9999999", "10000000_49999999", "50000000_249999999", "250000000_plus"]).optional().describe("Estimated annual revenue in USD"),
43
+ expectedMonthlyPayments: z.string().optional().describe("Expected monthly payments in USD"),
44
+ sourceOfFunds: z.enum(["BUSINESS_LOANS", "GRANTS", "INTER_COMPANY_FUNDS", "INVESTMENT_PROCEEDS", "LEGAL_SETTLEMENT", "OWNERS_CAPITAL", "PENSION_RETIREMENT", "SALE_OF_ASSETS", "SALES_OF_GOODS_AND_SERVICES", "THIRD_PARTY_FUNDS", "TREASURY_RESERVES"]).optional().describe("Source of funds"),
45
+ sourceOfFundsDescription: z.string().optional().describe("Describe where your business funds come from"),
46
+ operateInProhibitedCountry: z.boolean().optional().describe("Does your business operate in any prohibited countries?"),
47
+ doesYourBusinessEngageInHighRiskActivities: z.enum(["yes", "no"]).optional().describe("Does your business engage in high risk activities?"),
48
+ acceptTerms: z.boolean().optional().describe("Accept Stables' terms of service and privacy policy"),
49
+ howDidYouComeAcrossStables: z.string().optional().describe("How did you come across Stables?"),
50
+ // Shared fields
15
51
  externalCustomerId: z.string().optional().describe("Your own reference ID for this customer"),
16
52
  phone: z.string().optional().describe("Phone number with country code (e.g., '+14155552671')"),
17
- dob: z.string().optional().describe("Date of birth in YYYY-MM-DD format (e.g., '1990-01-15')"),
18
- nationality: z.string().optional().describe("Two-letter country code (e.g., 'US', 'GB')"),
19
- entitlements: z.array(z.string()).optional().describe("List of entitlements to request (e.g., ['base_payout', 'virtual_account'])"),
53
+ entitlements: z.array(z.enum(["base_payout", "virtual_account"])).optional().describe("List of entitlements to request"),
54
+ // Address fields (for individuals)
20
55
  addressLine1: z.string().optional().describe("Street address line 1"),
21
56
  addressLine2: z.string().optional().describe("Street address line 2"),
22
57
  addressCity: z.string().optional().describe("City"),
23
58
  addressState: z.string().optional().describe("State or region"),
24
59
  addressPostalCode: z.string().optional().describe("Postal/ZIP code"),
25
60
  addressCountry: z.string().optional().describe("Two-letter country code (e.g., 'US')"),
26
- }, async ({ email, customerType, firstName, lastName, middleName, companyName, externalCustomerId, phone, dob, nationality, entitlements, addressLine1, addressLine2, addressCity, addressState, addressPostalCode, addressCountry }) => {
61
+ // Legal address fields (for businesses)
62
+ legalAddressLine1: z.string().optional().describe("Legal address line 1 (for businesses)"),
63
+ legalAddressLine2: z.string().optional().describe("Legal address line 2 (for businesses)"),
64
+ legalAddressCity: z.string().optional().describe("Legal address city (for businesses)"),
65
+ legalAddressState: z.string().optional().describe("Legal address state (for businesses)"),
66
+ legalAddressPostalCode: z.string().optional().describe("Legal address postal code (for businesses)"),
67
+ legalAddressCountry: z.string().optional().describe("Legal address country code (for businesses)"),
68
+ }, async (params) => {
27
69
  try {
28
- const address = addressLine1 ? {
29
- line1: addressLine1,
30
- line2: addressLine2,
31
- city: addressCity || "",
32
- state: addressState,
33
- postalCode: addressPostalCode,
34
- country: addressCountry || "",
70
+ const isBusiness = params.customerType === "business";
71
+ // Build address for individuals
72
+ const address = (!isBusiness && params.addressLine1) ? {
73
+ line1: params.addressLine1,
74
+ line2: params.addressLine2,
75
+ city: params.addressCity || "",
76
+ state: params.addressState,
77
+ postalCode: params.addressPostalCode,
78
+ country: params.addressCountry || "",
35
79
  } : undefined;
36
- const customer = await client.createCustomer({
37
- email,
38
- customerType: customerType === "individual"
39
- ? "CUSTOMER_TYPE_INDIVIDUAL"
40
- : "CUSTOMER_TYPE_BUSINESS",
41
- firstName,
42
- lastName,
43
- middleName,
44
- companyName,
45
- externalCustomerId: externalCustomerId || crypto.randomUUID(),
46
- phone,
47
- dob,
48
- nationality,
49
- entitlements,
50
- address,
51
- });
80
+ // Build legal address for businesses
81
+ const legalAddress = (isBusiness && params.legalAddressLine1) ? {
82
+ line1: params.legalAddressLine1,
83
+ line2: params.legalAddressLine2,
84
+ city: params.legalAddressCity || "",
85
+ state: params.legalAddressState,
86
+ postalCode: params.legalAddressPostalCode,
87
+ country: params.legalAddressCountry || "",
88
+ } : undefined;
89
+ // Build request body based on customer type
90
+ const requestBody = {
91
+ email: params.email,
92
+ customerType: isBusiness ? "CUSTOMER_TYPE_BUSINESS" : "CUSTOMER_TYPE_INDIVIDUAL",
93
+ externalCustomerId: params.externalCustomerId || crypto.randomUUID(),
94
+ phone: params.phone,
95
+ entitlements: params.entitlements,
96
+ };
97
+ if (isBusiness) {
98
+ Object.assign(requestBody, {
99
+ companyName: params.companyName,
100
+ country: params.country,
101
+ registrationNumber: params.registrationNumber,
102
+ incorporatedOn: params.incorporatedOn,
103
+ type: params.type,
104
+ taxId: params.taxId,
105
+ registrationLocation: params.registrationLocation,
106
+ website: params.website,
107
+ legalAddress,
108
+ describeBusiness: params.describeBusiness,
109
+ conductMoneyServices: params.conductMoneyServices,
110
+ describeMoneyServices: params.describeMoneyServices,
111
+ describeComplianceControls: params.describeComplianceControls,
112
+ mainSourceOfFunds: params.mainSourceOfFunds,
113
+ accountPurpose: params.accountPurpose,
114
+ accountPurposeOther: params.accountPurposeOther,
115
+ isYourBusinessADao: params.isYourBusinessADao,
116
+ industrySelection: params.industrySelection,
117
+ expectedAnnualRevenue: params.expectedAnnualRevenue,
118
+ expectedMonthlyPayments: params.expectedMonthlyPayments,
119
+ sourceOfFunds: params.sourceOfFunds,
120
+ sourceOfFundsDescription: params.sourceOfFundsDescription,
121
+ operateInProhibitedCountry: params.operateInProhibitedCountry,
122
+ doesYourBusinessEngageInHighRiskActivities: params.doesYourBusinessEngageInHighRiskActivities,
123
+ acceptTerms: params.acceptTerms,
124
+ howDidYouComeAcrossStables: params.howDidYouComeAcrossStables,
125
+ });
126
+ }
127
+ else {
128
+ Object.assign(requestBody, {
129
+ firstName: params.firstName,
130
+ lastName: params.lastName,
131
+ middleName: params.middleName,
132
+ dob: params.dob,
133
+ nationality: params.nationality,
134
+ address,
135
+ });
136
+ }
137
+ // Remove undefined values
138
+ for (const key of Object.keys(requestBody)) {
139
+ if (requestBody[key] === undefined)
140
+ delete requestBody[key];
141
+ }
142
+ const customer = await client.createCustomer(requestBody);
52
143
  const verificationStatus = customer.verificationLevels?.[0]?.status || "NOT_STARTED";
53
144
  const entitlementsList = customer.entitlements?.map(e => `${e.name}: ${e.status}`).join(", ") || "None";
54
145
  return {
@@ -59,11 +150,11 @@ export function registerCustomerTools(server, client) {
59
150
 
60
151
  Customer ID: ${customer.customerId}
61
152
  Email: ${customer.email}
62
- Type: ${customerType}
63
- ${firstName ? `Name: ${firstName}${middleName ? ` ${middleName}` : ""} ${lastName || ""}` : ""}
64
- ${companyName ? `Company: ${companyName}` : ""}
65
- ${phone ? `Phone: ${phone}` : ""}
66
- ${nationality ? `Nationality: ${nationality}` : ""}
153
+ Type: ${params.customerType}
154
+ ${params.firstName ? `Name: ${params.firstName}${params.middleName ? ` ${params.middleName}` : ""} ${params.lastName || ""}` : ""}
155
+ ${params.companyName ? `Company: ${params.companyName}` : ""}
156
+ ${params.phone ? `Phone: ${params.phone}` : ""}
157
+ ${params.nationality ? `Nationality: ${params.nationality}` : ""}
67
158
  Entitlements: ${entitlementsList}
68
159
  Verification Status: ${verificationStatus}
69
160
  Created: ${customer.createdAt}
@@ -78,7 +169,7 @@ Next step: Use 'get_verification_link' to get a KYC verification link for this c
78
169
  content: [
79
170
  {
80
171
  type: "text",
81
- text: `Failed to create customer: ${error instanceof Error ? error.message : "Unknown error"}`,
172
+ text: `Failed to create customer: ${formatError(error)}`,
82
173
  },
83
174
  ],
84
175
  isError: true,
@@ -120,7 +211,7 @@ Updated: ${customer.updatedAt}`,
120
211
  content: [
121
212
  {
122
213
  type: "text",
123
- text: `Failed to get customer: ${error instanceof Error ? error.message : "Unknown error"}`,
214
+ text: `Failed to get customer: ${formatError(error)}`,
124
215
  },
125
216
  ],
126
217
  isError: true,
@@ -161,7 +252,7 @@ ${customerList}`,
161
252
  content: [
162
253
  {
163
254
  type: "text",
164
- text: `Failed to list customers: ${error instanceof Error ? error.message : "Unknown error"}`,
255
+ text: `Failed to list customers: ${formatError(error)}`,
165
256
  },
166
257
  ],
167
258
  isError: true,
@@ -205,7 +296,7 @@ Share this link with the customer to complete their identity verification.`,
205
296
  content: [
206
297
  {
207
298
  type: "text",
208
- text: `Failed to generate verification link: ${error instanceof Error ? error.message : "Unknown error"}`,
299
+ text: `Failed to generate verification link: ${formatError(error)}`,
209
300
  },
210
301
  ],
211
302
  isError: true,
@@ -219,8 +310,12 @@ Share this link with the customer to complete their identity verification.`,
219
310
  phone: z.string().optional().describe("Updated phone number"),
220
311
  firstName: z.string().optional().describe("Updated first name"),
221
312
  lastName: z.string().optional().describe("Updated last name"),
222
- entitlements: z.array(z.string()).optional().describe("Updated entitlements (e.g., ['base_payout', 'virtual_account'])"),
223
- }, async ({ customerId, email, phone, firstName, lastName, entitlements }) => {
313
+ middleName: z.string().optional().describe("Updated middle name"),
314
+ dob: z.string().optional().describe("Updated date of birth (YYYY-MM-DD)"),
315
+ nationality: z.string().optional().describe("Updated nationality (two-letter country code)"),
316
+ companyName: z.string().optional().describe("Updated company name (for businesses)"),
317
+ entitlements: z.array(z.enum(["base_payout", "virtual_account"])).optional().describe("Updated entitlements"),
318
+ }, async ({ customerId, email, phone, firstName, lastName, middleName, dob, nationality, companyName, entitlements }) => {
224
319
  try {
225
320
  const updates = {};
226
321
  if (email)
@@ -231,6 +326,14 @@ Share this link with the customer to complete their identity verification.`,
231
326
  updates.firstName = firstName;
232
327
  if (lastName)
233
328
  updates.lastName = lastName;
329
+ if (middleName)
330
+ updates.middleName = middleName;
331
+ if (dob)
332
+ updates.dob = dob;
333
+ if (nationality)
334
+ updates.nationality = nationality;
335
+ if (companyName)
336
+ updates.companyName = companyName;
234
337
  if (entitlements)
235
338
  updates.entitlements = entitlements;
236
339
  const customer = await client.updateCustomer(customerId, updates);
@@ -242,6 +345,7 @@ Share this link with the customer to complete their identity verification.`,
242
345
 
243
346
  Email: ${customer.email}
244
347
  ${customer.firstName ? `Name: ${customer.firstName} ${customer.lastName || ""}` : ""}
348
+ ${customer.companyName ? `Company: ${customer.companyName}` : ""}
245
349
  Updated: ${customer.updatedAt}`,
246
350
  },
247
351
  ],
@@ -252,7 +356,7 @@ Updated: ${customer.updatedAt}`,
252
356
  content: [
253
357
  {
254
358
  type: "text",
255
- text: `Failed to update customer: ${error instanceof Error ? error.message : "Unknown error"}`,
359
+ text: `Failed to update customer: ${formatError(error)}`,
256
360
  },
257
361
  ],
258
362
  isError: true,
@@ -282,7 +386,7 @@ Keys set: ${Object.keys(metadata).join(", ")}`,
282
386
  content: [
283
387
  {
284
388
  type: "text",
285
- text: `Failed to update metadata: ${error instanceof Error ? error.message : "Unknown error"}`,
389
+ text: `Failed to update metadata: ${formatError(error)}`,
286
390
  },
287
391
  ],
288
392
  isError: true,