stables-mcp-server 1.4.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +70 -48
  2. package/build/index.js +3 -3
  3. package/build/index.js.map +1 -1
  4. package/build/lib/stables-client.d.ts +313 -136
  5. package/build/lib/stables-client.d.ts.map +1 -1
  6. package/build/lib/stables-client.js +107 -19
  7. package/build/lib/stables-client.js.map +1 -1
  8. package/build/tools/api-keys.d.ts.map +1 -1
  9. package/build/tools/api-keys.js +7 -3
  10. package/build/tools/api-keys.js.map +1 -1
  11. package/build/tools/customers.d.ts.map +1 -1
  12. package/build/tools/customers.js +239 -106
  13. package/build/tools/customers.js.map +1 -1
  14. package/build/tools/quotes.d.ts +5 -1
  15. package/build/tools/quotes.d.ts.map +1 -1
  16. package/build/tools/quotes.js +103 -59
  17. package/build/tools/quotes.js.map +1 -1
  18. package/build/tools/sandbox.d.ts +11 -0
  19. package/build/tools/sandbox.d.ts.map +1 -0
  20. package/build/tools/sandbox.js +78 -0
  21. package/build/tools/sandbox.js.map +1 -0
  22. package/build/tools/transfers.d.ts +4 -1
  23. package/build/tools/transfers.d.ts.map +1 -1
  24. package/build/tools/transfers.js +212 -112
  25. package/build/tools/transfers.js.map +1 -1
  26. package/build/tools/virtual-accounts.d.ts.map +1 -1
  27. package/build/tools/virtual-accounts.js +127 -84
  28. package/build/tools/virtual-accounts.js.map +1 -1
  29. package/build/tools/webhooks.d.ts.map +1 -1
  30. package/build/tools/webhooks.js +98 -24
  31. package/build/tools/webhooks.js.map +1 -1
  32. package/package.json +12 -4
  33. package/build/tools/notifications.d.ts +0 -8
  34. package/build/tools/notifications.d.ts.map +0 -1
  35. package/build/tools/notifications.js +0 -125
  36. package/build/tools/notifications.js.map +0 -1
