@agentwonderland/mcp 0.1.20 → 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/tools/wallet.js +19 -3
- package/package.json +1 -1
- package/src/tools/wallet.ts +22 -4
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/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
|
"",
|