@agentwonderland/mcp 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/card-setup.js +4 -1
- package/dist/tools/wallet.js +19 -3
- package/package.json +1 -1
- package/src/core/card-setup.ts +5 -1
- package/src/tools/wallet.ts +22 -4
package/dist/core/card-setup.js
CHANGED
|
@@ -10,11 +10,14 @@ export async function initiateCardSetup() {
|
|
|
10
10
|
// Short redirect URL keeps the QR code small and scannable
|
|
11
11
|
const apiUrl = getApiUrl();
|
|
12
12
|
const shortUrl = `${apiUrl}/card/link/${token}`;
|
|
13
|
-
const
|
|
13
|
+
const rawQr = await QRCode.toString(shortUrl, {
|
|
14
14
|
type: "utf8",
|
|
15
15
|
errorCorrectionLevel: "L",
|
|
16
16
|
margin: 2,
|
|
17
17
|
});
|
|
18
|
+
// Pad every line with consistent leading spaces so the QR aligns
|
|
19
|
+
// properly in terminal renderers that add prefixes to the first line
|
|
20
|
+
const qr = rawQr.split("\n").map((line) => " " + line).join("\n");
|
|
18
21
|
return { qr, url: shortUrl, token };
|
|
19
22
|
}
|
|
20
23
|
/**
|
package/dist/tools/wallet.js
CHANGED
|
@@ -53,22 +53,38 @@ export function registerWalletTools(server) {
|
|
|
53
53
|
// Check if there's a pending setup to complete (user said they're done)
|
|
54
54
|
if (pendingCardSetup) {
|
|
55
55
|
const pendingToken = pendingCardSetup.token;
|
|
56
|
-
const result = await pollCardSetup(pendingToken);
|
|
56
|
+
const result = await pollCardSetup(pendingToken, 120_000);
|
|
57
57
|
pendingCardSetup = null;
|
|
58
58
|
if (result) {
|
|
59
59
|
return text(`Connected! ${result.brand} ****${result.last4} is ready for payments.`);
|
|
60
60
|
}
|
|
61
61
|
return text("Card setup timed out. Run wallet_setup({ action: \"add-card\" }) to try again.");
|
|
62
62
|
}
|
|
63
|
-
// Create new card setup session with QR code
|
|
63
|
+
// Create new card setup session with QR code, then auto-poll
|
|
64
64
|
try {
|
|
65
65
|
const { qr, url, token } = await initiateCardSetup();
|
|
66
|
+
// Auto-poll for up to 90 seconds — if the user enters their card
|
|
67
|
+
// quickly, the tool returns success without a second call
|
|
68
|
+
const result = await pollCardSetup(token, 90_000);
|
|
69
|
+
if (result) {
|
|
70
|
+
return {
|
|
71
|
+
content: [
|
|
72
|
+
{ type: "text", text: "\n" + qr.trim() },
|
|
73
|
+
{ type: "text", text: [
|
|
74
|
+
`Open to connect a card: ${url}`,
|
|
75
|
+
"",
|
|
76
|
+
`Connected! ${result.brand} ****${result.last4} is ready for payments.`,
|
|
77
|
+
].join("\n") },
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// Timed out — save token for manual follow-up
|
|
66
82
|
pendingCardSetup = { token };
|
|
67
83
|
return {
|
|
68
84
|
content: [
|
|
69
85
|
{ type: "text", text: "\n" + qr.trim() },
|
|
70
86
|
{ type: "text", text: [
|
|
71
|
-
`IMPORTANT:
|
|
87
|
+
`IMPORTANT: Present this link to the user to connect a payment card:`,
|
|
72
88
|
"",
|
|
73
89
|
url,
|
|
74
90
|
"",
|
package/package.json
CHANGED
package/src/core/card-setup.ts
CHANGED
|
@@ -17,12 +17,16 @@ export async function initiateCardSetup(): Promise<{
|
|
|
17
17
|
const apiUrl = getApiUrl();
|
|
18
18
|
const shortUrl = `${apiUrl}/card/link/${token}`;
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const rawQr = await QRCode.toString(shortUrl, {
|
|
21
21
|
type: "utf8",
|
|
22
22
|
errorCorrectionLevel: "L",
|
|
23
23
|
margin: 2,
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
// Pad every line with consistent leading spaces so the QR aligns
|
|
27
|
+
// properly in terminal renderers that add prefixes to the first line
|
|
28
|
+
const qr = rawQr.split("\n").map((line) => " " + line).join("\n");
|
|
29
|
+
|
|
26
30
|
return { qr, url: shortUrl, token };
|
|
27
31
|
}
|
|
28
32
|
|
package/src/tools/wallet.ts
CHANGED
|
@@ -85,7 +85,7 @@ export function registerWalletTools(server: McpServer): void {
|
|
|
85
85
|
// Check if there's a pending setup to complete (user said they're done)
|
|
86
86
|
if (pendingCardSetup) {
|
|
87
87
|
const pendingToken = pendingCardSetup.token;
|
|
88
|
-
const result = await pollCardSetup(pendingToken);
|
|
88
|
+
const result = await pollCardSetup(pendingToken, 120_000);
|
|
89
89
|
pendingCardSetup = null;
|
|
90
90
|
|
|
91
91
|
if (result) {
|
|
@@ -94,16 +94,34 @@ export function registerWalletTools(server: McpServer): void {
|
|
|
94
94
|
return text("Card setup timed out. Run wallet_setup({ action: \"add-card\" }) to try again.");
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
// Create new card setup session with QR code
|
|
97
|
+
// Create new card setup session with QR code, then auto-poll
|
|
98
98
|
try {
|
|
99
99
|
const { qr, url, token } = await initiateCardSetup();
|
|
100
|
-
pendingCardSetup = { token };
|
|
101
100
|
|
|
101
|
+
// Auto-poll for up to 90 seconds — if the user enters their card
|
|
102
|
+
// quickly, the tool returns success without a second call
|
|
103
|
+
const result = await pollCardSetup(token, 90_000);
|
|
104
|
+
|
|
105
|
+
if (result) {
|
|
106
|
+
return {
|
|
107
|
+
content: [
|
|
108
|
+
{ type: "text" as const, text: "\n" + qr.trim() },
|
|
109
|
+
{ type: "text" as const, text: [
|
|
110
|
+
`Open to connect a card: ${url}`,
|
|
111
|
+
"",
|
|
112
|
+
`Connected! ${result.brand} ****${result.last4} is ready for payments.`,
|
|
113
|
+
].join("\n") },
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Timed out — save token for manual follow-up
|
|
119
|
+
pendingCardSetup = { token };
|
|
102
120
|
return {
|
|
103
121
|
content: [
|
|
104
122
|
{ type: "text" as const, text: "\n" + qr.trim() },
|
|
105
123
|
{ type: "text" as const, text: [
|
|
106
|
-
`IMPORTANT:
|
|
124
|
+
`IMPORTANT: Present this link to the user to connect a payment card:`,
|
|
107
125
|
"",
|
|
108
126
|
url,
|
|
109
127
|
"",
|