@@ -1,125 +0,0 @@
1
- import { z } from "zod";
2
- import { StablesApiError } from "../lib/stables-client.js";
3
- function formatError(error) {
4
- if (error instanceof StablesApiError) {
5
- return `${error.message} (HTTP ${error.statusCode})`;
6
- }
7
- return error instanceof Error ? error.message : "Unknown error";
8
- }
9
- export function registerNotificationTools(server, client) {
10
- server.tool("send_verification_sms", "Send a KYC verification link to a customer via SMS. Automatically fetches the customer's phone number and generates a fresh verification link. Requires TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, and TWILIO_PHONE_NUMBER environment variables.", {
11
- customerId: z
12
- .string()
13
- .describe("The customer ID to send the verification SMS to"),
14
- phone: z
15
- .string()
16
- .optional()
17
- .describe("Override phone number (with country code, e.g., '+14155552671'). If not provided, uses the customer's phone on file."),
18
- botName: z
19
- .string()
20
- .optional()
21
- .describe("Name of the bot/assistant sending the message (default: 'your assistant')"),
22
- verificationLinkTtlSecs: z
23
- .number()
24
- .optional()
25
- .describe("TTL for the verification link in seconds (default: 1800)"),
26
- }, async ({ customerId, phone, botName, verificationLinkTtlSecs }) => {
27
- try {
28
- // 1. Validate Twilio environment variables
29
- const twilioAccountSid = process.env.TWILIO_ACCOUNT_SID;
30
- const twilioAuthToken = process.env.TWILIO_AUTH_TOKEN;
31
- const twilioPhoneNumber = process.env.TWILIO_PHONE_NUMBER;
32
- if (!twilioAccountSid || !twilioAuthToken || !twilioPhoneNumber) {
33
- return {
34
- content: [
35
- {
36
- type: "text",
37
- text: "Missing Twilio configuration. Please set TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, and TWILIO_PHONE_NUMBER environment variables.",
38
- },
39
- ],
40
- isError: true,
41
- };
42
- }
43
- // 2. Fetch customer details to get phone and name
44
- const customer = await client.getCustomer(customerId);
45
- const recipientPhone = phone || customer.phone;
46
- if (!recipientPhone) {
47
- return {
48
- content: [
49
- {
50
- type: "text",
51
- text: `Customer ${customerId} has no phone number on file. Please provide a phone number via the 'phone' parameter or update the customer's phone first using 'update_customer'.`,
52
- },
53
- ],
54
- isError: true,
55
- };
56
- }
57
- const customerName = customer.firstName || "there";
58
- const assistantName = botName || "your assistant";
59
- // 3. Generate a fresh verification link
60
- const verificationResult = await client.generateVerificationLink(customerId, { ttlInSecs: verificationLinkTtlSecs });
61
- const verificationLink = verificationResult.kycLink;
62
- // 4. Compose the SMS message
63
- const messageBody = `Hi ${customerName}, I'm ${assistantName}. Please complete verification to give me access to global commerce payment rails: ${verificationLink}`;
64
- // 5. Send SMS via Twilio REST API (using native fetch, no SDK needed)
65
- const twilioUrl = `https://api.twilio.com/2010-04-01/Accounts/${twilioAccountSid}/Messages.json`;
66
- const authHeader = "Basic " +
67
- Buffer.from(`${twilioAccountSid}:${twilioAuthToken}`).toString("base64");
68
- const formBody = new URLSearchParams({
69
- To: recipientPhone,
70
- From: twilioPhoneNumber,
71
- Body: messageBody,
72
- });
73
- const twilioResponse = await fetch(twilioUrl, {
74
- method: "POST",
75
- headers: {
76
- Authorization: authHeader,
77
- "Content-Type": "application/x-www-form-urlencoded",
78
- },
79
- body: formBody.toString(),
80
- });
81
- if (!twilioResponse.ok) {
82
- const errorData = await twilioResponse
83
- .json()
84
- .catch(() => null);
85
- const errorMsg = errorData?.message ||
86
- `HTTP ${twilioResponse.status}: ${twilioResponse.statusText}`;
87
- throw new Error(`Twilio API error: ${errorMsg}`);
88
- }
89
- const smsResult = (await twilioResponse.json());
90
- // 6. Return success
91
- const ttlDisplay = verificationLinkTtlSecs
92
- ? `${Math.floor(verificationLinkTtlSecs / 60)} minutes`
93
- : "30 minutes (default)";
94
- return {
95
- content: [
96
- {
97
- type: "text",
98
- text: `Verification SMS sent successfully!
99
-
100
- Customer ID: ${customerId}
101
- Customer Name: ${customerName}
102
- Sent To: ${recipientPhone}
103
- Twilio Message SID: ${smsResult.sid}
104
- Status: ${smsResult.status}
105
-
106
- Verification link expires in ${ttlDisplay}.
107
- The customer will receive an SMS with a link to complete KYC verification.`,
108
- },
109
- ],
110
- };
111
- }
112
- catch (error) {
113
- return {
114
- content: [
115
- {
116
- type: "text",
117
- text: `Failed to send verification SMS: ${formatError(error)}`,
118
- },
119
- ],
120
- isError: true,
121
- };
122
- }
123
- });
124
- }
125
- //# sourceMappingURL=notifications.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/tools/notifications.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE7E,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;QACrC,OAAO,GAAG,KAAK,CAAC,OAAO,UAAU,KAAK,CAAC,UAAU,GAAG,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,MAAiB,EACjB,MAAwB;IAExB,MAAM,CAAC,IAAI,CACT,uBAAuB,EACvB,+OAA+O,EAC/O;QACE,UAAU,EAAE,CAAC;aACV,MAAM,EAAE;aACR,QAAQ,CAAC,iDAAiD,CAAC;QAC9D,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,sHAAsH,CACvH;QACH,OAAO,EAAE,CAAC;aACP,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,2EAA2E,CAC5E;QACH,uBAAuB,EAAE,CAAC;aACvB,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,0DAA0D,CAC3D;KACJ,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAuB,EAAE,EAAE,EAAE;QAChE,IAAI,CAAC;YACH,2CAA2C;YAC3C,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;YACxD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;YACtD,MAAM,iBAAiB,GAAG,O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