rwagenthub-mcp 1.0.9 → 1.0.10

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 (2) hide show
  1. package/index.js +47 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -172,6 +172,53 @@ async function main() {
172
172
  }
173
173
  );
174
174
 
175
+ server.tool(
176
+ "recover_token",
177
+ "Recover your AgentHub token using your wallet signature. Use this if you lost your MCP_BALANCE_TOKEN. Signs a challenge with MCP_WALLET_PRIVATE_KEY automatically — no manual signing needed.",
178
+ {},
179
+ async () => {
180
+ try {
181
+ // 1. Get challenge
182
+ const challengeRes = await fetch(`${GATEWAY_URL}/v1/user/recover/challenge?wallet=${account.address}`);
183
+ const { message } = await challengeRes.json();
184
+ if (!message) return { content: [{ type: "text", text: "Failed to get recovery challenge from gateway." }], isError: true };
185
+
186
+ // 2. Sign with wallet
187
+ const signature = await signer.signMessage({ message });
188
+
189
+ // 3. Recover tokens
190
+ const recoverRes = await fetch(`${GATEWAY_URL}/v1/user/recover`, {
191
+ method: "POST",
192
+ headers: { "Content-Type": "application/json" },
193
+ body: JSON.stringify({ wallet: account.address, signature }),
194
+ });
195
+ const result = await recoverRes.json();
196
+
197
+ if (!result.tokens?.length) {
198
+ return { content: [{ type: "text", text: `No tokens found for wallet ${account.address}.\nTop up first with topup_balance.` }], isError: true };
199
+ }
200
+
201
+ // 4. Activate the first token in this session
202
+ balanceToken = result.tokens[0];
203
+
204
+ const balRes = await fetch(`${GATEWAY_URL}/v1/user/balance`, {
205
+ headers: { "Authorization": `Bearer ${balanceToken}` },
206
+ });
207
+ const bal = await balRes.json();
208
+
209
+ const allTokens = result.tokens.length > 1
210
+ ? `\n\nAll tokens for this wallet:\n${result.tokens.map((t, i) => ` ${i + 1}. ${t}`).join("\n")}`
211
+ : "";
212
+
213
+ return {
214
+ content: [{ type: "text", text: `Token recovered successfully!\n\nToken: ${balanceToken}\nWallet: ${account.address}\nAvailable: $${bal.balance_usd} USDC\n\nThis session is now using the recovered token.\nSave it for future sessions:\n MCP_BALANCE_TOKEN=${balanceToken}${allTokens}` }],
215
+ };
216
+ } catch (err) {
217
+ return { content: [{ type: "text", text: `Recovery error: ${err.message}` }], isError: true };
218
+ }
219
+ }
220
+ );
221
+
175
222
  // ── API tools (dynamic from gateway schema) ────────────────────────────────
176
223
  for (const api of apis) {
177
224
  const { properties = {}, required: requiredList = [] } = api.inputSchema ?? {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwagenthub-mcp",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "MCP server for AgentHub — 32 AI APIs (flights, weather, crypto, stocks, DeFi, web scraping, geocoding, IP reputation, blockchain data...) paid via x402 USDC on Base",
5
5
  "type": "module",
6
6
  "bin": {