@agentwonderland/mcp 0.1.20 → 0.1.22

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/index.js CHANGED
@@ -42,6 +42,10 @@ export async function startMcpServer() {
42
42
  "- Payment is automatic once configured. Users are never charged for failed runs.",
43
43
  "- Do NOT ask the user to set up payment before they try to run an agent. Let them explore freely — payment setup is handled inline when they're ready to pay.",
44
44
  "",
45
+ "MANAGING PAYMENT METHODS:",
46
+ "- To remove a card: wallet_setup({ action: \"remove-card\" })",
47
+ "- To remove or modify a crypto wallet: NEVER do this programmatically. Direct users to edit their config files manually (~/.agentwonderland/config.json or ~/.ows/). We do not handle private key deletion or modification to avoid any risk of key loss.",
48
+ "",
45
49
  "REQUIRED FIELDS:",
46
50
  "Always check the agent's input schema (via get_agent) before calling run_agent.",
47
51
  "Include ALL required fields in the first attempt to avoid validation errors.",
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { getWallets, getCardConfig, addWallet } from "../core/config.js";
2
+ import { getWallets, getCardConfig, setCardConfig, addWallet } from "../core/config.js";
3
3
  import { getWalletAddress } from "../core/payments.js";
4
4
  import { initiateCardSetup, pollCardSetup } from "../core/card-setup.js";
5
5
  import { isOwsAvailable, createOwsWallet, importKeyToOws, listOwsWallets, } from "../core/ows-adapter.js";
@@ -29,10 +29,10 @@ export function registerWalletTools(server) {
29
29
  return text(lines.join("\n"));
30
30
  });
31
31
  // ── wallet_setup (NEW) ──────────────────────────────────────────
32
- server.tool("wallet_setup", "Set up a payment method for running agents. Options: 'create' a crypto wallet, 'import' an existing key, or 'add-card' to connect a credit/debit card via QR code. Card setup shows a scannable QR code call again after the user enters their card to confirm.", {
32
+ server.tool("wallet_setup", "Set up or manage payment methods. Options: 'add-card' to connect a credit/debit card (recommended), 'remove-card' to disconnect a card, 'create' a crypto wallet, or 'import' an existing key. For crypto wallet changes (removal, key rotation), direct users to edit their config files manually never handle private keys programmatically.", {
33
33
  action: z
34
- .enum(["create", "import", "add-card"])
35
- .describe("'create' a new crypto wallet, 'import' an existing private key, or 'add-card' to connect a credit/debit card"),
34
+ .enum(["create", "import", "add-card", "remove-card"])
35
+ .describe("'add-card' to connect a card, 'remove-card' to disconnect it, 'create' a crypto wallet, or 'import' an existing key"),
36
36
  name: z
37
37
  .string()
38
38
  .optional()
@@ -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: You MUST present this link to the user so they can connect a payment card:`,
87
+ `IMPORTANT: Present this link to the user to connect a payment card:`,
72
88
  "",
73
89
  url,
74
90
  "",
@@ -82,6 +98,15 @@ export function registerWalletTools(server) {
82
98
  return text("Error: Could not create card setup session. Try again later.");
83
99
  }
84
100
  }
101
+ // ── Card removal ─────────────────────────────────────────
102
+ if (action === "remove-card") {
103
+ const existing = getCardConfig();
104
+ if (!existing) {
105
+ return text("No card is currently connected.");
106
+ }
107
+ setCardConfig(null);
108
+ return text(`Removed ${existing.brand} ****${existing.last4}. Card disconnected from Agent Wonderland.`);
109
+ }
85
110
  // ── Crypto wallet setup ──────────────────────────────────
86
111
  if (action === "import" && !key) {
87
112
  return text("Error: 'key' parameter is required when action is 'import'.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentwonderland/mcp",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "type": "module",
5
5
  "description": "MCP server for the Agent Wonderland AI agent marketplace",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -49,6 +49,10 @@ export async function startMcpServer(): Promise<void> {
49
49
  "- Payment is automatic once configured. Users are never charged for failed runs.",
50
50
  "- Do NOT ask the user to set up payment before they try to run an agent. Let them explore freely — payment setup is handled inline when they're ready to pay.",
51
51
  "",
52
+ "MANAGING PAYMENT METHODS:",
53
+ "- To remove a card: wallet_setup({ action: \"remove-card\" })",
54
+ "- To remove or modify a crypto wallet: NEVER do this programmatically. Direct users to edit their config files manually (~/.agentwonderland/config.json or ~/.ows/). We do not handle private key deletion or modification to avoid any risk of key loss.",
55
+ "",
52
56
  "REQUIRED FIELDS:",
53
57
  "Always check the agent's input schema (via get_agent) before calling run_agent.",
54
58
  "Include ALL required fields in the first attempt to avoid validation errors.",
@@ -56,11 +56,11 @@ export function registerWalletTools(server: McpServer): void {
56
56
  // ── wallet_setup (NEW) ──────────────────────────────────────────
57
57
  server.tool(
58
58
  "wallet_setup",
59
- "Set up a payment method for running agents. Options: 'create' a crypto wallet, 'import' an existing key, or 'add-card' to connect a credit/debit card via QR code. Card setup shows a scannable QR code call again after the user enters their card to confirm.",
59
+ "Set up or manage payment methods. Options: 'add-card' to connect a credit/debit card (recommended), 'remove-card' to disconnect a card, 'create' a crypto wallet, or 'import' an existing key. For crypto wallet changes (removal, key rotation), direct users to edit their config files manually never handle private keys programmatically.",
60
60
  {
61
61
  action: z
62
- .enum(["create", "import", "add-card"])
63
- .describe("'create' a new crypto wallet, 'import' an existing private key, or 'add-card' to connect a credit/debit card"),
62
+ .enum(["create", "import", "add-card", "remove-card"])
63
+ .describe("'add-card' to connect a card, 'remove-card' to disconnect it, 'create' a crypto wallet, or 'import' an existing key"),
64
64
  name: z
65
65
  .string()
66
66
  .optional()
@@ -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: You MUST present this link to the user so they can connect a payment card:`,
124
+ `IMPORTANT: Present this link to the user to connect a payment card:`,
107
125
  "",
108
126
  url,
109
127
  "",
@@ -117,6 +135,17 @@ export function registerWalletTools(server: McpServer): void {
117
135
  }
118
136
  }
119
137
 
138
+ // ── Card removal ─────────────────────────────────────────
139
+ if (action === "remove-card") {
140
+ const existing = getCardConfig();
141
+ if (!existing) {
142
+ return text("No card is currently connected.");
143
+ }
144
+
145
+ setCardConfig(null);
146
+ return text(`Removed ${existing.brand} ****${existing.last4}. Card disconnected from Agent Wonderland.`);
147
+ }
148
+
120
149
  // ── Crypto wallet setup ──────────────────────────────────
121
150
  if (action === "import" && !key) {
122
151
  return text(