httpcat-cli 0.3.0 → 0.3.1

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 (322) hide show
  1. package/.github/workflows/ci.yml +3 -0
  2. package/.github/workflows/rc-publish.yml +6 -0
  3. package/.github/workflows/release.yml +102 -0
  4. package/.github/workflows/sync-version.yml +31 -2
  5. package/README.md +1408 -109
  6. package/additions.txt +3 -0
  7. package/bun.lock +260 -25
  8. package/dist/agent/autonomous-trader.d.ts.map +1 -0
  9. package/dist/agent/autonomous-trader.js +362 -0
  10. package/dist/agent/autonomous-trader.js.map +1 -0
  11. package/dist/agent/ax-agent.d.ts.map +1 -1
  12. package/dist/agent/ax-agent.js +356 -18
  13. package/dist/agent/ax-agent.js.map +1 -1
  14. package/dist/agent/event-client.d.ts.map +1 -0
  15. package/dist/agent/event-client.js +82 -0
  16. package/dist/agent/event-client.js.map +1 -0
  17. package/dist/agent/log-stream.d.ts.map +1 -0
  18. package/dist/agent/log-stream.js +95 -0
  19. package/dist/agent/log-stream.js.map +1 -0
  20. package/dist/agent/memory/conversation-session.d.ts.map +1 -0
  21. package/dist/agent/memory/conversation-session.js +232 -0
  22. package/dist/agent/memory/conversation-session.js.map +1 -0
  23. package/dist/agent/memory/conversation-store.d.ts.map +1 -0
  24. package/dist/agent/memory/conversation-store.js +214 -0
  25. package/dist/agent/memory/conversation-store.js.map +1 -0
  26. package/dist/agent/memory/database-schema.d.ts.map +1 -0
  27. package/dist/agent/memory/database-schema.js +355 -0
  28. package/dist/agent/memory/database-schema.js.map +1 -0
  29. package/dist/agent/memory/decision-tracker.d.ts.map +1 -0
  30. package/dist/agent/memory/decision-tracker.js +274 -0
  31. package/dist/agent/memory/decision-tracker.js.map +1 -0
  32. package/dist/agent/memory/memory-manager.d.ts.map +1 -0
  33. package/dist/agent/memory/memory-manager.js +187 -0
  34. package/dist/agent/memory/memory-manager.js.map +1 -0
  35. package/dist/agent/memory/types.d.ts.map +1 -0
  36. package/dist/agent/memory/types.js +5 -0
  37. package/dist/agent/memory/types.js.map +1 -0
  38. package/dist/agent/message-formatter.d.ts.map +1 -0
  39. package/dist/agent/message-formatter.js +76 -0
  40. package/dist/agent/message-formatter.js.map +1 -0
  41. package/dist/agent/position-db.d.ts.map +1 -0
  42. package/dist/agent/position-db.js +154 -0
  43. package/dist/agent/position-db.js.map +1 -0
  44. package/dist/agent/simple-chat-ui-static.d.ts.map +1 -0
  45. package/dist/agent/simple-chat-ui-static.js +129 -0
  46. package/dist/agent/simple-chat-ui-static.js.map +1 -0
  47. package/dist/agent/simple-chat-ui.d.ts.map +1 -0
  48. package/dist/agent/simple-chat-ui.js +90 -0
  49. package/dist/agent/simple-chat-ui.js.map +1 -0
  50. package/dist/agent/tools.d.ts.map +1 -1
  51. package/dist/agent/tools.js +297 -4
  52. package/dist/agent/tools.js.map +1 -1
  53. package/dist/agent/ui.d.ts.map +1 -0
  54. package/dist/agent/ui.js +84 -0
  55. package/dist/agent/ui.js.map +1 -0
  56. package/dist/agent/unified-runtime.d.ts.map +1 -0
  57. package/dist/agent/unified-runtime.js +397 -0
  58. package/dist/agent/unified-runtime.js.map +1 -0
  59. package/dist/client.d.ts.map +1 -1
  60. package/dist/client.js +272 -21
  61. package/dist/client.js.map +1 -1
  62. package/dist/commands/account.d.ts.map +1 -1
  63. package/dist/commands/account.js +187 -33
  64. package/dist/commands/account.js.map +1 -1
  65. package/dist/commands/agent.d.ts.map +1 -0
  66. package/dist/commands/agent.js +125 -0
  67. package/dist/commands/agent.js.map +1 -0
  68. package/dist/commands/approve.d.ts.map +1 -0
  69. package/dist/commands/approve.js +505 -0
  70. package/dist/commands/approve.js.map +1 -0
  71. package/dist/commands/automation.d.ts.map +1 -0
  72. package/dist/commands/automation.js +346 -0
  73. package/dist/commands/automation.js.map +1 -0
  74. package/dist/commands/balances.d.ts.map +1 -1
  75. package/dist/commands/balances.js +226 -73
  76. package/dist/commands/balances.js.map +1 -1
  77. package/dist/commands/buy.d.ts.map +1 -1
  78. package/dist/commands/buy.js +149 -146
  79. package/dist/commands/buy.js.map +1 -1
  80. package/dist/commands/call.d.ts.map +1 -0
  81. package/dist/commands/call.js +51 -0
  82. package/dist/commands/call.js.map +1 -0
  83. package/dist/commands/cex.d.ts.map +1 -0
  84. package/dist/commands/cex.js +958 -0
  85. package/dist/commands/cex.js.map +1 -0
  86. package/dist/commands/chat.d.ts.map +1 -1
  87. package/dist/commands/chat.js +169 -411
  88. package/dist/commands/chat.js.map +1 -1
  89. package/dist/commands/claim.d.ts.map +1 -1
  90. package/dist/commands/claim.js +313 -29
  91. package/dist/commands/claim.js.map +1 -1
  92. package/dist/commands/create.d.ts.map +1 -1
  93. package/dist/commands/create.js +151 -43
  94. package/dist/commands/create.js.map +1 -1
  95. package/dist/commands/gasless-swap.d.ts.map +1 -0
  96. package/dist/commands/gasless-swap.js +232 -0
  97. package/dist/commands/gasless-swap.js.map +1 -0
  98. package/dist/commands/health.d.ts.map +1 -1
  99. package/dist/commands/health.js +63 -7
  100. package/dist/commands/health.js.map +1 -1
  101. package/dist/commands/info.d.ts.map +1 -1
  102. package/dist/commands/info.js +131 -47
  103. package/dist/commands/info.js.map +1 -1
  104. package/dist/commands/launchpad.d.ts.map +1 -0
  105. package/dist/commands/launchpad.js +708 -0
  106. package/dist/commands/launchpad.js.map +1 -0
  107. package/dist/commands/list.d.ts.map +1 -1
  108. package/dist/commands/list.js +57 -23
  109. package/dist/commands/list.js.map +1 -1
  110. package/dist/commands/market.d.ts.map +1 -0
  111. package/dist/commands/market.js +960 -0
  112. package/dist/commands/market.js.map +1 -0
  113. package/dist/commands/mcp-install.d.ts.map +1 -0
  114. package/dist/commands/mcp-install.js +387 -0
  115. package/dist/commands/mcp-install.js.map +1 -0
  116. package/dist/commands/opps.d.ts.map +1 -0
  117. package/dist/commands/opps.js +409 -0
  118. package/dist/commands/opps.js.map +1 -0
  119. package/dist/commands/perps.d.ts.map +1 -0
  120. package/dist/commands/perps.js +248 -0
  121. package/dist/commands/perps.js.map +1 -0
  122. package/dist/commands/portfolio.d.ts.map +1 -0
  123. package/dist/commands/portfolio.js +679 -0
  124. package/dist/commands/portfolio.js.map +1 -0
  125. package/dist/commands/positions.d.ts.map +1 -1
  126. package/dist/commands/positions.js +76 -47
  127. package/dist/commands/positions.js.map +1 -1
  128. package/dist/commands/predict.d.ts.map +1 -0
  129. package/dist/commands/predict.js +280 -0
  130. package/dist/commands/predict.js.map +1 -0
  131. package/dist/commands/predictions.d.ts.map +1 -0
  132. package/dist/commands/predictions.js +486 -0
  133. package/dist/commands/predictions.js.map +1 -0
  134. package/dist/commands/risk.d.ts.map +1 -0
  135. package/dist/commands/risk.js +225 -0
  136. package/dist/commands/risk.js.map +1 -0
  137. package/dist/commands/security.d.ts.map +1 -0
  138. package/dist/commands/security.js +244 -0
  139. package/dist/commands/security.js.map +1 -0
  140. package/dist/commands/sell.d.ts.map +1 -1
  141. package/dist/commands/sell.js +67 -34
  142. package/dist/commands/sell.js.map +1 -1
  143. package/dist/commands/send.d.ts.map +1 -0
  144. package/dist/commands/send.js +733 -0
  145. package/dist/commands/send.js.map +1 -0
  146. package/dist/commands/sign.d.ts.map +1 -0
  147. package/dist/commands/sign.js +1048 -0
  148. package/dist/commands/sign.js.map +1 -0
  149. package/dist/commands/swap.d.ts.map +1 -0
  150. package/dist/commands/swap.js +744 -0
  151. package/dist/commands/swap.js.map +1 -0
  152. package/dist/commands/system.d.ts.map +1 -0
  153. package/dist/commands/system.js +417 -0
  154. package/dist/commands/system.js.map +1 -0
  155. package/dist/commands/tools/index.d.ts.map +1 -0
  156. package/dist/commands/tools/index.js +2040 -0
  157. package/dist/commands/tools/index.js.map +1 -0
  158. package/dist/commands/trade.d.ts.map +1 -0
  159. package/dist/commands/trade.js +237 -0
  160. package/dist/commands/trade.js.map +1 -0
  161. package/dist/commands/transactions.d.ts.map +1 -1
  162. package/dist/commands/transactions.js +29 -17
  163. package/dist/commands/transactions.js.map +1 -1
  164. package/dist/commands/update.d.ts.map +1 -0
  165. package/dist/commands/update.js +429 -0
  166. package/dist/commands/update.js.map +1 -0
  167. package/dist/config.d.ts.map +1 -1
  168. package/dist/config.js +351 -40
  169. package/dist/config.js.map +1 -1
  170. package/dist/index.js +4524 -924
  171. package/dist/index.js.map +1 -1
  172. package/dist/interactive/art.d.ts.map +1 -1
  173. package/dist/interactive/art.js +33 -1
  174. package/dist/interactive/art.js.map +1 -1
  175. package/dist/interactive/shell.d.ts.map +1 -1
  176. package/dist/interactive/shell.js +467 -2652
  177. package/dist/interactive/shell.js.map +1 -1
  178. package/dist/mcp/context.d.ts.map +1 -0
  179. package/dist/mcp/context.js +211 -0
  180. package/dist/mcp/context.js.map +1 -0
  181. package/dist/mcp/onboarding.d.ts.map +1 -0
  182. package/dist/mcp/onboarding.js +266 -0
  183. package/dist/mcp/onboarding.js.map +1 -0
  184. package/dist/mcp/resources.d.ts.map +1 -0
  185. package/dist/mcp/resources.js +222 -0
  186. package/dist/mcp/resources.js.map +1 -0
  187. package/dist/mcp/server.d.ts.map +1 -1
  188. package/dist/mcp/server.js +51 -1
  189. package/dist/mcp/server.js.map +1 -1
  190. package/dist/mcp/tools.d.ts.map +1 -1
  191. package/dist/mcp/tools.js +4119 -169
  192. package/dist/mcp/tools.js.map +1 -1
  193. package/dist/mcp/types.d.ts.map +1 -1
  194. package/dist/types/agent-info.d.ts.map +1 -0
  195. package/dist/types/agent-info.js +11 -0
  196. package/dist/types/agent-info.js.map +1 -0
  197. package/dist/ui/components/ScrollableList.d.ts.map +1 -0
  198. package/dist/ui/components/ScrollableList.js +72 -0
  199. package/dist/ui/components/ScrollableList.js.map +1 -0
  200. package/dist/ui/components/ThemeProvider.d.ts.map +1 -0
  201. package/dist/ui/components/ThemeProvider.js +87 -0
  202. package/dist/ui/components/ThemeProvider.js.map +1 -0
  203. package/dist/ui/components/ThemedBox.d.ts.map +1 -0
  204. package/dist/ui/components/ThemedBox.js +24 -0
  205. package/dist/ui/components/ThemedBox.js.map +1 -0
  206. package/dist/ui/components/agent/ChatHeader.d.ts.map +1 -0
  207. package/dist/ui/components/agent/ChatHeader.js +39 -0
  208. package/dist/ui/components/agent/ChatHeader.js.map +1 -0
  209. package/dist/ui/components/agent/Header.d.ts.map +1 -0
  210. package/dist/ui/components/agent/Header.js +14 -0
  211. package/dist/ui/components/agent/Header.js.map +1 -0
  212. package/dist/ui/components/agent/Input.d.ts.map +1 -0
  213. package/dist/ui/components/agent/Input.js +23 -0
  214. package/dist/ui/components/agent/Input.js.map +1 -0
  215. package/dist/ui/components/agent/Output.d.ts.map +1 -0
  216. package/dist/ui/components/agent/Output.js +23 -0
  217. package/dist/ui/components/agent/Output.js.map +1 -0
  218. package/dist/ui/components/chat/TokenChatUI.d.ts.map +1 -0
  219. package/dist/ui/components/chat/TokenChatUI.js +133 -0
  220. package/dist/ui/components/chat/TokenChatUI.js.map +1 -0
  221. package/dist/ui/components/shell/ShellHeader.d.ts.map +1 -0
  222. package/dist/ui/components/shell/ShellHeader.js +31 -0
  223. package/dist/ui/components/shell/ShellHeader.js.map +1 -0
  224. package/dist/ui/components/shell/ShellInput.d.ts.map +1 -0
  225. package/dist/ui/components/shell/ShellInput.js +151 -0
  226. package/dist/ui/components/shell/ShellInput.js.map +1 -0
  227. package/dist/ui/components/shell/ShellOutput.d.ts.map +1 -0
  228. package/dist/ui/components/shell/ShellOutput.js +8 -0
  229. package/dist/ui/components/shell/ShellOutput.js.map +1 -0
  230. package/dist/ui/hooks/useChatWebSocket.d.ts.map +1 -0
  231. package/dist/ui/hooks/useChatWebSocket.js +76 -0
  232. package/dist/ui/hooks/useChatWebSocket.js.map +1 -0
  233. package/dist/ui/hooks/useCommandHistory.d.ts.map +1 -0
  234. package/dist/ui/hooks/useCommandHistory.js +70 -0
  235. package/dist/ui/hooks/useCommandHistory.js.map +1 -0
  236. package/dist/ui/hooks/useDebounce.d.ts.map +1 -0
  237. package/dist/ui/hooks/useDebounce.js +17 -0
  238. package/dist/ui/hooks/useDebounce.js.map +1 -0
  239. package/dist/ui/hooks/useLogStream.d.ts.map +1 -0
  240. package/dist/ui/hooks/useLogStream.js +20 -0
  241. package/dist/ui/hooks/useLogStream.js.map +1 -0
  242. package/dist/ui/hooks/useVirtualScroll.d.ts.map +1 -0
  243. package/dist/ui/hooks/useVirtualScroll.js +70 -0
  244. package/dist/ui/hooks/useVirtualScroll.js.map +1 -0
  245. package/dist/utils/admin.d.ts.map +1 -0
  246. package/dist/utils/admin.js +144 -0
  247. package/dist/utils/admin.js.map +1 -0
  248. package/dist/utils/autoSetup.d.ts.map +1 -0
  249. package/dist/utils/autoSetup.js +252 -0
  250. package/dist/utils/autoSetup.js.map +1 -0
  251. package/dist/utils/build-constants.d.ts.map +1 -0
  252. package/dist/utils/build-constants.js +10 -0
  253. package/dist/utils/build-constants.js.map +1 -0
  254. package/dist/utils/constants.d.ts.map +1 -1
  255. package/dist/utils/errors.d.ts.map +1 -1
  256. package/dist/utils/errors.js +10 -1
  257. package/dist/utils/errors.js.map +1 -1
  258. package/dist/utils/formatting.d.ts.map +1 -1
  259. package/dist/utils/formatting.js +46 -9
  260. package/dist/utils/formatting.js.map +1 -1
  261. package/dist/utils/llm-cli-config.d.ts.map +1 -0
  262. package/dist/utils/llm-cli-config.js +963 -0
  263. package/dist/utils/llm-cli-config.js.map +1 -0
  264. package/dist/utils/llm-cli-detector.d.ts.map +1 -0
  265. package/dist/utils/llm-cli-detector.js +202 -0
  266. package/dist/utils/llm-cli-detector.js.map +1 -0
  267. package/dist/utils/loading.d.ts.map +1 -1
  268. package/dist/utils/loading.js +25 -3
  269. package/dist/utils/loading.js.map +1 -1
  270. package/dist/utils/maintenance.d.ts.map +1 -0
  271. package/dist/utils/maintenance.js +17 -0
  272. package/dist/utils/maintenance.js.map +1 -0
  273. package/dist/utils/mcp-config.d.ts.map +1 -0
  274. package/dist/utils/mcp-config.js +77 -0
  275. package/dist/utils/mcp-config.js.map +1 -0
  276. package/dist/utils/privateKeyPrompt.d.ts.map +1 -1
  277. package/dist/utils/privateKeyPrompt.js +308 -129
  278. package/dist/utils/privateKeyPrompt.js.map +1 -1
  279. package/dist/utils/process-cleanup.d.ts.map +1 -0
  280. package/dist/utils/process-cleanup.js +136 -0
  281. package/dist/utils/process-cleanup.js.map +1 -0
  282. package/dist/utils/retry.d.ts.map +1 -0
  283. package/dist/utils/retry.js +56 -0
  284. package/dist/utils/retry.js.map +1 -0
  285. package/dist/utils/rpc-helpers.d.ts.map +1 -0
  286. package/dist/utils/rpc-helpers.js +70 -0
  287. package/dist/utils/rpc-helpers.js.map +1 -0
  288. package/dist/utils/rpc-transport.d.ts.map +1 -0
  289. package/dist/utils/rpc-transport.js +87 -0
  290. package/dist/utils/rpc-transport.js.map +1 -0
  291. package/dist/utils/shell-setup.d.ts.map +1 -0
  292. package/dist/utils/shell-setup.js +531 -0
  293. package/dist/utils/shell-setup.js.map +1 -0
  294. package/dist/utils/status.d.ts.map +1 -1
  295. package/dist/utils/status.js +34 -5
  296. package/dist/utils/status.js.map +1 -1
  297. package/dist/utils/token-resolver.d.ts.map +1 -1
  298. package/dist/utils/token-resolver.js +51 -8
  299. package/dist/utils/token-resolver.js.map +1 -1
  300. package/dist/utils/x402-caller.d.ts.map +1 -0
  301. package/dist/utils/x402-caller.js +17 -0
  302. package/dist/utils/x402-caller.js.map +1 -0
  303. package/docs/README.md +28 -0
  304. package/docs/agent/README.md +18 -0
  305. package/docs/api/README.md +41 -0
  306. package/docs/cli/README.md +42 -0
  307. package/docs/guides/README.md +26 -0
  308. package/docs/implementation/README.md +18 -0
  309. package/docs/planning/README.md +19 -0
  310. package/docs/testing/README.md +15 -0
  311. package/docs/ux/README.md +16 -0
  312. package/issues.txt +2 -0
  313. package/package.json +24 -9
  314. package/scripts/cat-spin.sh +417 -0
  315. package/scripts/deprecate-rc-versions.js +58 -0
  316. package/scripts/inject-build-constants.js +43 -0
  317. package/scripts/monitor-foobar.js +117 -0
  318. package/swap.logs +61 -0
  319. package/swapping.txt +108 -0
  320. package/test.txt +12 -0
  321. package/tests/fixtures/test-data.json +16 -0
  322. package/Screenshot 2025-12-21 at 8.56.02/342/200/257PM.png +0 -0
package/dist/mcp/tools.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { HttpcatClient } from "../client.js";
2
2
  import { config } from "../config.js";
3
+ import { getAdminCommands, isCurrentUserAdmin } from "../utils/admin.js";
3
4
  import { createToken } from "../commands/create.js";
4
5
  import { buyToken } from "../commands/buy.js";
5
6
  import { sellToken, parseTokenAmount } from "../commands/sell.js";
@@ -9,8 +10,12 @@ import { getPositions } from "../commands/positions.js";
9
10
  import { privateKeyToAccount } from "viem/accounts";
10
11
  import { checkHealth } from "../commands/health.js";
11
12
  import { checkBalance } from "../commands/balances.js";
12
- import { viewFees, claimFees } from "../commands/claim.js";
13
+ import { viewFees, claimFees, getUserCreatedTokens, getAllTokenFees, claimAllFees, } from "../commands/claim.js";
13
14
  import { getTransactions } from "../commands/transactions.js";
15
+ import { swap, shieldedSwap } from "../commands/swap.js";
16
+ import { submitGaslessSwap, submitGaslessSwapOur, } from "../commands/gasless-swap.js";
17
+ import { getPerpsMarkets, onboardPerps, depositPerps, tradePerps, getPerpsPositions, } from "../commands/perps.js";
18
+ import { getPredictionMarkets, getPredictionMarket, searchPredictionMarkets, placePredictionBet, detectPredictionArbs, calculatePredictionHedge, executePredictionArb, detectPredictionInsiders, } from "../commands/predictions.js";
14
19
  import { getOrCreateChatSession, getChatSession, ensureValidSession, sendMessage, getRecentMessages, } from "./chat-state.js";
15
20
  // Helper to resolve private key with priority: param > env > config
16
21
  function resolvePrivateKey(paramKey, accountIndex) {
@@ -68,13 +73,85 @@ async function createClient(privateKey, accountIndex) {
68
73
  // Helper to get network for test mode detection
69
74
  function isTestMode(client) {
70
75
  const network = client.getNetwork();
71
- return network === "eip155:84532" || network === "eip155:11155111" || network.includes("sepolia");
76
+ return (network === "eip155:84532" ||
77
+ network === "eip155:11155111" ||
78
+ network.includes("sepolia"));
72
79
  }
80
+ /**
81
+ * Map MCP tool name to CLI command name for admin filtering
82
+ * Examples:
83
+ * - "market_price" -> "market"
84
+ * - "tools_address_validate" -> "address"
85
+ * - "create_token" -> "create"
86
+ * - "gasless_swap_submit" -> "gasless-submit"
87
+ */
88
+ function toolNameToCommandName(toolName) {
89
+ // Special cases first
90
+ const specialCases = {
91
+ "create_token": "create",
92
+ "claim_fees": "claim",
93
+ "gasless_swap_submit": "gasless-submit",
94
+ "gasless_swap_submit_our": "gasless-submit-our",
95
+ "gasless_swap_quote": "gasless-quote",
96
+ "gasless_swap_status": "gasless-status",
97
+ "system_status": "status",
98
+ "system_limits": "limits",
99
+ "system_sources": "sources",
100
+ };
101
+ if (specialCases[toolName]) {
102
+ return specialCases[toolName];
103
+ }
104
+ // Extract category prefix (first part before underscore)
105
+ const parts = toolName.split("_");
106
+ if (parts.length === 0)
107
+ return null;
108
+ // Handle tools_* category - extract subcategory
109
+ if (parts[0] === "tools" && parts.length > 1) {
110
+ return parts[1]; // e.g., "tools_address_validate" -> "address"
111
+ }
112
+ // Default: use first part as command name
113
+ return parts[0]; // e.g., "market_price" -> "market"
114
+ }
115
+ /**
116
+ * Returns all available MCP tools for the httpcat CLI.
117
+ *
118
+ * Tool Categories (100+ total):
119
+ * - Launchpad/Tokens: 7 tools (create, buy, sell, info, list, positions, transactions)
120
+ * - Swaps: 5 tools (universal, shielded, gasless quote/submit/status)
121
+ * - Perps: 5 tools (markets, onboard, deposit, trade, positions)
122
+ * - Predictions: 9 tools (markets, market, search, bet, detect-arbs, calculate-hedge, execute-arb, detect-insiders, stream)
123
+ * - Chat: 4 tools (join, send message, renew lease, get messages)
124
+ * - Fees: 2 tools (view, claim)
125
+ * - Market Intelligence: 8 tools
126
+ * - Security: 3 tools
127
+ * - Risk: 2 tools
128
+ * - Trading: 2 tools
129
+ * - Opportunities: 5 tools
130
+ * - Portfolio: 4 tools
131
+ * - Automation: 4 tools
132
+ * - System: 3 tools
133
+ * - Agent: 1 tool
134
+ * - Tools: 40+ utility tools
135
+ * - Other: 6 tools (health check, balance check, RPC proxy, etc.)
136
+ */
73
137
  export function getTools() {
74
- return [
138
+ const allTools = [
75
139
  {
76
140
  name: "create_token",
77
- description: "Create a new token on the bonding curve. Costs $0.01 USDC.",
141
+ description: `Create a new token on the bonding curve.
142
+
143
+ 💰 Cost: $0.01 USDC
144
+
145
+ 📝 Usage Examples:
146
+ - Create a basic token: {"name": "My Token", "symbol": "MTK"}
147
+ - Create with logo: {"name": "Cool Cat", "symbol": "CAT", "photoUrl": "https://example.com/logo.png"}
148
+ - Create with website: {"name": "My Project", "symbol": "PROJ", "websiteUrl": "https://myproject.com"}
149
+
150
+ 💡 Tips:
151
+ - Token symbol must be 3-10 characters, unique on the platform
152
+ - Tokens start on a bonding curve and graduate to AMM at $100k market cap
153
+ - You become the creator and earn 80% of trading fees
154
+ - Use token_info to check your token after creation`,
78
155
  inputSchema: {
79
156
  type: "object",
80
157
  properties: {
@@ -104,7 +181,22 @@ export function getTools() {
104
181
  },
105
182
  {
106
183
  name: "buy_token",
107
- description: "Buy tokens from the bonding curve. Amount: 0.05, 0.10, or 0.20 USDC (testnet) or 50, 100, or 200 USDC (mainnet). Includes 1% fee.",
184
+ description: `Buy tokens from the bonding curve.
185
+
186
+ 💰 Cost: Amount + 1% fee
187
+ - Testnet: 0.05, 0.10, or 0.20 USDC
188
+ - Mainnet: 50, 100, or 200 USDC
189
+
190
+ 📝 Usage Examples:
191
+ - Buy by symbol: {"identifier": "FRIDA", "amount": "100"}
192
+ - Buy by name: {"identifier": "My Token", "amount": "50"}
193
+ - Buy by address: {"identifier": "0x1234...", "amount": "200"}
194
+
195
+ 💡 Tips:
196
+ - Token identifier can be symbol (case-insensitive), name, or contract address
197
+ - Use token_info first to check current price and market cap
198
+ - Tokens on bonding curve have dynamic pricing based on supply
199
+ - Use positions to see all your holdings after buying`,
108
200
  inputSchema: {
109
201
  type: "object",
110
202
  properties: {
@@ -126,7 +218,20 @@ export function getTools() {
126
218
  },
127
219
  {
128
220
  name: "sell_token",
129
- description: "Sell tokens back to the bonding curve. Amount can be a number, percentage (e.g., '50%'), or 'all'. 1% fee deducted from proceeds.",
221
+ description: `Sell tokens back to the bonding curve.
222
+
223
+ 💰 Cost: 1% fee deducted from proceeds
224
+
225
+ 📝 Usage Examples:
226
+ - Sell specific amount: {"identifier": "FRIDA", "amount": "1000"}
227
+ - Sell percentage: {"identifier": "FRIDA", "amount": "50%"}
228
+ - Sell all: {"identifier": "FRIDA", "amount": "all"}
229
+
230
+ 💡 Tips:
231
+ - Amount can be a number, percentage (e.g., '50%'), or 'all'
232
+ - Use token_info first to check your holdings
233
+ - Selling reduces token supply and may affect price
234
+ - Use positions to see updated holdings after selling`,
130
235
  inputSchema: {
131
236
  type: "object",
132
237
  properties: {
@@ -148,7 +253,26 @@ export function getTools() {
148
253
  },
149
254
  {
150
255
  name: "token_info",
151
- description: "Get detailed information about a token including price, market cap, graduation progress, and your position (if you own tokens). Costs $0.0001 USDC.",
256
+ description: `Get detailed information about a token.
257
+
258
+ 💰 Cost: $0.0001 USDC
259
+
260
+ 📊 Returns:
261
+ - Current price and market cap
262
+ - Graduation progress (toward $100k for AMM)
263
+ - Your position (if you own tokens)
264
+ - Token metadata (name, symbol, logo, website)
265
+ - Trading statistics
266
+
267
+ 📝 Usage Examples:
268
+ - Get info by symbol: {"identifier": "FRIDA"}
269
+ - Get info by name: {"identifier": "My Token"}
270
+ - Get info by address: {"identifier": "0x1234..."}
271
+
272
+ 💡 Tips:
273
+ - Use this before buying to check current price
274
+ - Check graduation progress to see if token is close to AMM
275
+ - Your position shows profit/loss if you own tokens`,
152
276
  inputSchema: {
153
277
  type: "object",
154
278
  properties: {
@@ -166,7 +290,20 @@ export function getTools() {
166
290
  },
167
291
  {
168
292
  name: "list_tokens",
169
- description: "List all tokens with pagination and sorting. Costs $0.0001 USDC.",
293
+ description: `List all tokens with pagination and sorting.
294
+
295
+ 💰 Cost: $0.0001 USDC
296
+
297
+ 📝 Usage Examples:
298
+ - List top tokens: {"sort": "mcap", "limit": 20}
299
+ - List newest: {"sort": "created", "limit": 50}
300
+ - List alphabetically: {"sort": "name", "page": 1, "limit": 100}
301
+
302
+ 💡 Tips:
303
+ - Sort by 'mcap' to see highest market cap tokens first
304
+ - Sort by 'created' to see newest tokens
305
+ - Use pagination to browse through all tokens
306
+ - Consider using the httpcat://tokens/list resource for cached data`,
170
307
  inputSchema: {
171
308
  type: "object",
172
309
  properties: {
@@ -195,7 +332,25 @@ export function getTools() {
195
332
  },
196
333
  {
197
334
  name: "positions",
198
- description: "Get all your positions with comprehensive information including current value, profit/loss, ROI, transaction history, and portfolio summary. Costs $0.01 USDC.",
335
+ description: `Get all your token positions with comprehensive portfolio analysis.
336
+
337
+ 💰 Cost: $0.01 USDC
338
+
339
+ 📊 Returns:
340
+ - All tokens you own with current value
341
+ - Profit/loss for each position
342
+ - ROI percentage
343
+ - Transaction history
344
+ - Portfolio summary (total value, total P/L)
345
+
346
+ 📝 Usage Example:
347
+ - Get all positions: {} (no parameters needed)
348
+
349
+ 💡 Tips:
350
+ - Use this regularly to track your portfolio performance
351
+ - Shows both realized and unrealized gains
352
+ - Transaction history helps track your trading activity
353
+ - Portfolio summary gives quick overview of total value`,
199
354
  inputSchema: {
200
355
  type: "object",
201
356
  properties: {
@@ -208,7 +363,22 @@ export function getTools() {
208
363
  },
209
364
  {
210
365
  name: "check_balance",
211
- description: "Check wallet balance (ETH and USDC). Free - no payment required.",
366
+ description: `Check wallet balance for ETH and USDC.
367
+
368
+ 💰 Cost: FREE - no payment required
369
+
370
+ 📊 Returns:
371
+ - ETH balance (for gas fees)
372
+ - USDC balance (for trading)
373
+
374
+ 📝 Usage Example:
375
+ - Check balance: {} (no parameters needed)
376
+
377
+ 💡 Tips:
378
+ - Check balance before trading to ensure sufficient funds
379
+ - You need ETH for gas fees on all transactions
380
+ - You need USDC for buying tokens and trading
381
+ - Use this tool frequently to monitor your wallet`,
212
382
  inputSchema: {
213
383
  type: "object",
214
384
  properties: {
@@ -313,31 +483,31 @@ export function getTools() {
313
483
  },
314
484
  {
315
485
  name: "view_fees",
316
- description: "View accumulated fees for a token. Shows total fees, creator share (80%), and platform share (20%). Free - no payment required.",
486
+ description: "View accumulated claims for a token or all your tokens. Shows total fees, creator share (80%), and platform share (20%). If no identifier provided, shows all tokens you created. Free - no payment required.",
317
487
  inputSchema: {
318
488
  type: "object",
319
489
  properties: {
320
490
  identifier: {
321
491
  type: "string",
322
- description: "Token identifier: address, name (use quotes if spaces), or symbol (case-insensitive)",
492
+ description: "Optional token identifier: address, name (use quotes if spaces), or symbol (case-insensitive). If omitted, returns all your created tokens.",
323
493
  },
324
494
  privateKey: {
325
495
  type: "string",
326
496
  description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
327
497
  },
328
498
  },
329
- required: ["identifier"],
499
+ required: [],
330
500
  },
331
501
  },
332
502
  {
333
503
  name: "claim_fees",
334
- description: "Claim accumulated fees for a token. Creator receives 80% of fees, platform receives 20%. Requires gas fees.",
504
+ description: "Claim accumulated fees for a token. Creator receives 80% of fees, platform receives 20%. Requires gas fees. Use 'all' as identifier to claim all your tokens.",
335
505
  inputSchema: {
336
506
  type: "object",
337
507
  properties: {
338
508
  identifier: {
339
509
  type: "string",
340
- description: "Token identifier: address, name (use quotes if spaces), or symbol (case-insensitive)",
510
+ description: "Token identifier: address, name (use quotes if spaces), symbol (case-insensitive), or 'all' to claim all your tokens.",
341
511
  },
342
512
  privateKey: {
343
513
  type: "string",
@@ -383,160 +553,3940 @@ export function getTools() {
383
553
  },
384
554
  },
385
555
  },
386
- ];
387
- }
388
- // Generate a unique response ID
389
- function generateResponseId() {
390
- return `resp_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
391
- }
392
- export async function handleTool(name, args) {
393
- const responseId = generateResponseId();
394
- try {
395
- let result;
396
- switch (name) {
397
- case "create_token": {
398
- const params = args;
399
- const client = await createClient(params.privateKey);
400
- result = await createToken(client, {
401
- name: params.name,
402
- symbol: params.symbol,
403
- photoUrl: params.photoUrl,
404
- websiteUrl: params.websiteUrl,
405
- });
406
- break;
407
- }
408
- case "buy_token": {
409
- const params = args;
410
- const client = await createClient(params.privateKey);
411
- const testMode = isTestMode(client);
412
- result = await buyToken(client, params.identifier, params.amount, testMode, true // silent mode for MCP
413
- );
414
- break;
415
- }
416
- case "sell_token": {
417
- const params = args;
418
- const client = await createClient(params.privateKey);
419
- // First get token info to check holdings
420
- const info = await getTokenInfo(client, params.identifier, undefined, true // silent mode
421
- );
422
- if (!info.userPosition || info.userPosition.tokensOwned === "0") {
423
- throw new Error("You do not own any of this token");
424
- }
425
- const tokenAmount = parseTokenAmount(params.amount, info.userPosition.tokensOwned);
426
- result = await sellToken(client, params.identifier, tokenAmount, true // silent mode
427
- );
428
- break;
429
- }
430
- case "token_info": {
431
- const params = args;
432
- const client = await createClient(params.privateKey);
433
- result = await getTokenInfo(client, params.identifier, undefined, true // silent mode
434
- );
435
- break;
436
- }
437
- case "list_tokens": {
438
- const params = args;
439
- const client = await createClient(params.privateKey);
440
- result = await listTokens(client, params.page || 1, params.limit || 20, params.sort || "mcap");
441
- break;
442
- }
443
- case "positions": {
444
- const params = args;
445
- const client = await createClient(params.privateKey);
446
- // Get user address from private key
447
- const privateKey = resolvePrivateKey(params.privateKey);
448
- if (!privateKey) {
449
- throw new Error("Private key required for positions command");
450
- }
451
- const account = privateKeyToAccount(privateKey);
452
- const userAddress = account.address;
453
- result = await getPositions(client, userAddress);
454
- break;
455
- }
456
- case "check_balance": {
457
- const params = args;
458
- const resolvedKey = resolvePrivateKey(params.privateKey);
459
- result = await checkBalance(resolvedKey);
460
- break;
461
- }
462
- case "health_check": {
463
- const params = args;
464
- const client = await createClient(params.privateKey);
465
- result = await checkHealth(client);
466
- break;
467
- }
468
- case "chat_join": {
469
- const params = args;
470
- const client = await createClient(params.privateKey);
471
- const session = await getOrCreateChatSession(client, params.tokenIdentifier, resolvePrivateKey(params.privateKey));
472
- result = {
473
- leaseId: session.leaseId,
474
- leaseExpiresAt: session.leaseExpiresAt.toISOString(),
475
- wsUrl: session.wsUrl,
476
- lastMessages: session.messages.slice(-20), // Last 20 messages
477
- };
478
- break;
479
- }
480
- case "chat_send_message": {
481
- const params = args;
482
- const client = await createClient(params.privateKey);
483
- const session = getChatSession(params.leaseId);
484
- if (!session) {
485
- throw new Error(`No active chat session found for leaseId: ${params.leaseId}. Use chat_join first.`);
486
- }
487
- result = await sendMessage(session, params.message);
488
- break;
489
- }
490
- case "chat_renew_lease": {
491
- const params = args;
492
- const client = await createClient(params.privateKey);
493
- const session = await ensureValidSession(client, params.leaseId, resolvePrivateKey(params.privateKey));
494
- result = {
495
- leaseId: session.leaseId,
496
- leaseExpiresAt: session.leaseExpiresAt.toISOString(),
497
- };
498
- break;
499
- }
500
- case "chat_get_recent_messages": {
501
- const params = args;
502
- const session = getChatSession(params.leaseId);
503
- if (!session) {
504
- throw new Error(`No active chat session found for leaseId: ${params.leaseId}. Use chat_join first.`);
505
- }
506
- const messages = getRecentMessages(session, params.limit || 50);
507
- result = { messages };
508
- break;
509
- }
510
- case "view_fees": {
511
- const params = args;
512
- const client = await createClient(params.privateKey);
513
- result = await viewFees(client, params.identifier, true); // silent mode
514
- break;
515
- }
516
- case "claim_fees": {
517
- const params = args;
518
- const client = await createClient(params.privateKey);
519
- // Get user address from private key
520
- const privateKey = resolvePrivateKey(params.privateKey);
521
- if (!privateKey) {
522
- throw new Error("Private key required for claim_fees command");
523
- }
524
- const account = privateKeyToAccount(privateKey);
525
- const userAddress = account.address;
526
- result = await claimFees(client, params.identifier, userAddress, true // silent mode
527
- );
528
- break;
529
- }
530
- case "get_transactions": {
531
- const params = args;
532
- const client = await createClient(params.privateKey);
533
- result = await getTransactions(client, {
534
- userAddress: params.userAddress,
535
- tokenId: params.tokenId,
536
- type: params.type,
537
- limit: params.limit,
538
- offset: params.offset,
539
- });
556
+ {
557
+ name: "swap_tokens",
558
+ description: "Swap tokens using universal swap with best route aggregation. Costs $0.10 USDC. Supports any ERC20 token (including CAT tokens).",
559
+ inputSchema: {
560
+ type: "object",
561
+ properties: {
562
+ tokenIn: {
563
+ type: "string",
564
+ description: "Token identifier to swap from: address, name (use quotes if spaces), or symbol (case-insensitive). Can be USDC, ETH, or any CAT token.",
565
+ },
566
+ tokenOut: {
567
+ type: "string",
568
+ description: "Token identifier to swap to: address, name (use quotes if spaces), or symbol (case-insensitive). Can be USDC, ETH, or any CAT token.",
569
+ },
570
+ amount: {
571
+ type: "string",
572
+ description: "Amount to swap (human-readable, e.g., '100' for 100 tokens, '0.5' for 0.5 ETH)",
573
+ },
574
+ slippageBps: {
575
+ type: "number",
576
+ description: "Slippage tolerance in basis points (default: 50, which is 0.5%). 100 bps = 1%",
577
+ default: 50,
578
+ },
579
+ privateKey: {
580
+ type: "string",
581
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
582
+ },
583
+ },
584
+ required: ["tokenIn", "tokenOut", "amount"],
585
+ },
586
+ },
587
+ {
588
+ name: "shielded_swap",
589
+ description: "MEV-protected swap via UniswapX Dutch auction. Costs $1.00 USDC. Provides protection against front-running and sandwich attacks.",
590
+ inputSchema: {
591
+ type: "object",
592
+ properties: {
593
+ tokenIn: {
594
+ type: "string",
595
+ description: "Token identifier to swap from: address, name (use quotes if spaces), or symbol (case-insensitive). Can be USDC, ETH, or any CAT token.",
596
+ },
597
+ tokenOut: {
598
+ type: "string",
599
+ description: "Token identifier to swap to: address, name (use quotes if spaces), or symbol (case-insensitive). Can be USDC, ETH, or any CAT token.",
600
+ },
601
+ amount: {
602
+ type: "string",
603
+ description: "Amount to swap (human-readable, e.g., '100' for 100 tokens, '0.5' for 0.5 ETH)",
604
+ },
605
+ slippageBps: {
606
+ type: "number",
607
+ description: "Slippage tolerance in basis points (default: 50, which is 0.5%). 100 bps = 1%",
608
+ default: 50,
609
+ },
610
+ privateKey: {
611
+ type: "string",
612
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
613
+ },
614
+ },
615
+ required: ["tokenIn", "tokenOut", "amount"],
616
+ },
617
+ },
618
+ {
619
+ name: "gasless_swap_quote",
620
+ description: "Get gasless swap quotes from multiple providers. Free - no payment required. Returns quotes without executing the swap.",
621
+ inputSchema: {
622
+ type: "object",
623
+ properties: {
624
+ tokenIn: {
625
+ type: "string",
626
+ description: "Token address to swap from (must be a contract address)",
627
+ },
628
+ tokenOut: {
629
+ type: "string",
630
+ description: "Token address to swap to (must be a contract address)",
631
+ },
632
+ amount: {
633
+ type: "string",
634
+ description: "Amount to swap in smallest units (e.g., for USDC with 6 decimals, '1000000' = 1 USDC)",
635
+ },
636
+ slippageBps: {
637
+ type: "number",
638
+ description: "Slippage tolerance in basis points (optional). 100 bps = 1%",
639
+ },
640
+ taker: {
641
+ type: "string",
642
+ description: "Taker address (wallet that will receive the tokens)",
643
+ },
644
+ privateKey: {
645
+ type: "string",
646
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
647
+ },
648
+ },
649
+ required: ["tokenIn", "tokenOut", "amount", "taker"],
650
+ },
651
+ },
652
+ {
653
+ name: "gasless_swap_status",
654
+ description: "Check the status of a 0x gasless swap. Free - no payment required.",
655
+ inputSchema: {
656
+ type: "object",
657
+ properties: {
658
+ tradeHash: {
659
+ type: "string",
660
+ description: "Trade hash from gasless swap",
661
+ },
662
+ chainId: {
663
+ type: "number",
664
+ description: "Optional chain ID (defaults to configured network)",
665
+ },
666
+ privateKey: {
667
+ type: "string",
668
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
669
+ },
670
+ },
671
+ required: ["tradeHash"],
672
+ },
673
+ },
674
+ {
675
+ name: "gasless_swap_submit",
676
+ description: "Submit a signed 0x gasless swap trade. Costs $0.01 USDC.",
677
+ inputSchema: {
678
+ type: "object",
679
+ properties: {
680
+ chainId: {
681
+ type: "number",
682
+ description: "Optional chain ID",
683
+ },
684
+ approval: {
685
+ type: "object",
686
+ description: "Optional approval object",
687
+ },
688
+ trade: {
689
+ type: "object",
690
+ description: "Trade object (required)",
691
+ },
692
+ privateKey: {
693
+ type: "string",
694
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
695
+ },
696
+ },
697
+ required: ["trade"],
698
+ },
699
+ },
700
+ {
701
+ name: "gasless_swap_submit_our",
702
+ description: "Submit a gasless swap via our executor. Costs $0.01 USDC.",
703
+ inputSchema: {
704
+ type: "object",
705
+ properties: {
706
+ tokenIn: {
707
+ type: "string",
708
+ description: "Token in address",
709
+ },
710
+ tokenOut: {
711
+ type: "string",
712
+ description: "Token out address",
713
+ },
714
+ totalAmount: {
715
+ type: "string",
716
+ description: "Total amount",
717
+ },
718
+ feeAmount: {
719
+ type: "string",
720
+ description: "Fee amount",
721
+ },
722
+ taker: {
723
+ type: "string",
724
+ description: "Taker address",
725
+ },
726
+ permit2Signature: {
727
+ type: "string",
728
+ description: "Permit2 signature",
729
+ },
730
+ permitNonce: {
731
+ type: "number",
732
+ description: "Permit nonce",
733
+ },
734
+ permitDeadline: {
735
+ type: "number",
736
+ description: "Permit deadline",
737
+ },
738
+ privateKey: {
739
+ type: "string",
740
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
741
+ },
742
+ },
743
+ required: [
744
+ "tokenIn",
745
+ "tokenOut",
746
+ "totalAmount",
747
+ "feeAmount",
748
+ "taker",
749
+ "permit2Signature",
750
+ "permitNonce",
751
+ "permitDeadline",
752
+ ],
753
+ },
754
+ },
755
+ {
756
+ name: "perps_markets",
757
+ description: "Get available perpetual futures markets. Costs $0.01 USDC.",
758
+ inputSchema: {
759
+ type: "object",
760
+ properties: {
761
+ platform: {
762
+ type: "string",
763
+ description: "Optional platform filter",
764
+ },
765
+ symbol: {
766
+ type: "string",
767
+ description: "Optional symbol filter",
768
+ },
769
+ privateKey: {
770
+ type: "string",
771
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
772
+ },
773
+ },
774
+ },
775
+ },
776
+ {
777
+ name: "perps_onboard",
778
+ description: "One-time setup to connect wallet to perps venues. Free - no payment required.",
779
+ inputSchema: {
780
+ type: "object",
781
+ properties: {
782
+ wallet: {
783
+ type: "string",
784
+ description: "Wallet address",
785
+ },
786
+ privateKey: {
787
+ type: "string",
788
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
789
+ },
790
+ },
791
+ required: ["wallet"],
792
+ },
793
+ },
794
+ {
795
+ name: "perps_deposit",
796
+ description: "Deposit USDC to perps trading venues. Free - no payment required.",
797
+ inputSchema: {
798
+ type: "object",
799
+ properties: {
800
+ amount: {
801
+ type: "string",
802
+ description: "Amount to deposit",
803
+ },
804
+ venue: {
805
+ type: "string",
806
+ description: "Optional venue",
807
+ },
808
+ chain: {
809
+ type: "string",
810
+ description: "Optional chain",
811
+ },
812
+ wallet: {
813
+ type: "string",
814
+ description: "Wallet address",
815
+ },
816
+ privateKey: {
817
+ type: "string",
818
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
819
+ },
820
+ },
821
+ required: ["amount", "wallet"],
822
+ },
823
+ },
824
+ {
825
+ name: "perps_trade",
826
+ description: "Open or close perpetual positions with auto-routing. Costs $0.05 USDC.",
827
+ inputSchema: {
828
+ type: "object",
829
+ properties: {
830
+ market: {
831
+ type: "string",
832
+ description: "Market identifier",
833
+ },
834
+ side: {
835
+ type: "string",
836
+ enum: ["long", "short"],
837
+ description: "Side: long or short",
838
+ },
839
+ sizeUsd: {
840
+ type: "string",
841
+ description: "Size in USD",
842
+ },
843
+ leverage: {
844
+ type: "number",
845
+ description: "Leverage multiplier",
846
+ },
847
+ orderType: {
848
+ type: "string",
849
+ description: "Optional order type",
850
+ },
851
+ price: {
852
+ type: "string",
853
+ description: "Optional price",
854
+ },
855
+ wallet: {
856
+ type: "string",
857
+ description: "Wallet address",
858
+ },
859
+ privateKey: {
860
+ type: "string",
861
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
862
+ },
863
+ },
864
+ required: ["market", "side", "sizeUsd", "leverage", "wallet"],
865
+ },
866
+ },
867
+ {
868
+ name: "perps_positions",
869
+ description: "View all open perpetual positions across venues. Costs $0.01 USDC.",
870
+ inputSchema: {
871
+ type: "object",
872
+ properties: {
873
+ wallet: {
874
+ type: "string",
875
+ description: "Wallet address",
876
+ },
877
+ venue: {
878
+ type: "string",
879
+ description: "Optional venue filter",
880
+ },
881
+ asterApiKey: {
882
+ type: "string",
883
+ description: "Optional Aster API key",
884
+ },
885
+ asterApiSecret: {
886
+ type: "string",
887
+ description: "Optional Aster API secret",
888
+ },
889
+ privateKey: {
890
+ type: "string",
891
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
892
+ },
893
+ },
894
+ required: ["wallet"],
895
+ },
896
+ },
897
+ {
898
+ name: "predictions_markets",
899
+ description: "Browse prediction markets from Polymarket and Azuro. Costs $0.01 USDC.",
900
+ inputSchema: {
901
+ type: "object",
902
+ properties: {
903
+ venue: {
904
+ type: "string",
905
+ description: "Optional venue filter",
906
+ },
907
+ category: {
908
+ type: "string",
909
+ description: "Optional category filter",
910
+ },
911
+ limit: {
912
+ type: "number",
913
+ description: "Optional limit",
914
+ },
915
+ sort: {
916
+ type: "string",
917
+ description: "Optional sort option",
918
+ },
919
+ privateKey: {
920
+ type: "string",
921
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
922
+ },
923
+ },
924
+ },
925
+ },
926
+ {
927
+ name: "predictions_market",
928
+ description: "Get detailed information about a specific prediction market. Costs $0.01 USDC.",
929
+ inputSchema: {
930
+ type: "object",
931
+ properties: {
932
+ marketId: {
933
+ type: "string",
934
+ description: "Market ID",
935
+ },
936
+ privateKey: {
937
+ type: "string",
938
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
939
+ },
940
+ },
941
+ required: ["marketId"],
942
+ },
943
+ },
944
+ {
945
+ name: "predictions_search",
946
+ description: "Search prediction markets by keyword. Costs $0.01 USDC.",
947
+ inputSchema: {
948
+ type: "object",
949
+ properties: {
950
+ query: {
951
+ type: "string",
952
+ description: "Search query",
953
+ },
954
+ venue: {
955
+ type: "string",
956
+ description: "Optional venue filter",
957
+ },
958
+ limit: {
959
+ type: "number",
960
+ description: "Optional limit",
961
+ },
962
+ privateKey: {
963
+ type: "string",
964
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
965
+ },
966
+ },
967
+ required: ["query"],
968
+ },
969
+ },
970
+ {
971
+ name: "predictions_bet",
972
+ description: "Place a bet on a prediction market outcome. Costs $0.05 USDC.",
973
+ inputSchema: {
974
+ type: "object",
975
+ properties: {
976
+ marketId: {
977
+ type: "string",
978
+ description: "Market ID",
979
+ },
980
+ outcomeId: {
981
+ type: "string",
982
+ description: "Outcome ID",
983
+ },
984
+ amountUsd: {
985
+ type: "number",
986
+ description: "Amount in USD",
987
+ },
988
+ wallet: {
989
+ type: "string",
990
+ description: "Wallet address",
991
+ },
992
+ polymarketApiKey: {
993
+ type: "string",
994
+ description: "Optional Polymarket API key",
995
+ },
996
+ polymarketApiSecret: {
997
+ type: "string",
998
+ description: "Optional Polymarket API secret",
999
+ },
1000
+ privateKey: {
1001
+ type: "string",
1002
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1003
+ },
1004
+ },
1005
+ required: ["marketId", "outcomeId", "amountUsd", "wallet"],
1006
+ },
1007
+ },
1008
+ {
1009
+ name: "predictions_detect_arbs",
1010
+ description: "Scan for arbitrage opportunities across prediction market venues. Free - no payment required.",
1011
+ inputSchema: {
1012
+ type: "object",
1013
+ properties: {
1014
+ minSpreadPct: {
1015
+ type: "number",
1016
+ description: "Optional minimum spread percentage",
1017
+ },
1018
+ venues: {
1019
+ type: "array",
1020
+ items: { type: "string" },
1021
+ description: "Optional venues array",
1022
+ },
1023
+ cryptoOnly: {
1024
+ type: "boolean",
1025
+ description: "Optional crypto-only filter",
1026
+ },
1027
+ maxResults: {
1028
+ type: "number",
1029
+ description: "Optional max results",
1030
+ },
1031
+ privateKey: {
1032
+ type: "string",
1033
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1034
+ },
1035
+ },
1036
+ },
1037
+ },
1038
+ {
1039
+ name: "predictions_calculate_hedge",
1040
+ description: "Calculate optimal perp hedge for cross-venue arbitrage. Free - no payment required.",
1041
+ inputSchema: {
1042
+ type: "object",
1043
+ properties: {
1044
+ marketA: {
1045
+ type: "object",
1046
+ description: "Market A object",
1047
+ },
1048
+ marketB: {
1049
+ type: "object",
1050
+ description: "Market B object",
1051
+ },
1052
+ positionSizeUsd: {
1053
+ type: "number",
1054
+ description: "Position size in USD",
1055
+ },
1056
+ currentPrice: {
1057
+ type: "number",
1058
+ description: "Current price",
1059
+ },
1060
+ fundingRate8h: {
1061
+ type: "number",
1062
+ description: "Optional funding rate (8h)",
1063
+ },
1064
+ privateKey: {
1065
+ type: "string",
1066
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1067
+ },
1068
+ },
1069
+ required: ["marketA", "marketB", "positionSizeUsd", "currentPrice"],
1070
+ },
1071
+ },
1072
+ {
1073
+ name: "predictions_execute_arb",
1074
+ description: "Execute complete arbitrage trade with optional hedge. Costs $0.20 USDC.",
1075
+ inputSchema: {
1076
+ type: "object",
1077
+ properties: {
1078
+ marketA: {
1079
+ type: "object",
1080
+ description: "Market A object",
1081
+ },
1082
+ marketB: {
1083
+ type: "object",
1084
+ description: "Market B object",
1085
+ },
1086
+ positionSizeUsd: {
1087
+ type: "number",
1088
+ description: "Position size in USD",
1089
+ },
1090
+ autoHedge: {
1091
+ type: "boolean",
1092
+ description: "Optional auto-hedge flag",
1093
+ },
1094
+ maxSlippagePct: {
1095
+ type: "number",
1096
+ description: "Optional max slippage percentage",
1097
+ },
1098
+ currentPrice: {
1099
+ type: "number",
1100
+ description: "Optional current price",
1101
+ },
1102
+ wallet: {
1103
+ type: "string",
1104
+ description: "Wallet address",
1105
+ },
1106
+ privateKey: {
1107
+ type: "string",
1108
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1109
+ },
1110
+ },
1111
+ required: ["marketA", "marketB", "positionSizeUsd", "wallet"],
1112
+ },
1113
+ },
1114
+ {
1115
+ name: "predictions_detect_insiders",
1116
+ description: "Detect sophisticated traders via wallet graph analysis. Costs $5.00 USDC.",
1117
+ inputSchema: {
1118
+ type: "object",
1119
+ properties: {
1120
+ timeWindowMinutes: {
1121
+ type: "number",
1122
+ description: "Optional time window in minutes",
1123
+ },
1124
+ minTrades: {
1125
+ type: "number",
1126
+ description: "Optional minimum trades",
1127
+ },
1128
+ minSimilarity: {
1129
+ type: "number",
1130
+ description: "Optional minimum similarity (0-1)",
1131
+ },
1132
+ includeCommunities: {
1133
+ type: "boolean",
1134
+ description: "Optional include communities flag",
1135
+ },
1136
+ maxResults: {
1137
+ type: "number",
1138
+ description: "Optional max results",
1139
+ },
1140
+ assetFilter: {
1141
+ type: "string",
1142
+ description: "Optional asset filter",
1143
+ },
1144
+ trades: {
1145
+ type: "array",
1146
+ description: "Optional trades array",
1147
+ },
1148
+ privateKey: {
1149
+ type: "string",
1150
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1151
+ },
1152
+ },
1153
+ },
1154
+ },
1155
+ {
1156
+ name: "rpc_proxy",
1157
+ description: "JSON-RPC proxy for Ethereum/Base blockchain calls. Costs $0.05 USDC per request. Supports all standard JSON-RPC methods.",
1158
+ inputSchema: {
1159
+ type: "object",
1160
+ properties: {
1161
+ jsonrpc: {
1162
+ type: "string",
1163
+ description: 'JSON-RPC version (typically "2.0")',
1164
+ default: "2.0",
1165
+ },
1166
+ id: {
1167
+ type: "number",
1168
+ description: "Request ID (preserved in response)",
1169
+ },
1170
+ method: {
1171
+ type: "string",
1172
+ description: "RPC method name (e.g., 'eth_blockNumber', 'eth_getBalance', 'eth_call')",
1173
+ },
1174
+ params: {
1175
+ type: "array",
1176
+ description: "Method parameters (array or object)",
1177
+ items: {},
1178
+ },
1179
+ privateKey: {
1180
+ type: "string",
1181
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1182
+ },
1183
+ },
1184
+ required: ["jsonrpc", "id", "method", "params"],
1185
+ },
1186
+ },
1187
+ {
1188
+ name: "call_x402_endpoint",
1189
+ description: "Call an arbitrary x402-protected HTTP endpoint with automatic payment handling. Supports GET, POST, PUT, DELETE, PATCH methods.",
1190
+ inputSchema: {
1191
+ type: "object",
1192
+ properties: {
1193
+ url: {
1194
+ type: "string",
1195
+ description: "Full URL of the x402 endpoint",
1196
+ },
1197
+ method: {
1198
+ type: "string",
1199
+ description: "HTTP method (GET, POST, PUT, DELETE, PATCH)",
1200
+ enum: ["GET", "POST", "PUT", "DELETE", "PATCH"],
1201
+ default: "POST",
1202
+ },
1203
+ body: {
1204
+ type: "object",
1205
+ description: "Request body (will be JSON stringified)",
1206
+ },
1207
+ headers: {
1208
+ type: "object",
1209
+ description: "Additional HTTP headers",
1210
+ additionalProperties: {
1211
+ type: "string",
1212
+ },
1213
+ },
1214
+ privateKey: {
1215
+ type: "string",
1216
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1217
+ },
1218
+ },
1219
+ required: ["url"],
1220
+ },
1221
+ },
1222
+ // Market Intelligence
1223
+ {
1224
+ name: "market_price",
1225
+ description: "Get token price data. Costs $0.001 USDC.",
1226
+ inputSchema: {
1227
+ type: "object",
1228
+ properties: {
1229
+ tokenIdentifier: {
1230
+ type: "string",
1231
+ description: "Token identifier: address, name, or symbol",
1232
+ },
1233
+ timeframe: {
1234
+ type: "string",
1235
+ enum: ["1h", "24h", "7d", "30d"],
1236
+ description: "Optional timeframe",
1237
+ },
1238
+ privateKey: {
1239
+ type: "string",
1240
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1241
+ },
1242
+ },
1243
+ required: ["tokenIdentifier"],
1244
+ },
1245
+ },
1246
+ {
1247
+ name: "market_ohlc",
1248
+ description: "Get OHLC (Open, High, Low, Close) candle data. Costs $0.01 USDC.",
1249
+ inputSchema: {
1250
+ type: "object",
1251
+ properties: {
1252
+ tokenIdentifier: {
1253
+ type: "string",
1254
+ description: "Token identifier: address, name, or symbol",
1255
+ },
1256
+ interval: {
1257
+ type: "string",
1258
+ enum: ["1m", "5m", "15m", "1h", "4h", "1d"],
1259
+ description: "Optional interval",
1260
+ },
1261
+ limit: {
1262
+ type: "number",
1263
+ description: "Optional limit (default: 100)",
1264
+ },
1265
+ privateKey: {
1266
+ type: "string",
1267
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1268
+ },
1269
+ },
1270
+ required: ["tokenIdentifier"],
1271
+ },
1272
+ },
1273
+ {
1274
+ name: "market_liquidity",
1275
+ description: "Get liquidity depth. Costs $0.01 USDC.",
1276
+ inputSchema: {
1277
+ type: "object",
1278
+ properties: {
1279
+ tokenIdentifier: {
1280
+ type: "string",
1281
+ description: "Token identifier: address, name, or symbol",
1282
+ },
1283
+ depth: {
1284
+ type: "number",
1285
+ description: "Optional depth (default: 10)",
1286
+ },
1287
+ privateKey: {
1288
+ type: "string",
1289
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1290
+ },
1291
+ },
1292
+ required: ["tokenIdentifier"],
1293
+ },
1294
+ },
1295
+ {
1296
+ name: "market_price_impact",
1297
+ description: "Estimate price impact for a trade. Costs $0.01 USDC.",
1298
+ inputSchema: {
1299
+ type: "object",
1300
+ properties: {
1301
+ tokenIdentifier: {
1302
+ type: "string",
1303
+ description: "Token identifier: address, name, or symbol",
1304
+ },
1305
+ amount: {
1306
+ type: "string",
1307
+ description: "Trade amount",
1308
+ },
1309
+ side: {
1310
+ type: "string",
1311
+ enum: ["buy", "sell"],
1312
+ description: "Trade side",
1313
+ },
1314
+ privateKey: {
1315
+ type: "string",
1316
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1317
+ },
1318
+ },
1319
+ required: ["tokenIdentifier", "amount", "side"],
1320
+ },
1321
+ },
1322
+ {
1323
+ name: "token_holders_top",
1324
+ description: "Get top holders of a token. Costs $0.01 USDC.",
1325
+ inputSchema: {
1326
+ type: "object",
1327
+ properties: {
1328
+ tokenIdentifier: {
1329
+ type: "string",
1330
+ description: "Token identifier: address, name, or symbol",
1331
+ },
1332
+ limit: {
1333
+ type: "number",
1334
+ description: "Optional limit (default: 10)",
1335
+ },
1336
+ privateKey: {
1337
+ type: "string",
1338
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1339
+ },
1340
+ },
1341
+ required: ["tokenIdentifier"],
1342
+ },
1343
+ },
1344
+ {
1345
+ name: "token_distribution",
1346
+ description: "Get token distribution analysis. Costs $0.01 USDC.",
1347
+ inputSchema: {
1348
+ type: "object",
1349
+ properties: {
1350
+ tokenIdentifier: {
1351
+ type: "string",
1352
+ description: "Token identifier: address, name, or symbol",
1353
+ },
1354
+ privateKey: {
1355
+ type: "string",
1356
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1357
+ },
1358
+ },
1359
+ required: ["tokenIdentifier"],
1360
+ },
1361
+ },
1362
+ {
1363
+ name: "token_supply",
1364
+ description: "Get token supply information. Costs $0.001 USDC.",
1365
+ inputSchema: {
1366
+ type: "object",
1367
+ properties: {
1368
+ tokenIdentifier: {
1369
+ type: "string",
1370
+ description: "Token identifier: address, name, or symbol",
1371
+ },
1372
+ privateKey: {
1373
+ type: "string",
1374
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1375
+ },
1376
+ },
1377
+ required: ["tokenIdentifier"],
1378
+ },
1379
+ },
1380
+ {
1381
+ name: "token_unlocks",
1382
+ description: "Get token unlock schedules. Costs $0.01 USDC.",
1383
+ inputSchema: {
1384
+ type: "object",
1385
+ properties: {
1386
+ tokenIdentifier: {
1387
+ type: "string",
1388
+ description: "Token identifier: address, name, or symbol",
1389
+ },
1390
+ privateKey: {
1391
+ type: "string",
1392
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1393
+ },
1394
+ },
1395
+ required: ["tokenIdentifier"],
1396
+ },
1397
+ },
1398
+ // Security
1399
+ {
1400
+ name: "security_token_scan",
1401
+ description: "Comprehensive token safety scan. Costs $0.01 USDC.",
1402
+ inputSchema: {
1403
+ type: "object",
1404
+ properties: {
1405
+ tokenAddress: {
1406
+ type: "string",
1407
+ description: "Token address (0x format)",
1408
+ },
1409
+ privateKey: {
1410
+ type: "string",
1411
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1412
+ },
1413
+ },
1414
+ required: ["tokenAddress"],
1415
+ },
1416
+ },
1417
+ {
1418
+ name: "security_allowances",
1419
+ description: "Check token allowances for a wallet. Costs $0.001 USDC.",
1420
+ inputSchema: {
1421
+ type: "object",
1422
+ properties: {
1423
+ wallet: {
1424
+ type: "string",
1425
+ description: "Wallet address (0x format)",
1426
+ },
1427
+ token: {
1428
+ type: "string",
1429
+ description: "Token address (0x format)",
1430
+ },
1431
+ spender: {
1432
+ type: "string",
1433
+ description: "Optional spender address (0x format)",
1434
+ },
1435
+ privateKey: {
1436
+ type: "string",
1437
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1438
+ },
1439
+ },
1440
+ required: ["wallet", "token"],
1441
+ },
1442
+ },
1443
+ {
1444
+ name: "security_revoke_allowance",
1445
+ description: "Generate revoke allowance transaction. Costs $0.001 USDC.",
1446
+ inputSchema: {
1447
+ type: "object",
1448
+ properties: {
1449
+ token: {
1450
+ type: "string",
1451
+ description: "Token address (0x format)",
1452
+ },
1453
+ spender: {
1454
+ type: "string",
1455
+ description: "Spender address (0x format)",
1456
+ },
1457
+ wallet: {
1458
+ type: "string",
1459
+ description: "Wallet address (0x format)",
1460
+ },
1461
+ privateKey: {
1462
+ type: "string",
1463
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1464
+ },
1465
+ },
1466
+ required: ["token", "spender", "wallet"],
1467
+ },
1468
+ },
1469
+ // Risk
1470
+ {
1471
+ name: "risk_policy",
1472
+ description: "Get or set risk policy for a wallet. Costs $0.001 USDC.",
1473
+ inputSchema: {
1474
+ type: "object",
1475
+ properties: {
1476
+ wallet: {
1477
+ type: "string",
1478
+ description: "Wallet address (0x format)",
1479
+ },
1480
+ maxPositionSize: {
1481
+ type: "string",
1482
+ description: "Optional max position size (for POST)",
1483
+ },
1484
+ maxLeverage: {
1485
+ type: "number",
1486
+ description: "Optional max leverage (for POST)",
1487
+ },
1488
+ allowedTokens: {
1489
+ type: "array",
1490
+ items: { type: "string" },
1491
+ description: "Optional allowed tokens array (for POST)",
1492
+ },
1493
+ blockedTokens: {
1494
+ type: "array",
1495
+ items: { type: "string" },
1496
+ description: "Optional blocked tokens array (for POST)",
1497
+ },
1498
+ privateKey: {
1499
+ type: "string",
1500
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1501
+ },
1502
+ },
1503
+ required: ["wallet"],
1504
+ },
1505
+ },
1506
+ {
1507
+ name: "risk_evaluate",
1508
+ description: "Evaluate risk policy against a proposed trade. Costs $0.001 USDC.",
1509
+ inputSchema: {
1510
+ type: "object",
1511
+ properties: {
1512
+ wallet: {
1513
+ type: "string",
1514
+ description: "Wallet address (0x format)",
1515
+ },
1516
+ trade: {
1517
+ type: "object",
1518
+ description: "Trade object",
1519
+ properties: {
1520
+ type: {
1521
+ type: "string",
1522
+ enum: ["swap", "perps", "prediction"],
1523
+ },
1524
+ token: { type: "string" },
1525
+ amount: { type: "string" },
1526
+ leverage: { type: "number" },
1527
+ },
1528
+ required: ["type", "token", "amount"],
1529
+ },
1530
+ privateKey: {
1531
+ type: "string",
1532
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1533
+ },
1534
+ },
1535
+ required: ["wallet", "trade"],
1536
+ },
1537
+ },
1538
+ // Trading
1539
+ {
1540
+ name: "trade_preview",
1541
+ description: "Preview trade without executing. Costs $0.001 USDC.",
1542
+ inputSchema: {
1543
+ type: "object",
1544
+ properties: {
1545
+ tokenIn: {
1546
+ type: "string",
1547
+ description: "Token in address (0x format)",
1548
+ },
1549
+ tokenOut: {
1550
+ type: "string",
1551
+ description: "Token out address (0x format)",
1552
+ },
1553
+ amount: {
1554
+ type: "string",
1555
+ description: "Amount in wei",
1556
+ },
1557
+ slippageBps: {
1558
+ type: "number",
1559
+ description: "Optional slippage in basis points",
1560
+ },
1561
+ privateKey: {
1562
+ type: "string",
1563
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1564
+ },
1565
+ },
1566
+ required: ["tokenIn", "tokenOut", "amount"],
1567
+ },
1568
+ },
1569
+ {
1570
+ name: "tx_simulate",
1571
+ description: "Simulate transaction with state analysis. Costs $0.01 USDC.",
1572
+ inputSchema: {
1573
+ type: "object",
1574
+ properties: {
1575
+ transaction: {
1576
+ type: "object",
1577
+ description: "Transaction object",
1578
+ properties: {
1579
+ to: { type: "string" },
1580
+ data: { type: "string" },
1581
+ value: { type: "string" },
1582
+ },
1583
+ required: ["to", "data", "value"],
1584
+ },
1585
+ from: {
1586
+ type: "string",
1587
+ description: "Optional from address (0x format)",
1588
+ },
1589
+ privateKey: {
1590
+ type: "string",
1591
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1592
+ },
1593
+ },
1594
+ required: ["transaction"],
1595
+ },
1596
+ },
1597
+ // Opportunities
1598
+ {
1599
+ name: "opps_arbitrage",
1600
+ description: "Discover arbitrage opportunities. Costs $0.01 USDC.",
1601
+ inputSchema: {
1602
+ type: "object",
1603
+ properties: {
1604
+ minProfit: {
1605
+ type: "string",
1606
+ description: "Optional minimum profit",
1607
+ },
1608
+ tokens: {
1609
+ type: "array",
1610
+ items: { type: "string" },
1611
+ description: "Optional tokens array",
1612
+ },
1613
+ privateKey: {
1614
+ type: "string",
1615
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1616
+ },
1617
+ },
1618
+ },
1619
+ },
1620
+ {
1621
+ name: "opps_funding",
1622
+ description: "Discover funding opportunities. Costs $0.01 USDC.",
1623
+ inputSchema: {
1624
+ type: "object",
1625
+ properties: {
1626
+ minRate: {
1627
+ type: "number",
1628
+ description: "Optional minimum rate",
1629
+ },
1630
+ privateKey: {
1631
+ type: "string",
1632
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1633
+ },
1634
+ },
1635
+ },
1636
+ },
1637
+ {
1638
+ name: "opps_yield",
1639
+ description: "Discover yield opportunities. Costs $0.01 USDC.",
1640
+ inputSchema: {
1641
+ type: "object",
1642
+ properties: {
1643
+ minApy: {
1644
+ type: "number",
1645
+ description: "Optional minimum APY",
1646
+ },
1647
+ privateKey: {
1648
+ type: "string",
1649
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1650
+ },
1651
+ },
1652
+ },
1653
+ },
1654
+ {
1655
+ name: "opps_liquidations",
1656
+ description: "Discover liquidation opportunities. Costs $0.01 USDC.",
1657
+ inputSchema: {
1658
+ type: "object",
1659
+ properties: {
1660
+ minProfit: {
1661
+ type: "string",
1662
+ description: "Optional minimum profit",
1663
+ },
1664
+ privateKey: {
1665
+ type: "string",
1666
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1667
+ },
1668
+ },
1669
+ },
1670
+ },
1671
+ {
1672
+ name: "opps_execute",
1673
+ description: "Execute opportunity. Costs $0.05 USDC.",
1674
+ inputSchema: {
1675
+ type: "object",
1676
+ properties: {
1677
+ opportunityId: {
1678
+ type: "string",
1679
+ description: "Opportunity ID",
1680
+ },
1681
+ wallet: {
1682
+ type: "string",
1683
+ description: "Wallet address (0x format)",
1684
+ },
1685
+ amount: {
1686
+ type: "string",
1687
+ description: "Optional amount",
1688
+ },
1689
+ privateKey: {
1690
+ type: "string",
1691
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1692
+ },
1693
+ },
1694
+ required: ["opportunityId", "wallet"],
1695
+ },
1696
+ },
1697
+ // Portfolio
1698
+ {
1699
+ name: "portfolio_summary",
1700
+ description: "Get portfolio summary. Costs $0.001 USDC.",
1701
+ inputSchema: {
1702
+ type: "object",
1703
+ properties: {
1704
+ wallet: {
1705
+ type: "string",
1706
+ description: "Wallet address (0x format)",
1707
+ },
1708
+ privateKey: {
1709
+ type: "string",
1710
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1711
+ },
1712
+ },
1713
+ required: ["wallet"],
1714
+ },
1715
+ },
1716
+ {
1717
+ name: "portfolio_pnl",
1718
+ description: "Get portfolio P&L. Costs $0.001 USDC.",
1719
+ inputSchema: {
1720
+ type: "object",
1721
+ properties: {
1722
+ wallet: {
1723
+ type: "string",
1724
+ description: "Wallet address (0x format)",
1725
+ },
1726
+ timeframe: {
1727
+ type: "string",
1728
+ enum: ["1d", "7d", "30d", "all"],
1729
+ description: "Optional timeframe",
1730
+ },
1731
+ privateKey: {
1732
+ type: "string",
1733
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1734
+ },
1735
+ },
1736
+ required: ["wallet"],
1737
+ },
1738
+ },
1739
+ {
1740
+ name: "history_trades",
1741
+ description: "Get trade history. Costs $0.001 USDC.",
1742
+ inputSchema: {
1743
+ type: "object",
1744
+ properties: {
1745
+ wallet: {
1746
+ type: "string",
1747
+ description: "Wallet address (0x format)",
1748
+ },
1749
+ limit: {
1750
+ type: "number",
1751
+ description: "Optional limit (default: 50)",
1752
+ },
1753
+ offset: {
1754
+ type: "number",
1755
+ description: "Optional offset (default: 0)",
1756
+ },
1757
+ privateKey: {
1758
+ type: "string",
1759
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1760
+ },
1761
+ },
1762
+ required: ["wallet"],
1763
+ },
1764
+ },
1765
+ {
1766
+ name: "history_transactions",
1767
+ description: "Get transaction history. Costs $0.001 USDC.",
1768
+ inputSchema: {
1769
+ type: "object",
1770
+ properties: {
1771
+ wallet: {
1772
+ type: "string",
1773
+ description: "Wallet address (0x format)",
1774
+ },
1775
+ limit: {
1776
+ type: "number",
1777
+ description: "Optional limit (default: 50)",
1778
+ },
1779
+ offset: {
1780
+ type: "number",
1781
+ description: "Optional offset (default: 0)",
1782
+ },
1783
+ privateKey: {
1784
+ type: "string",
1785
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1786
+ },
1787
+ },
1788
+ required: ["wallet"],
1789
+ },
1790
+ },
1791
+ // Automation
1792
+ {
1793
+ name: "automation_alerts",
1794
+ description: "List, create, or delete alerts. Costs $0.001 USDC.",
1795
+ inputSchema: {
1796
+ type: "object",
1797
+ properties: {
1798
+ wallet: {
1799
+ type: "string",
1800
+ description: "Wallet address (0x format)",
1801
+ },
1802
+ type: {
1803
+ type: "string",
1804
+ enum: ["price", "volume", "mcap"],
1805
+ description: "Alert type (for POST)",
1806
+ },
1807
+ tokenIdentifier: {
1808
+ type: "string",
1809
+ description: "Token identifier (for POST)",
1810
+ },
1811
+ condition: {
1812
+ type: "string",
1813
+ enum: [">", "<", ">=", "<="],
1814
+ description: "Condition (for POST)",
1815
+ },
1816
+ value: {
1817
+ type: "string",
1818
+ description: "Value (for POST)",
1819
+ },
1820
+ webhookUrl: {
1821
+ type: "string",
1822
+ description: "Optional webhook URL (for POST)",
1823
+ },
1824
+ alertId: {
1825
+ type: "string",
1826
+ description: "Alert ID (for DELETE)",
1827
+ },
1828
+ privateKey: {
1829
+ type: "string",
1830
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1831
+ },
1832
+ },
1833
+ required: ["wallet"],
1834
+ },
1835
+ },
1836
+ {
1837
+ name: "automation_webhooks",
1838
+ description: "List or register webhooks. Costs $0.001 USDC.",
1839
+ inputSchema: {
1840
+ type: "object",
1841
+ properties: {
1842
+ wallet: {
1843
+ type: "string",
1844
+ description: "Wallet address (0x format)",
1845
+ },
1846
+ url: {
1847
+ type: "string",
1848
+ description: "Webhook URL (for POST)",
1849
+ },
1850
+ events: {
1851
+ type: "array",
1852
+ items: { type: "string" },
1853
+ description: "Events array (for POST)",
1854
+ },
1855
+ privateKey: {
1856
+ type: "string",
1857
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1858
+ },
1859
+ },
1860
+ required: ["wallet"],
1861
+ },
1862
+ },
1863
+ {
1864
+ name: "automation_jobs",
1865
+ description: "Run automation job. Costs $0.01 USDC.",
1866
+ inputSchema: {
1867
+ type: "object",
1868
+ properties: {
1869
+ jobType: {
1870
+ type: "string",
1871
+ description: "Job type",
1872
+ },
1873
+ parameters: {
1874
+ type: "object",
1875
+ description: "Job parameters",
1876
+ },
1877
+ privateKey: {
1878
+ type: "string",
1879
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1880
+ },
1881
+ },
1882
+ required: ["jobType", "parameters"],
1883
+ },
1884
+ },
1885
+ {
1886
+ name: "automation_jobs_status",
1887
+ description: "Get job status. Costs $0.001 USDC.",
1888
+ inputSchema: {
1889
+ type: "object",
1890
+ properties: {
1891
+ jobId: {
1892
+ type: "string",
1893
+ description: "Job ID (UUID)",
1894
+ },
1895
+ privateKey: {
1896
+ type: "string",
1897
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1898
+ },
1899
+ },
1900
+ required: ["jobId"],
1901
+ },
1902
+ },
1903
+ // System
1904
+ {
1905
+ name: "system_status",
1906
+ description: "Get system status. Costs $0.001 USDC.",
1907
+ inputSchema: {
1908
+ type: "object",
1909
+ properties: {
1910
+ privateKey: {
1911
+ type: "string",
1912
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1913
+ },
1914
+ },
1915
+ },
1916
+ },
1917
+ {
1918
+ name: "system_limits",
1919
+ description: "Get rate limits. Costs $0.001 USDC.",
1920
+ inputSchema: {
1921
+ type: "object",
1922
+ properties: {
1923
+ privateKey: {
1924
+ type: "string",
1925
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1926
+ },
1927
+ },
1928
+ },
1929
+ },
1930
+ {
1931
+ name: "system_sources",
1932
+ description: "Get data sources. Costs $0.001 USDC.",
1933
+ inputSchema: {
1934
+ type: "object",
1935
+ properties: {
1936
+ privateKey: {
1937
+ type: "string",
1938
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1939
+ },
1940
+ },
1941
+ },
1942
+ },
1943
+ // Agent
1944
+ {
1945
+ name: "agent_context",
1946
+ description: "Get agent context. Costs $0.01 USDC.",
1947
+ inputSchema: {
1948
+ type: "object",
1949
+ properties: {
1950
+ agentId: {
1951
+ type: "string",
1952
+ description: "Optional agent ID",
1953
+ },
1954
+ includeHistory: {
1955
+ type: "boolean",
1956
+ description: "Optional include history flag",
1957
+ },
1958
+ privateKey: {
1959
+ type: "string",
1960
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1961
+ },
1962
+ },
1963
+ },
1964
+ },
1965
+ // Tools - Address
1966
+ {
1967
+ name: "tools_address_validate",
1968
+ description: "Validate Ethereum address format. Costs $0.001 USDC.",
1969
+ inputSchema: {
1970
+ type: "object",
1971
+ properties: {
1972
+ address: {
1973
+ type: "string",
1974
+ description: "Address to validate",
1975
+ },
1976
+ privateKey: {
1977
+ type: "string",
1978
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1979
+ },
1980
+ },
1981
+ required: ["address"],
1982
+ },
1983
+ },
1984
+ {
1985
+ name: "tools_address_checksum",
1986
+ description: "Convert address to EIP-55 checksum format. Costs $0.001 USDC.",
1987
+ inputSchema: {
1988
+ type: "object",
1989
+ properties: {
1990
+ address: {
1991
+ type: "string",
1992
+ description: "Address to checksum",
1993
+ },
1994
+ privateKey: {
1995
+ type: "string",
1996
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
1997
+ },
1998
+ },
1999
+ required: ["address"],
2000
+ },
2001
+ },
2002
+ {
2003
+ name: "tools_address_derive",
2004
+ description: "Derive address from private key. Costs $0.001 USDC.",
2005
+ inputSchema: {
2006
+ type: "object",
2007
+ properties: {
2008
+ privateKey: {
2009
+ type: "string",
2010
+ description: "Private key (0x-prefixed hex)",
2011
+ },
2012
+ },
2013
+ required: ["privateKey"],
2014
+ },
2015
+ },
2016
+ {
2017
+ name: "tools_address_balance",
2018
+ description: "Get balance for address (ETH + tokens). Costs $0.001 USDC.",
2019
+ inputSchema: {
2020
+ type: "object",
2021
+ properties: {
2022
+ address: {
2023
+ type: "string",
2024
+ description: "Address (0x format)",
2025
+ },
2026
+ tokens: {
2027
+ type: "array",
2028
+ items: { type: "string" },
2029
+ description: "Optional token addresses",
2030
+ },
2031
+ privateKey: {
2032
+ type: "string",
2033
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2034
+ },
2035
+ },
2036
+ required: ["address"],
2037
+ },
2038
+ },
2039
+ // Tools - ABI
2040
+ {
2041
+ name: "tools_abi_encode",
2042
+ description: "Encode function call from ABI and arguments. Costs $0.001 USDC.",
2043
+ inputSchema: {
2044
+ type: "object",
2045
+ properties: {
2046
+ abi: {
2047
+ type: "array",
2048
+ description: "ABI JSON array",
2049
+ },
2050
+ functionName: {
2051
+ type: "string",
2052
+ description: "Function name",
2053
+ },
2054
+ args: {
2055
+ type: "array",
2056
+ description: "Function arguments",
2057
+ },
2058
+ privateKey: {
2059
+ type: "string",
2060
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2061
+ },
2062
+ },
2063
+ required: ["abi", "functionName", "args"],
2064
+ },
2065
+ },
2066
+ {
2067
+ name: "tools_abi_decode",
2068
+ description: "Decode function result or event log. Costs $0.001 USDC.",
2069
+ inputSchema: {
2070
+ type: "object",
2071
+ properties: {
2072
+ abi: {
2073
+ type: "array",
2074
+ description: "ABI JSON array",
2075
+ },
2076
+ data: {
2077
+ type: "string",
2078
+ description: "Data to decode (0x-prefixed hex)",
2079
+ },
2080
+ type: {
2081
+ type: "string",
2082
+ enum: ["function", "event"],
2083
+ description: "Type: function or event",
2084
+ },
2085
+ privateKey: {
2086
+ type: "string",
2087
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2088
+ },
2089
+ },
2090
+ required: ["abi", "data", "type"],
2091
+ },
2092
+ },
2093
+ {
2094
+ name: "tools_abi_parse",
2095
+ description: "Parse ABI JSON and return structured format. Costs $0.001 USDC.",
2096
+ inputSchema: {
2097
+ type: "object",
2098
+ properties: {
2099
+ abi: {
2100
+ type: "array",
2101
+ description: "ABI JSON array",
2102
+ },
2103
+ privateKey: {
2104
+ type: "string",
2105
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2106
+ },
2107
+ },
2108
+ required: ["abi"],
2109
+ },
2110
+ },
2111
+ // Tools - Transaction
2112
+ {
2113
+ name: "tools_tx_build",
2114
+ description: "Build complete transaction with auto-filled fields. Costs $0.001 USDC.",
2115
+ inputSchema: {
2116
+ type: "object",
2117
+ properties: {
2118
+ to: {
2119
+ type: "string",
2120
+ description: "To address (0x format)",
2121
+ },
2122
+ data: {
2123
+ type: "string",
2124
+ description: "Optional data (0x-prefixed hex)",
2125
+ },
2126
+ value: {
2127
+ type: "string",
2128
+ description: "Optional value (wei)",
2129
+ },
2130
+ from: {
2131
+ type: "string",
2132
+ description: "Optional from address (0x format)",
2133
+ },
2134
+ gasLimit: {
2135
+ type: "string",
2136
+ description: "Optional gas limit (wei)",
2137
+ },
2138
+ gasPrice: {
2139
+ type: "string",
2140
+ description: "Optional gas price (wei)",
2141
+ },
2142
+ nonce: {
2143
+ type: "number",
2144
+ description: "Optional nonce",
2145
+ },
2146
+ privateKey: {
2147
+ type: "string",
2148
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2149
+ },
2150
+ },
2151
+ required: ["to"],
2152
+ },
2153
+ },
2154
+ {
2155
+ name: "tools_tx_encode",
2156
+ description: "Encode transaction to RLP format. Costs $0.001 USDC.",
2157
+ inputSchema: {
2158
+ type: "object",
2159
+ properties: {
2160
+ transaction: {
2161
+ type: "object",
2162
+ description: "Transaction object",
2163
+ properties: {
2164
+ to: { type: "string" },
2165
+ data: { type: "string" },
2166
+ value: { type: "string" },
2167
+ gasLimit: { type: "string" },
2168
+ gasPrice: { type: "string" },
2169
+ nonce: { type: "number" },
2170
+ chainId: { type: "number" },
2171
+ },
2172
+ required: ["to", "data", "value", "gasLimit", "gasPrice", "nonce", "chainId"],
2173
+ },
2174
+ privateKey: {
2175
+ type: "string",
2176
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2177
+ },
2178
+ },
2179
+ required: ["transaction"],
2180
+ },
2181
+ },
2182
+ {
2183
+ name: "tools_tx_decode",
2184
+ description: "Decode RLP transaction. Costs $0.001 USDC.",
2185
+ inputSchema: {
2186
+ type: "object",
2187
+ properties: {
2188
+ rlp: {
2189
+ type: "string",
2190
+ description: "RLP data (0x-prefixed hex)",
2191
+ },
2192
+ privateKey: {
2193
+ type: "string",
2194
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2195
+ },
2196
+ },
2197
+ required: ["rlp"],
2198
+ },
2199
+ },
2200
+ {
2201
+ name: "tools_tx_simulate",
2202
+ description: "Enhanced transaction simulation with state analysis. Costs $0.001 USDC.",
2203
+ inputSchema: {
2204
+ type: "object",
2205
+ properties: {
2206
+ transaction: {
2207
+ type: "object",
2208
+ description: "Transaction object",
2209
+ properties: {
2210
+ to: { type: "string" },
2211
+ data: { type: "string" },
2212
+ value: { type: "string" },
2213
+ },
2214
+ required: ["to", "data", "value"],
2215
+ },
2216
+ from: {
2217
+ type: "string",
2218
+ description: "Optional from address (0x format)",
2219
+ },
2220
+ privateKey: {
2221
+ type: "string",
2222
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2223
+ },
2224
+ },
2225
+ required: ["transaction"],
2226
+ },
2227
+ },
2228
+ {
2229
+ name: "tools_tx_estimate_gas",
2230
+ description: "Estimate gas for transaction. Costs $0.001 USDC.",
2231
+ inputSchema: {
2232
+ type: "object",
2233
+ properties: {
2234
+ transaction: {
2235
+ type: "object",
2236
+ description: "Transaction object",
2237
+ properties: {
2238
+ to: { type: "string" },
2239
+ data: { type: "string" },
2240
+ value: { type: "string" },
2241
+ },
2242
+ required: ["to", "data", "value"],
2243
+ },
2244
+ from: {
2245
+ type: "string",
2246
+ description: "Optional from address (0x format)",
2247
+ },
2248
+ privateKey: {
2249
+ type: "string",
2250
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2251
+ },
2252
+ },
2253
+ required: ["transaction"],
2254
+ },
2255
+ },
2256
+ {
2257
+ name: "tools_tx_prepare",
2258
+ description: "Prepare transaction for signing. Costs $0.001 USDC.",
2259
+ inputSchema: {
2260
+ type: "object",
2261
+ properties: {
2262
+ to: {
2263
+ type: "string",
2264
+ description: "To address (0x format)",
2265
+ },
2266
+ data: {
2267
+ type: "string",
2268
+ description: "Optional data (0x-prefixed hex)",
2269
+ },
2270
+ value: {
2271
+ type: "string",
2272
+ description: "Optional value (wei)",
2273
+ },
2274
+ from: {
2275
+ type: "string",
2276
+ description: "From address (0x format)",
2277
+ },
2278
+ privateKey: {
2279
+ type: "string",
2280
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2281
+ },
2282
+ },
2283
+ required: ["to", "from"],
2284
+ },
2285
+ },
2286
+ // Tools - Signature
2287
+ {
2288
+ name: "tools_signature_eip191",
2289
+ description: "Prepare EIP-191 personal sign message. Costs $0.001 USDC.",
2290
+ inputSchema: {
2291
+ type: "object",
2292
+ properties: {
2293
+ message: {
2294
+ type: "string",
2295
+ description: "Message to sign",
2296
+ },
2297
+ address: {
2298
+ type: "string",
2299
+ description: "Optional address for verification",
2300
+ },
2301
+ privateKey: {
2302
+ type: "string",
2303
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2304
+ },
2305
+ },
2306
+ required: ["message"],
2307
+ },
2308
+ },
2309
+ {
2310
+ name: "tools_signature_eip712",
2311
+ description: "Prepare EIP-712 structured data signature. Costs $0.001 USDC.",
2312
+ inputSchema: {
2313
+ type: "object",
2314
+ properties: {
2315
+ domain: {
2316
+ type: "object",
2317
+ description: "Domain object",
2318
+ properties: {
2319
+ name: { type: "string" },
2320
+ version: { type: "string" },
2321
+ chainId: { type: "number" },
2322
+ verifyingContract: { type: "string" },
2323
+ },
2324
+ required: ["name", "version", "chainId", "verifyingContract"],
2325
+ },
2326
+ types: {
2327
+ type: "object",
2328
+ description: "Types object",
2329
+ },
2330
+ message: {
2331
+ type: "object",
2332
+ description: "Message object",
2333
+ },
2334
+ privateKey: {
2335
+ type: "string",
2336
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2337
+ },
2338
+ },
2339
+ required: ["domain", "types", "message"],
2340
+ },
2341
+ },
2342
+ {
2343
+ name: "tools_signature_permit2",
2344
+ description: "Prepare Permit2 signature message. Costs $0.001 USDC.",
2345
+ inputSchema: {
2346
+ type: "object",
2347
+ properties: {
2348
+ token: {
2349
+ type: "string",
2350
+ description: "Token address (0x format)",
2351
+ },
2352
+ amount: {
2353
+ type: "string",
2354
+ description: "Amount (wei)",
2355
+ },
2356
+ spender: {
2357
+ type: "string",
2358
+ description: "Spender address (0x format)",
2359
+ },
2360
+ nonce: {
2361
+ type: "number",
2362
+ description: "Nonce",
2363
+ },
2364
+ deadline: {
2365
+ type: "number",
2366
+ description: "Deadline (Unix timestamp)",
2367
+ },
2368
+ privateKey: {
2369
+ type: "string",
2370
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2371
+ },
2372
+ },
2373
+ required: ["token", "amount", "spender", "nonce", "deadline"],
2374
+ },
2375
+ },
2376
+ // Sign Command - High-level signing operations
2377
+ {
2378
+ name: "sign_message",
2379
+ description: "Sign a message using EIP-191 personal sign. Costs $0.001 USDC.",
2380
+ inputSchema: {
2381
+ type: "object",
2382
+ properties: {
2383
+ message: {
2384
+ type: "string",
2385
+ description: "Message to sign",
2386
+ },
2387
+ verify: {
2388
+ type: "boolean",
2389
+ description: "Verify signature after signing",
2390
+ default: false,
2391
+ },
2392
+ format: {
2393
+ type: "string",
2394
+ enum: ["hex", "rsv", "compact"],
2395
+ description: "Signature format",
2396
+ default: "hex",
2397
+ },
2398
+ privateKey: {
2399
+ type: "string",
2400
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2401
+ },
2402
+ },
2403
+ required: ["message"],
2404
+ },
2405
+ },
2406
+ {
2407
+ name: "sign_file",
2408
+ description: "Sign a file (hash + EIP-191 signature). Costs $0.001 USDC.",
2409
+ inputSchema: {
2410
+ type: "object",
2411
+ properties: {
2412
+ file: {
2413
+ type: "string",
2414
+ description: "File path to sign",
2415
+ },
2416
+ hashAlgorithm: {
2417
+ type: "string",
2418
+ enum: ["sha256", "keccak256"],
2419
+ description: "Hash algorithm",
2420
+ default: "sha256",
2421
+ },
2422
+ verify: {
2423
+ type: "boolean",
2424
+ description: "Verify signature after signing",
2425
+ default: false,
2426
+ },
2427
+ format: {
2428
+ type: "string",
2429
+ enum: ["hex", "rsv", "compact"],
2430
+ description: "Signature format",
2431
+ default: "hex",
2432
+ },
2433
+ privateKey: {
2434
+ type: "string",
2435
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2436
+ },
2437
+ },
2438
+ required: ["file"],
2439
+ },
2440
+ },
2441
+ {
2442
+ name: "sign_transaction",
2443
+ description: "Sign a transaction (EIP-155). Costs $0.001 USDC.",
2444
+ inputSchema: {
2445
+ type: "object",
2446
+ properties: {
2447
+ transaction: {
2448
+ type: "object",
2449
+ description: "Transaction object",
2450
+ properties: {
2451
+ to: { type: "string", description: "To address (0x format)" },
2452
+ value: { type: "string", description: "Value in wei" },
2453
+ data: { type: "string", description: "Transaction data (0x-prefixed hex)" },
2454
+ gas: { type: "string", description: "Gas limit" },
2455
+ gasPrice: { type: "string", description: "Gas price" },
2456
+ nonce: { type: "number", description: "Nonce" },
2457
+ },
2458
+ required: ["to"],
2459
+ },
2460
+ privateKey: {
2461
+ type: "string",
2462
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2463
+ },
2464
+ },
2465
+ required: ["transaction"],
2466
+ },
2467
+ },
2468
+ {
2469
+ name: "sign_eip712",
2470
+ description: "Sign EIP-712 structured data. Costs $0.001 USDC.",
2471
+ inputSchema: {
2472
+ type: "object",
2473
+ properties: {
2474
+ domain: {
2475
+ type: "object",
2476
+ description: "EIP-712 domain",
2477
+ },
2478
+ types: {
2479
+ type: "object",
2480
+ description: "EIP-712 types",
2481
+ },
2482
+ message: {
2483
+ type: "object",
2484
+ description: "EIP-712 message",
2485
+ },
2486
+ verify: {
2487
+ type: "boolean",
2488
+ description: "Verify signature after signing",
2489
+ default: false,
2490
+ },
2491
+ privateKey: {
2492
+ type: "string",
2493
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2494
+ },
2495
+ },
2496
+ required: ["domain", "types", "message"],
2497
+ },
2498
+ },
2499
+ {
2500
+ name: "sign_permit2",
2501
+ description: "Sign Permit2 token authorization. Costs $0.001 USDC.",
2502
+ inputSchema: {
2503
+ type: "object",
2504
+ properties: {
2505
+ token: {
2506
+ type: "string",
2507
+ description: "Token address (0x format)",
2508
+ },
2509
+ amount: {
2510
+ type: "string",
2511
+ description: "Amount in wei",
2512
+ },
2513
+ spender: {
2514
+ type: "string",
2515
+ description: "Spender address (0x format)",
2516
+ },
2517
+ nonce: {
2518
+ type: "number",
2519
+ description: "Nonce (auto-generated if not provided)",
2520
+ },
2521
+ deadline: {
2522
+ type: "number",
2523
+ description: "Deadline Unix timestamp (auto-generated if not provided)",
2524
+ },
2525
+ verify: {
2526
+ type: "boolean",
2527
+ description: "Verify signature after signing",
2528
+ default: false,
2529
+ },
2530
+ privateKey: {
2531
+ type: "string",
2532
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2533
+ },
2534
+ },
2535
+ required: ["token", "amount", "spender"],
2536
+ },
2537
+ },
2538
+ {
2539
+ name: "sign_batch",
2540
+ description: "Batch sign multiple messages/files. Costs $0.001 USDC per item.",
2541
+ inputSchema: {
2542
+ type: "object",
2543
+ properties: {
2544
+ messages: {
2545
+ type: "array",
2546
+ items: { type: "string" },
2547
+ description: "Array of messages to sign",
2548
+ },
2549
+ files: {
2550
+ type: "array",
2551
+ items: {
2552
+ type: "object",
2553
+ properties: {
2554
+ path: { type: "string" },
2555
+ hashAlgorithm: {
2556
+ type: "string",
2557
+ enum: ["sha256", "keccak256"],
2558
+ default: "sha256",
2559
+ },
2560
+ },
2561
+ required: ["path"],
2562
+ },
2563
+ description: "Array of files to sign",
2564
+ },
2565
+ privateKey: {
2566
+ type: "string",
2567
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2568
+ },
2569
+ },
2570
+ },
2571
+ },
2572
+ {
2573
+ name: "sign_verify",
2574
+ description: "Verify a signature. FREE.",
2575
+ inputSchema: {
2576
+ type: "object",
2577
+ properties: {
2578
+ signature: {
2579
+ type: "string",
2580
+ description: "Signature to verify (hex format)",
2581
+ },
2582
+ message: {
2583
+ type: "string",
2584
+ description: "Original message (string for EIP-191, JSON string for EIP-712)",
2585
+ },
2586
+ type: {
2587
+ type: "string",
2588
+ enum: ["eip191", "eip712"],
2589
+ description: "Signature type",
2590
+ default: "eip191",
2591
+ },
2592
+ domain: {
2593
+ type: "object",
2594
+ description: "EIP-712 domain (required for eip712 type)",
2595
+ },
2596
+ types: {
2597
+ type: "object",
2598
+ description: "EIP-712 types (required for eip712 type)",
2599
+ },
2600
+ primaryType: {
2601
+ type: "string",
2602
+ description: "EIP-712 primary type (required for eip712 type)",
2603
+ },
2604
+ },
2605
+ required: ["signature", "message"],
2606
+ },
2607
+ },
2608
+ // Tools - Multicall
2609
+ {
2610
+ name: "tools_multicall_encode",
2611
+ description: "Encode multicall operation. Costs $0.001 USDC.",
2612
+ inputSchema: {
2613
+ type: "object",
2614
+ properties: {
2615
+ calls: {
2616
+ type: "array",
2617
+ description: "Calls array",
2618
+ items: {
2619
+ type: "object",
2620
+ properties: {
2621
+ target: { type: "string" },
2622
+ data: { type: "string" },
2623
+ },
2624
+ required: ["target", "data"],
2625
+ },
2626
+ },
2627
+ privateKey: {
2628
+ type: "string",
2629
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2630
+ },
2631
+ },
2632
+ required: ["calls"],
2633
+ },
2634
+ },
2635
+ {
2636
+ name: "tools_multicall_decode",
2637
+ description: "Decode multicall results. Costs $0.001 USDC.",
2638
+ inputSchema: {
2639
+ type: "object",
2640
+ properties: {
2641
+ data: {
2642
+ type: "string",
2643
+ description: "Data to decode (0x-prefixed hex)",
2644
+ },
2645
+ calls: {
2646
+ type: "array",
2647
+ description: "Calls array (same as encode input)",
2648
+ items: {
2649
+ type: "object",
2650
+ properties: {
2651
+ target: { type: "string" },
2652
+ data: { type: "string" },
2653
+ },
2654
+ required: ["target", "data"],
2655
+ },
2656
+ },
2657
+ privateKey: {
2658
+ type: "string",
2659
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2660
+ },
2661
+ },
2662
+ required: ["data", "calls"],
2663
+ },
2664
+ },
2665
+ // Tools - Nonce
2666
+ {
2667
+ name: "tools_nonce_get",
2668
+ description: "Get current nonce for address. Costs $0.001 USDC.",
2669
+ inputSchema: {
2670
+ type: "object",
2671
+ properties: {
2672
+ address: {
2673
+ type: "string",
2674
+ description: "Address (0x format)",
2675
+ },
2676
+ privateKey: {
2677
+ type: "string",
2678
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2679
+ },
2680
+ },
2681
+ required: ["address"],
2682
+ },
2683
+ },
2684
+ {
2685
+ name: "tools_nonce_predict",
2686
+ description: "Predict next nonce accounting for pending transactions. Costs $0.001 USDC.",
2687
+ inputSchema: {
2688
+ type: "object",
2689
+ properties: {
2690
+ address: {
2691
+ type: "string",
2692
+ description: "Address (0x format)",
2693
+ },
2694
+ privateKey: {
2695
+ type: "string",
2696
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2697
+ },
2698
+ },
2699
+ required: ["address"],
2700
+ },
2701
+ },
2702
+ // Tools - Gas
2703
+ {
2704
+ name: "tools_gas_price",
2705
+ description: "Get current gas price. Costs $0.001 USDC.",
2706
+ inputSchema: {
2707
+ type: "object",
2708
+ properties: {
2709
+ privateKey: {
2710
+ type: "string",
2711
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2712
+ },
2713
+ },
2714
+ },
2715
+ },
2716
+ {
2717
+ name: "tools_gas_estimate",
2718
+ description: "Estimate gas for operation. Costs $0.001 USDC.",
2719
+ inputSchema: {
2720
+ type: "object",
2721
+ properties: {
2722
+ transaction: {
2723
+ type: "object",
2724
+ description: "Transaction object",
2725
+ properties: {
2726
+ to: { type: "string" },
2727
+ data: { type: "string" },
2728
+ value: { type: "string" },
2729
+ },
2730
+ required: ["to", "data", "value"],
2731
+ },
2732
+ privateKey: {
2733
+ type: "string",
2734
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2735
+ },
2736
+ },
2737
+ required: ["transaction"],
2738
+ },
2739
+ },
2740
+ {
2741
+ name: "tools_gas_optimize",
2742
+ description: "Optimize gas settings for transaction. Costs $0.001 USDC.",
2743
+ inputSchema: {
2744
+ type: "object",
2745
+ properties: {
2746
+ transaction: {
2747
+ type: "object",
2748
+ description: "Transaction object",
2749
+ properties: {
2750
+ to: { type: "string" },
2751
+ data: { type: "string" },
2752
+ value: { type: "string" },
2753
+ },
2754
+ required: ["to", "data", "value"],
2755
+ },
2756
+ priority: {
2757
+ type: "string",
2758
+ enum: ["low", "medium", "high"],
2759
+ description: "Optional priority",
2760
+ },
2761
+ privateKey: {
2762
+ type: "string",
2763
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2764
+ },
2765
+ },
2766
+ required: ["transaction"],
2767
+ },
2768
+ },
2769
+ // Tools - Key
2770
+ {
2771
+ name: "tools_key_derive",
2772
+ description: "Derive address from private key. Costs $0.001 USDC.",
2773
+ inputSchema: {
2774
+ type: "object",
2775
+ properties: {
2776
+ privateKey: {
2777
+ type: "string",
2778
+ description: "Private key (0x-prefixed hex)",
2779
+ },
2780
+ },
2781
+ required: ["privateKey"],
2782
+ },
2783
+ },
2784
+ {
2785
+ name: "tools_key_validate",
2786
+ description: "Validate private key format. Costs $0.001 USDC.",
2787
+ inputSchema: {
2788
+ type: "object",
2789
+ properties: {
2790
+ privateKey: {
2791
+ type: "string",
2792
+ description: "Private key to validate",
2793
+ },
2794
+ },
2795
+ required: ["privateKey"],
2796
+ },
2797
+ },
2798
+ // Tools - RPC
2799
+ {
2800
+ name: "tools_rpc_proxy",
2801
+ description: "Enhanced JSON-RPC proxy. Costs $0.001 USDC.",
2802
+ inputSchema: {
2803
+ type: "object",
2804
+ properties: {
2805
+ method: {
2806
+ type: "string",
2807
+ description: "RPC method name (e.g., 'eth_getBalance')",
2808
+ },
2809
+ params: {
2810
+ type: "array",
2811
+ description: "Method parameters",
2812
+ },
2813
+ privateKey: {
2814
+ type: "string",
2815
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2816
+ },
2817
+ },
2818
+ required: ["method", "params"],
2819
+ },
2820
+ },
2821
+ {
2822
+ name: "tools_rpc_batch",
2823
+ description: "Batch multiple RPC calls. Costs $0.001 USDC.",
2824
+ inputSchema: {
2825
+ type: "object",
2826
+ properties: {
2827
+ requests: {
2828
+ type: "array",
2829
+ description: "RPC requests array",
2830
+ items: {
2831
+ type: "object",
2832
+ properties: {
2833
+ method: { type: "string" },
2834
+ params: { type: "array" },
2835
+ id: { type: "number" },
2836
+ },
2837
+ required: ["method", "params"],
2838
+ },
2839
+ },
2840
+ privateKey: {
2841
+ type: "string",
2842
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2843
+ },
2844
+ },
2845
+ required: ["requests"],
2846
+ },
2847
+ },
2848
+ {
2849
+ name: "tools_rpc_health",
2850
+ description: "Check RPC endpoint health. Costs $0.001 USDC.",
2851
+ inputSchema: {
2852
+ type: "object",
2853
+ properties: {
2854
+ privateKey: {
2855
+ type: "string",
2856
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2857
+ },
2858
+ },
2859
+ },
2860
+ },
2861
+ // Additional Free Endpoints
2862
+ {
2863
+ name: "resolve_tokens",
2864
+ description: "Batch lookup token metadata (name, symbol, decimals, totalSupply) for multiple tokens. Free - no payment required.",
2865
+ inputSchema: {
2866
+ type: "object",
2867
+ properties: {
2868
+ tokens: {
2869
+ type: "array",
2870
+ items: { type: "string" },
2871
+ description: "Token addresses (max 50, 0x format)",
2872
+ },
2873
+ privateKey: {
2874
+ type: "string",
2875
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2876
+ },
2877
+ },
2878
+ required: ["tokens"],
2879
+ },
2880
+ },
2881
+ {
2882
+ name: "wallet_portfolio",
2883
+ description: "Get all token balances for a wallet address. Free - no payment required.",
2884
+ inputSchema: {
2885
+ type: "object",
2886
+ properties: {
2887
+ wallet: {
2888
+ type: "string",
2889
+ description: "Wallet address (0x format)",
2890
+ },
2891
+ tokens: {
2892
+ type: "array",
2893
+ items: { type: "string" },
2894
+ description: "Optional token addresses (max 100, 0x format)",
2895
+ },
2896
+ includeMetadata: {
2897
+ type: "boolean",
2898
+ description: "Optional include metadata (default: true)",
2899
+ },
2900
+ privateKey: {
2901
+ type: "string",
2902
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2903
+ },
2904
+ },
2905
+ required: ["wallet"],
2906
+ },
2907
+ },
2908
+ // Predictions Stream
2909
+ {
2910
+ name: "predictions_stream",
2911
+ description: "Real-time market updates via Server-Sent Events (SSE). Returns connection info. Free - no payment required.",
2912
+ inputSchema: {
2913
+ type: "object",
2914
+ properties: {
2915
+ venues: {
2916
+ type: "string",
2917
+ description: "Comma-separated venues (Polymarket,Azuro)",
2918
+ },
2919
+ sports: {
2920
+ type: "string",
2921
+ description: "Comma-separated sports for Azuro filtering",
2922
+ },
2923
+ min_volume: {
2924
+ type: "number",
2925
+ description: "Minimum 24h volume filter",
2926
+ },
2927
+ poll_interval: {
2928
+ type: "number",
2929
+ description: "Seconds between updates (2-60)",
2930
+ },
2931
+ realtime: {
2932
+ type: "boolean",
2933
+ description: "Use WebSocket feeds (default: false for poll-based)",
2934
+ },
2935
+ privateKey: {
2936
+ type: "string",
2937
+ description: "Optional private key (overrides config and env var). If not provided, uses HTTPCAT_PRIVATE_KEY env var or config file.",
2938
+ },
2939
+ },
2940
+ },
2941
+ },
2942
+ ];
2943
+ // Filter based on admin commands if user is not admin
2944
+ const isAdmin = isCurrentUserAdmin();
2945
+ if (isAdmin) {
2946
+ // Admin users see all tools
2947
+ return allTools;
2948
+ }
2949
+ // Non-admin: filter tools based on HTTPCAT_ADMIN_COMMANDS
2950
+ const adminCommands = getAdminCommands();
2951
+ if (adminCommands.length === 0) {
2952
+ // No admin commands configured, show all tools
2953
+ return allTools;
2954
+ }
2955
+ const adminCommandSet = new Set(adminCommands.map((cmd) => cmd.trim().toLowerCase()));
2956
+ return allTools.filter((tool) => {
2957
+ const commandName = toolNameToCommandName(tool.name);
2958
+ if (!commandName) {
2959
+ // If we can't map it, show it (fail open)
2960
+ return true;
2961
+ }
2962
+ // Hide tool if its command is in admin list
2963
+ return !adminCommandSet.has(commandName.toLowerCase());
2964
+ });
2965
+ }
2966
+ // Generate a unique response ID
2967
+ function generateResponseId() {
2968
+ return `resp_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
2969
+ }
2970
+ export async function handleTool(name, args) {
2971
+ const responseId = generateResponseId();
2972
+ try {
2973
+ let result;
2974
+ switch (name) {
2975
+ case "create_token": {
2976
+ const params = args;
2977
+ const client = await createClient(params.privateKey);
2978
+ result = await createToken(client, {
2979
+ name: params.name,
2980
+ symbol: params.symbol,
2981
+ photoUrl: params.photoUrl,
2982
+ websiteUrl: params.websiteUrl,
2983
+ });
2984
+ break;
2985
+ }
2986
+ case "buy_token": {
2987
+ const params = args;
2988
+ const client = await createClient(params.privateKey);
2989
+ const testMode = isTestMode(client);
2990
+ result = await buyToken(client, params.identifier, params.amount, testMode, true // silent mode for MCP
2991
+ );
2992
+ break;
2993
+ }
2994
+ case "sell_token": {
2995
+ const params = args;
2996
+ const client = await createClient(params.privateKey);
2997
+ // First get token info to check holdings
2998
+ const info = await getTokenInfo(client, params.identifier, undefined, true // silent mode
2999
+ );
3000
+ if (!info.userPosition || info.userPosition.tokensOwned === "0") {
3001
+ throw new Error("You do not own any of this token");
3002
+ }
3003
+ const tokenAmount = parseTokenAmount(params.amount, info.userPosition.tokensOwned);
3004
+ result = await sellToken(client, params.identifier, tokenAmount, true // silent mode
3005
+ );
3006
+ break;
3007
+ }
3008
+ case "token_info": {
3009
+ const params = args;
3010
+ const client = await createClient(params.privateKey);
3011
+ result = await getTokenInfo(client, params.identifier, undefined, true // silent mode
3012
+ );
3013
+ break;
3014
+ }
3015
+ case "list_tokens": {
3016
+ const params = args;
3017
+ const client = await createClient(params.privateKey);
3018
+ result = await listTokens(client, params.page || 1, params.limit || 20, params.sort || "mcap");
3019
+ break;
3020
+ }
3021
+ case "positions": {
3022
+ const params = args;
3023
+ const client = await createClient(params.privateKey);
3024
+ // Get user address from private key
3025
+ const privateKey = resolvePrivateKey(params.privateKey);
3026
+ if (!privateKey) {
3027
+ throw new Error("Private key required for positions command");
3028
+ }
3029
+ const account = privateKeyToAccount(privateKey);
3030
+ const userAddress = account.address;
3031
+ result = await getPositions(client, userAddress);
3032
+ break;
3033
+ }
3034
+ case "check_balance": {
3035
+ const params = args;
3036
+ const resolvedKey = resolvePrivateKey(params.privateKey);
3037
+ result = await checkBalance(resolvedKey);
3038
+ break;
3039
+ }
3040
+ case "health_check": {
3041
+ const params = args;
3042
+ const client = await createClient(params.privateKey);
3043
+ result = await checkHealth(client);
3044
+ break;
3045
+ }
3046
+ case "chat_join": {
3047
+ const params = args;
3048
+ const client = await createClient(params.privateKey);
3049
+ const session = await getOrCreateChatSession(client, params.tokenIdentifier, resolvePrivateKey(params.privateKey));
3050
+ result = {
3051
+ leaseId: session.leaseId,
3052
+ leaseExpiresAt: session.leaseExpiresAt.toISOString(),
3053
+ wsUrl: session.wsUrl,
3054
+ lastMessages: session.messages.slice(-20), // Last 20 messages
3055
+ };
3056
+ break;
3057
+ }
3058
+ case "chat_send_message": {
3059
+ const params = args;
3060
+ const session = getChatSession(params.leaseId);
3061
+ if (!session) {
3062
+ throw new Error(`No active chat session found for leaseId: ${params.leaseId}. Use chat_join first.`);
3063
+ }
3064
+ result = await sendMessage(session, params.message);
3065
+ break;
3066
+ }
3067
+ case "chat_renew_lease": {
3068
+ const params = args;
3069
+ const client = await createClient(params.privateKey);
3070
+ const session = await ensureValidSession(client, params.leaseId, resolvePrivateKey(params.privateKey));
3071
+ result = {
3072
+ leaseId: session.leaseId,
3073
+ leaseExpiresAt: session.leaseExpiresAt.toISOString(),
3074
+ };
3075
+ break;
3076
+ }
3077
+ case "chat_get_recent_messages": {
3078
+ const params = args;
3079
+ const session = getChatSession(params.leaseId);
3080
+ if (!session) {
3081
+ throw new Error(`No active chat session found for leaseId: ${params.leaseId}. Use chat_join first.`);
3082
+ }
3083
+ const messages = getRecentMessages(session, params.limit || 50);
3084
+ result = { messages };
3085
+ break;
3086
+ }
3087
+ case "view_fees": {
3088
+ const params = args;
3089
+ const client = await createClient(params.privateKey);
3090
+ const privateKey = resolvePrivateKey(params.privateKey);
3091
+ if (!params.identifier) {
3092
+ // View all tokens
3093
+ if (!privateKey) {
3094
+ throw new Error("Private key required to view all your tokens");
3095
+ }
3096
+ const account = privateKeyToAccount(privateKey);
3097
+ const userAddress = account.address;
3098
+ const userTokens = await getUserCreatedTokens(client, userAddress);
3099
+ if (userTokens.length === 0) {
3100
+ result = { tokens: [], message: "No tokens created yet" };
3101
+ }
3102
+ else {
3103
+ const allFees = await getAllTokenFees(client, userTokens, true);
3104
+ result = {
3105
+ tokens: allFees.map((fees) => ({
3106
+ tokenId: fees.tokenId,
3107
+ tokenSymbol: fees.tokenSymbol,
3108
+ tokenName: fees.tokenName,
3109
+ feeToken: fees.feeToken,
3110
+ feePaired: fees.feePaired,
3111
+ creatorToken: fees.creatorToken,
3112
+ creatorPaired: fees.creatorPaired,
3113
+ error: 'error' in fees ? fees.error : undefined,
3114
+ })),
3115
+ };
3116
+ }
3117
+ }
3118
+ else {
3119
+ // View specific token
3120
+ result = await viewFees(client, params.identifier, true); // silent mode
3121
+ }
3122
+ break;
3123
+ }
3124
+ case "claim_fees": {
3125
+ const params = args;
3126
+ const client = await createClient(params.privateKey);
3127
+ // Get user address from private key
3128
+ const privateKey = resolvePrivateKey(params.privateKey);
3129
+ if (!privateKey) {
3130
+ throw new Error("Private key required for claim_fees command");
3131
+ }
3132
+ const account = privateKeyToAccount(privateKey);
3133
+ const userAddress = account.address;
3134
+ if (params.identifier.toLowerCase() === 'all') {
3135
+ // Claim all tokens
3136
+ const userTokens = await getUserCreatedTokens(client, userAddress);
3137
+ if (userTokens.length === 0) {
3138
+ result = { tokens: [], message: "No tokens created yet" };
3139
+ }
3140
+ else {
3141
+ const results = await claimAllFees(client, userTokens, userAddress, true);
3142
+ result = {
3143
+ success: results.success,
3144
+ failed: results.failed,
3145
+ };
3146
+ }
3147
+ }
3148
+ else {
3149
+ // Claim specific token
3150
+ result = await claimFees(client, params.identifier, userAddress, true // silent mode
3151
+ );
3152
+ }
3153
+ break;
3154
+ }
3155
+ case "get_transactions": {
3156
+ const params = args;
3157
+ const client = await createClient(params.privateKey);
3158
+ result = await getTransactions(client, {
3159
+ userAddress: params.userAddress,
3160
+ tokenId: params.tokenId,
3161
+ type: params.type,
3162
+ limit: params.limit,
3163
+ offset: params.offset,
3164
+ });
3165
+ break;
3166
+ }
3167
+ case "swap_tokens": {
3168
+ const params = args;
3169
+ const client = await createClient(params.privateKey);
3170
+ const privateKey = resolvePrivateKey(params.privateKey);
3171
+ if (!privateKey) {
3172
+ throw new Error("Private key required for swap_tokens command");
3173
+ }
3174
+ result = await swap(client, params.tokenIn, params.tokenOut, params.amount, params.slippageBps || 50, true, // silent mode
3175
+ privateKey);
3176
+ break;
3177
+ }
3178
+ case "shielded_swap": {
3179
+ const params = args;
3180
+ const client = await createClient(params.privateKey);
3181
+ const privateKey = resolvePrivateKey(params.privateKey);
3182
+ if (!privateKey) {
3183
+ throw new Error("Private key required for shielded_swap command");
3184
+ }
3185
+ result = await shieldedSwap(client, params.tokenIn, params.tokenOut, params.amount, params.slippageBps || 50, privateKey, true // silent mode
3186
+ );
3187
+ break;
3188
+ }
3189
+ case "gasless_swap_quote": {
3190
+ const params = args;
3191
+ const client = await createClient(params.privateKey);
3192
+ const input = {
3193
+ tokenIn: params.tokenIn,
3194
+ tokenOut: params.tokenOut,
3195
+ amount: params.amount,
3196
+ taker: params.taker,
3197
+ ...(params.slippageBps !== undefined && {
3198
+ slippageBps: params.slippageBps,
3199
+ }),
3200
+ };
3201
+ const response = await client.invoke("swaps/gasless", input);
3202
+ result = response.data;
3203
+ break;
3204
+ }
3205
+ case "gasless_swap_status": {
3206
+ const params = args;
3207
+ const client = await createClient(params.privateKey);
3208
+ const input = {
3209
+ tradeHash: params.tradeHash,
3210
+ };
3211
+ if (params.chainId !== undefined) {
3212
+ input.chainId = params.chainId;
3213
+ }
3214
+ const response = await client.invoke("swaps/gasless/status", input);
3215
+ result = response.data;
3216
+ break;
3217
+ }
3218
+ case "gasless_swap_submit": {
3219
+ const params = args;
3220
+ const client = await createClient(params.privateKey);
3221
+ const input = {
3222
+ trade: params.trade,
3223
+ };
3224
+ if (params.chainId !== undefined) {
3225
+ input.chainId = params.chainId;
3226
+ }
3227
+ if (params.approval !== undefined) {
3228
+ input.approval = params.approval;
3229
+ }
3230
+ result = await submitGaslessSwap(client, input, true);
3231
+ break;
3232
+ }
3233
+ case "gasless_swap_submit_our": {
3234
+ const params = args;
3235
+ const client = await createClient(params.privateKey);
3236
+ const input = {
3237
+ tokenIn: params.tokenIn,
3238
+ tokenOut: params.tokenOut,
3239
+ totalAmount: params.totalAmount,
3240
+ feeAmount: params.feeAmount,
3241
+ taker: params.taker,
3242
+ permit2Signature: params.permit2Signature,
3243
+ permitNonce: params.permitNonce,
3244
+ permitDeadline: params.permitDeadline,
3245
+ };
3246
+ result = await submitGaslessSwapOur(client, input, true);
3247
+ break;
3248
+ }
3249
+ case "rpc_proxy": {
3250
+ const params = args;
3251
+ const client = await createClient(params.privateKey);
3252
+ const input = {
3253
+ jsonrpc: params.jsonrpc || "2.0",
3254
+ id: params.id,
3255
+ method: params.method,
3256
+ params: params.params,
3257
+ };
3258
+ const response = await client.invoke("rpc/proxy", input);
3259
+ // The response should be in the format { output: { jsonrpc, id, result/error } }
3260
+ result = response.data;
3261
+ break;
3262
+ }
3263
+ case "call_x402_endpoint": {
3264
+ const params = args;
3265
+ const client = await createClient(params.privateKey);
3266
+ result = await client.callX402Endpoint(params.url, {
3267
+ method: params.method || "POST",
3268
+ body: params.body,
3269
+ headers: params.headers,
3270
+ });
3271
+ break;
3272
+ }
3273
+ case "perps_markets": {
3274
+ const params = args;
3275
+ const client = await createClient(params.privateKey);
3276
+ const input = {};
3277
+ if (params.platform)
3278
+ input.platform = params.platform;
3279
+ if (params.symbol)
3280
+ input.symbol = params.symbol;
3281
+ result = await getPerpsMarkets(client, input, true);
3282
+ break;
3283
+ }
3284
+ case "perps_onboard": {
3285
+ const params = args;
3286
+ const client = await createClient(params.privateKey);
3287
+ result = await onboardPerps(client, params.wallet, true);
3288
+ break;
3289
+ }
3290
+ case "perps_deposit": {
3291
+ const params = args;
3292
+ const client = await createClient(params.privateKey);
3293
+ const input = {
3294
+ amount: params.amount,
3295
+ wallet: params.wallet,
3296
+ };
3297
+ if (params.venue)
3298
+ input.venue = params.venue;
3299
+ if (params.chain)
3300
+ input.chain = params.chain;
3301
+ result = await depositPerps(client, input, true);
3302
+ break;
3303
+ }
3304
+ case "perps_trade": {
3305
+ const params = args;
3306
+ const client = await createClient(params.privateKey);
3307
+ const input = {
3308
+ market: params.market,
3309
+ side: params.side,
3310
+ sizeUsd: params.sizeUsd,
3311
+ leverage: params.leverage,
3312
+ wallet: params.wallet,
3313
+ };
3314
+ if (params.orderType)
3315
+ input.orderType = params.orderType;
3316
+ if (params.price)
3317
+ input.price = params.price;
3318
+ result = await tradePerps(client, input, true);
3319
+ break;
3320
+ }
3321
+ case "perps_positions": {
3322
+ const params = args;
3323
+ const client = await createClient(params.privateKey);
3324
+ const input = {
3325
+ wallet: params.wallet,
3326
+ };
3327
+ if (params.venue)
3328
+ input.venue = params.venue;
3329
+ if (params.asterApiKey)
3330
+ input.asterApiKey = params.asterApiKey;
3331
+ if (params.asterApiSecret)
3332
+ input.asterApiSecret = params.asterApiSecret;
3333
+ result = await getPerpsPositions(client, input, true);
3334
+ break;
3335
+ }
3336
+ case "predictions_markets": {
3337
+ const params = args;
3338
+ const client = await createClient(params.privateKey);
3339
+ const input = {};
3340
+ if (params.venue)
3341
+ input.venue = params.venue;
3342
+ if (params.category)
3343
+ input.category = params.category;
3344
+ if (params.limit)
3345
+ input.limit = params.limit;
3346
+ if (params.sort)
3347
+ input.sort = params.sort;
3348
+ result = await getPredictionMarkets(client, input, true);
3349
+ break;
3350
+ }
3351
+ case "predictions_market": {
3352
+ const params = args;
3353
+ const client = await createClient(params.privateKey);
3354
+ result = await getPredictionMarket(client, params.marketId, true);
3355
+ break;
3356
+ }
3357
+ case "predictions_search": {
3358
+ const params = args;
3359
+ const client = await createClient(params.privateKey);
3360
+ const input = {
3361
+ query: params.query,
3362
+ };
3363
+ if (params.venue)
3364
+ input.venue = params.venue;
3365
+ if (params.limit)
3366
+ input.limit = params.limit;
3367
+ result = await searchPredictionMarkets(client, input, true);
3368
+ break;
3369
+ }
3370
+ case "predictions_bet": {
3371
+ const params = args;
3372
+ const client = await createClient(params.privateKey);
3373
+ const input = {
3374
+ marketId: params.marketId,
3375
+ outcomeId: params.outcomeId,
3376
+ amountUsd: params.amountUsd,
3377
+ wallet: params.wallet,
3378
+ };
3379
+ if (params.polymarketApiKey)
3380
+ input.polymarketApiKey = params.polymarketApiKey;
3381
+ if (params.polymarketApiSecret)
3382
+ input.polymarketApiSecret = params.polymarketApiSecret;
3383
+ result = await placePredictionBet(client, input, true);
3384
+ break;
3385
+ }
3386
+ case "predictions_detect_arbs": {
3387
+ const params = args;
3388
+ const client = await createClient(params.privateKey);
3389
+ const input = {};
3390
+ if (params.minSpreadPct !== undefined)
3391
+ input.minSpreadPct = params.minSpreadPct;
3392
+ if (params.venues)
3393
+ input.venues = params.venues;
3394
+ if (params.cryptoOnly !== undefined)
3395
+ input.cryptoOnly = params.cryptoOnly;
3396
+ if (params.maxResults !== undefined)
3397
+ input.maxResults = params.maxResults;
3398
+ result = await detectPredictionArbs(client, input, true);
3399
+ break;
3400
+ }
3401
+ case "predictions_calculate_hedge": {
3402
+ const params = args;
3403
+ const client = await createClient(params.privateKey);
3404
+ const input = {
3405
+ marketA: params.marketA,
3406
+ marketB: params.marketB,
3407
+ positionSizeUsd: params.positionSizeUsd,
3408
+ currentPrice: params.currentPrice,
3409
+ };
3410
+ if (params.fundingRate8h !== undefined)
3411
+ input.fundingRate8h = params.fundingRate8h;
3412
+ result = await calculatePredictionHedge(client, input, true);
3413
+ break;
3414
+ }
3415
+ case "predictions_execute_arb": {
3416
+ const params = args;
3417
+ const client = await createClient(params.privateKey);
3418
+ const input = {
3419
+ marketA: params.marketA,
3420
+ marketB: params.marketB,
3421
+ positionSizeUsd: params.positionSizeUsd,
3422
+ wallet: params.wallet,
3423
+ };
3424
+ if (params.autoHedge !== undefined)
3425
+ input.autoHedge = params.autoHedge;
3426
+ if (params.maxSlippagePct !== undefined)
3427
+ input.maxSlippagePct = params.maxSlippagePct;
3428
+ if (params.currentPrice !== undefined)
3429
+ input.currentPrice = params.currentPrice;
3430
+ result = await executePredictionArb(client, input, true);
3431
+ break;
3432
+ }
3433
+ case "predictions_detect_insiders": {
3434
+ const params = args;
3435
+ const client = await createClient(params.privateKey);
3436
+ const input = {};
3437
+ if (params.timeWindowMinutes !== undefined)
3438
+ input.timeWindowMinutes = params.timeWindowMinutes;
3439
+ if (params.minTrades !== undefined)
3440
+ input.minTrades = params.minTrades;
3441
+ if (params.minSimilarity !== undefined)
3442
+ input.minSimilarity = params.minSimilarity;
3443
+ if (params.includeCommunities !== undefined)
3444
+ input.includeCommunities = params.includeCommunities;
3445
+ if (params.maxResults !== undefined)
3446
+ input.maxResults = params.maxResults;
3447
+ if (params.assetFilter)
3448
+ input.assetFilter = params.assetFilter;
3449
+ if (params.trades)
3450
+ input.trades = params.trades;
3451
+ result = await detectPredictionInsiders(client, input, true);
3452
+ break;
3453
+ }
3454
+ // Market Intelligence
3455
+ case "market_price": {
3456
+ const params = args;
3457
+ const client = await createClient(params.privateKey);
3458
+ const input = { tokenIdentifier: params.tokenIdentifier };
3459
+ if (params.timeframe)
3460
+ input.timeframe = params.timeframe;
3461
+ const response = await client.invoke("market/price", input);
3462
+ result = response.data;
3463
+ break;
3464
+ }
3465
+ case "market_ohlc": {
3466
+ const params = args;
3467
+ const client = await createClient(params.privateKey);
3468
+ const input = { tokenIdentifier: params.tokenIdentifier };
3469
+ if (params.interval)
3470
+ input.interval = params.interval;
3471
+ if (params.limit !== undefined)
3472
+ input.limit = params.limit;
3473
+ const response = await client.invoke("market/ohlc", input);
3474
+ result = response.data;
3475
+ break;
3476
+ }
3477
+ case "market_liquidity": {
3478
+ const params = args;
3479
+ const client = await createClient(params.privateKey);
3480
+ const input = { tokenIdentifier: params.tokenIdentifier };
3481
+ if (params.depth !== undefined)
3482
+ input.depth = params.depth;
3483
+ const response = await client.invoke("market/liquidity", input);
3484
+ result = response.data;
3485
+ break;
3486
+ }
3487
+ case "market_price_impact": {
3488
+ const params = args;
3489
+ const client = await createClient(params.privateKey);
3490
+ const input = {
3491
+ tokenIdentifier: params.tokenIdentifier,
3492
+ amount: params.amount,
3493
+ side: params.side,
3494
+ };
3495
+ const response = await client.invoke("market/price-impact", input);
3496
+ result = response.data;
3497
+ break;
3498
+ }
3499
+ case "token_holders_top": {
3500
+ const params = args;
3501
+ const client = await createClient(params.privateKey);
3502
+ const input = { tokenIdentifier: params.tokenIdentifier };
3503
+ if (params.limit !== undefined)
3504
+ input.limit = params.limit;
3505
+ const response = await client.invoke("token/holders/top", input);
3506
+ result = response.data;
3507
+ break;
3508
+ }
3509
+ case "token_distribution": {
3510
+ const params = args;
3511
+ const client = await createClient(params.privateKey);
3512
+ const input = { tokenIdentifier: params.tokenIdentifier };
3513
+ const response = await client.invoke("token/distribution", input);
3514
+ result = response.data;
3515
+ break;
3516
+ }
3517
+ case "token_supply": {
3518
+ const params = args;
3519
+ const client = await createClient(params.privateKey);
3520
+ const input = { tokenIdentifier: params.tokenIdentifier };
3521
+ const response = await client.invoke("token/supply", input);
3522
+ result = response.data;
3523
+ break;
3524
+ }
3525
+ case "token_unlocks": {
3526
+ const params = args;
3527
+ const client = await createClient(params.privateKey);
3528
+ const input = { tokenIdentifier: params.tokenIdentifier };
3529
+ const response = await client.invoke("token/unlocks", input);
3530
+ result = response.data;
3531
+ break;
3532
+ }
3533
+ // Security
3534
+ case "security_token_scan": {
3535
+ const params = args;
3536
+ const client = await createClient(params.privateKey);
3537
+ const input = { tokenAddress: params.tokenAddress };
3538
+ const response = await client.invoke("security/token-scan", input);
3539
+ result = response.data;
3540
+ break;
3541
+ }
3542
+ case "security_allowances": {
3543
+ const params = args;
3544
+ const client = await createClient(params.privateKey);
3545
+ const input = {
3546
+ wallet: params.wallet,
3547
+ token: params.token,
3548
+ };
3549
+ if (params.spender)
3550
+ input.spender = params.spender;
3551
+ const response = await client.invoke("security/allowances", input);
3552
+ result = response.data;
3553
+ break;
3554
+ }
3555
+ case "security_revoke_allowance": {
3556
+ const params = args;
3557
+ const client = await createClient(params.privateKey);
3558
+ const input = {
3559
+ token: params.token,
3560
+ spender: params.spender,
3561
+ wallet: params.wallet,
3562
+ };
3563
+ const response = await client.invoke("security/revoke-allowance", input);
3564
+ result = response.data;
3565
+ break;
3566
+ }
3567
+ // Risk
3568
+ case "risk_policy": {
3569
+ const params = args;
3570
+ const client = await createClient(params.privateKey);
3571
+ const input = { wallet: params.wallet };
3572
+ // If any policy fields are provided, it's a POST (set policy)
3573
+ if (params.maxPositionSize !== undefined ||
3574
+ params.maxLeverage !== undefined ||
3575
+ params.allowedTokens !== undefined ||
3576
+ params.blockedTokens !== undefined) {
3577
+ if (params.maxPositionSize !== undefined)
3578
+ input.maxPositionSize = params.maxPositionSize;
3579
+ if (params.maxLeverage !== undefined)
3580
+ input.maxLeverage = params.maxLeverage;
3581
+ if (params.allowedTokens !== undefined)
3582
+ input.allowedTokens = params.allowedTokens;
3583
+ if (params.blockedTokens !== undefined)
3584
+ input.blockedTokens = params.blockedTokens;
3585
+ }
3586
+ const response = await client.invoke("risk/policy", input);
3587
+ result = response.data;
3588
+ break;
3589
+ }
3590
+ case "risk_evaluate": {
3591
+ const params = args;
3592
+ const client = await createClient(params.privateKey);
3593
+ const input = {
3594
+ wallet: params.wallet,
3595
+ trade: params.trade,
3596
+ };
3597
+ const response = await client.invoke("risk/evaluate", input);
3598
+ result = response.data;
3599
+ break;
3600
+ }
3601
+ // Trading
3602
+ case "trade_preview": {
3603
+ const params = args;
3604
+ const client = await createClient(params.privateKey);
3605
+ const input = {
3606
+ tokenIn: params.tokenIn,
3607
+ tokenOut: params.tokenOut,
3608
+ amount: params.amount,
3609
+ };
3610
+ if (params.slippageBps !== undefined)
3611
+ input.slippageBps = params.slippageBps;
3612
+ const response = await client.invoke("trade/preview", input);
3613
+ result = response.data;
3614
+ break;
3615
+ }
3616
+ case "tx_simulate": {
3617
+ const params = args;
3618
+ const client = await createClient(params.privateKey);
3619
+ const input = { transaction: params.transaction };
3620
+ if (params.from)
3621
+ input.from = params.from;
3622
+ const response = await client.invoke("tx/simulate", input);
3623
+ result = response.data;
3624
+ break;
3625
+ }
3626
+ // Opportunities
3627
+ case "opps_arbitrage": {
3628
+ const params = args;
3629
+ const client = await createClient(params.privateKey);
3630
+ const input = {};
3631
+ if (params.minProfit !== undefined)
3632
+ input.minProfit = params.minProfit;
3633
+ if (params.tokens !== undefined)
3634
+ input.tokens = params.tokens;
3635
+ const response = await client.invoke("opps/arbitrage", input);
3636
+ result = response.data;
3637
+ break;
3638
+ }
3639
+ case "opps_funding": {
3640
+ const params = args;
3641
+ const client = await createClient(params.privateKey);
3642
+ const input = {};
3643
+ if (params.minRate !== undefined)
3644
+ input.minRate = params.minRate;
3645
+ const response = await client.invoke("opps/funding", input);
3646
+ result = response.data;
3647
+ break;
3648
+ }
3649
+ case "opps_yield": {
3650
+ const params = args;
3651
+ const client = await createClient(params.privateKey);
3652
+ const input = {};
3653
+ if (params.minApy !== undefined)
3654
+ input.minApy = params.minApy;
3655
+ const response = await client.invoke("opps/yield", input);
3656
+ result = response.data;
3657
+ break;
3658
+ }
3659
+ case "opps_liquidations": {
3660
+ const params = args;
3661
+ const client = await createClient(params.privateKey);
3662
+ const input = {};
3663
+ if (params.minProfit !== undefined)
3664
+ input.minProfit = params.minProfit;
3665
+ const response = await client.invoke("opps/liquidations", input);
3666
+ result = response.data;
3667
+ break;
3668
+ }
3669
+ case "opps_execute": {
3670
+ const params = args;
3671
+ const client = await createClient(params.privateKey);
3672
+ const input = {
3673
+ opportunityId: params.opportunityId,
3674
+ wallet: params.wallet,
3675
+ };
3676
+ if (params.amount !== undefined)
3677
+ input.amount = params.amount;
3678
+ const response = await client.invoke("opps/execute", input);
3679
+ result = response.data;
3680
+ break;
3681
+ }
3682
+ // Portfolio
3683
+ case "portfolio_summary": {
3684
+ const params = args;
3685
+ const client = await createClient(params.privateKey);
3686
+ const input = { wallet: params.wallet };
3687
+ const response = await client.invoke("portfolio/summary", input);
3688
+ result = response.data;
3689
+ break;
3690
+ }
3691
+ case "portfolio_pnl": {
3692
+ const params = args;
3693
+ const client = await createClient(params.privateKey);
3694
+ const input = { wallet: params.wallet };
3695
+ if (params.timeframe !== undefined)
3696
+ input.timeframe = params.timeframe;
3697
+ const response = await client.invoke("portfolio/pnl", input);
3698
+ result = response.data;
3699
+ break;
3700
+ }
3701
+ case "history_trades": {
3702
+ const params = args;
3703
+ const client = await createClient(params.privateKey);
3704
+ const input = { wallet: params.wallet };
3705
+ if (params.limit !== undefined)
3706
+ input.limit = params.limit;
3707
+ if (params.offset !== undefined)
3708
+ input.offset = params.offset;
3709
+ const response = await client.invoke("history/trades", input);
3710
+ result = response.data;
3711
+ break;
3712
+ }
3713
+ case "history_transactions": {
3714
+ const params = args;
3715
+ const client = await createClient(params.privateKey);
3716
+ const input = { wallet: params.wallet };
3717
+ if (params.limit !== undefined)
3718
+ input.limit = params.limit;
3719
+ if (params.offset !== undefined)
3720
+ input.offset = params.offset;
3721
+ const response = await client.invoke("history/transactions", input);
3722
+ result = response.data;
3723
+ break;
3724
+ }
3725
+ // Automation
3726
+ case "automation_alerts": {
3727
+ const params = args;
3728
+ const client = await createClient(params.privateKey);
3729
+ // DELETE if alertId is provided
3730
+ if (params.alertId) {
3731
+ const input = { alertId: params.alertId };
3732
+ const response = await client.invoke("automation/alerts", input);
3733
+ result = response.data;
3734
+ }
3735
+ // POST if type and other fields are provided
3736
+ else if (params.type && params.tokenIdentifier && params.condition && params.value) {
3737
+ const input = {
3738
+ wallet: params.wallet,
3739
+ type: params.type,
3740
+ tokenIdentifier: params.tokenIdentifier,
3741
+ condition: params.condition,
3742
+ value: params.value,
3743
+ };
3744
+ if (params.webhookUrl)
3745
+ input.webhookUrl = params.webhookUrl;
3746
+ const response = await client.invoke("automation/alerts", input);
3747
+ result = response.data;
3748
+ }
3749
+ // GET (list alerts)
3750
+ else {
3751
+ const input = { wallet: params.wallet };
3752
+ const response = await client.invoke("automation/alerts", input);
3753
+ result = response.data;
3754
+ }
3755
+ break;
3756
+ }
3757
+ case "automation_webhooks": {
3758
+ const params = args;
3759
+ const client = await createClient(params.privateKey);
3760
+ // POST if url and events are provided
3761
+ if (params.url && params.events) {
3762
+ const input = {
3763
+ wallet: params.wallet,
3764
+ url: params.url,
3765
+ events: params.events,
3766
+ };
3767
+ const response = await client.invoke("automation/webhooks", input);
3768
+ result = response.data;
3769
+ }
3770
+ // GET (list webhooks)
3771
+ else {
3772
+ const input = { wallet: params.wallet };
3773
+ const response = await client.invoke("automation/webhooks", input);
3774
+ result = response.data;
3775
+ }
3776
+ break;
3777
+ }
3778
+ case "automation_jobs": {
3779
+ const params = args;
3780
+ const client = await createClient(params.privateKey);
3781
+ const input = {
3782
+ jobType: params.jobType,
3783
+ parameters: params.parameters,
3784
+ };
3785
+ const response = await client.invoke("automation/jobs", input);
3786
+ result = response.data;
3787
+ break;
3788
+ }
3789
+ case "automation_jobs_status": {
3790
+ const params = args;
3791
+ const client = await createClient(params.privateKey);
3792
+ const input = { jobId: params.jobId };
3793
+ const response = await client.invoke("automation/jobs/status", input);
3794
+ result = response.data;
3795
+ break;
3796
+ }
3797
+ // System
3798
+ case "system_status": {
3799
+ const params = args;
3800
+ const client = await createClient(params.privateKey);
3801
+ const response = await client.invoke("system/status", {});
3802
+ result = response.data;
3803
+ break;
3804
+ }
3805
+ case "system_limits": {
3806
+ const params = args;
3807
+ const client = await createClient(params.privateKey);
3808
+ const response = await client.invoke("system/limits", {});
3809
+ result = response.data;
3810
+ break;
3811
+ }
3812
+ case "system_sources": {
3813
+ const params = args;
3814
+ const client = await createClient(params.privateKey);
3815
+ const response = await client.invoke("system/sources", {});
3816
+ result = response.data;
3817
+ break;
3818
+ }
3819
+ // Agent
3820
+ case "agent_context": {
3821
+ const params = args;
3822
+ const client = await createClient(params.privateKey);
3823
+ const input = {};
3824
+ if (params.agentId !== undefined)
3825
+ input.agentId = params.agentId;
3826
+ if (params.includeHistory !== undefined)
3827
+ input.includeHistory = params.includeHistory;
3828
+ const response = await client.invoke("agent/context", input);
3829
+ result = response.data;
3830
+ break;
3831
+ }
3832
+ // Tools - Address
3833
+ case "tools_address_validate": {
3834
+ const params = args;
3835
+ const client = await createClient(params.privateKey);
3836
+ const input = { address: params.address };
3837
+ const response = await client.invoke("tools/address/validate", input);
3838
+ result = response.data;
3839
+ break;
3840
+ }
3841
+ case "tools_address_checksum": {
3842
+ const params = args;
3843
+ const client = await createClient(params.privateKey);
3844
+ const input = { address: params.address };
3845
+ const response = await client.invoke("tools/address/checksum", input);
3846
+ result = response.data;
3847
+ break;
3848
+ }
3849
+ case "tools_address_derive": {
3850
+ const params = args;
3851
+ const client = await createClient(params.privateKey);
3852
+ const input = { privateKey: params.privateKey };
3853
+ const response = await client.invoke("tools/address/derive", input);
3854
+ result = response.data;
3855
+ break;
3856
+ }
3857
+ case "tools_address_balance": {
3858
+ const params = args;
3859
+ const client = await createClient(params.privateKey);
3860
+ const input = { address: params.address };
3861
+ if (params.tokens !== undefined)
3862
+ input.tokens = params.tokens;
3863
+ const response = await client.invoke("tools/address/balance", input);
3864
+ result = response.data;
3865
+ break;
3866
+ }
3867
+ // Tools - ABI
3868
+ case "tools_abi_encode": {
3869
+ const params = args;
3870
+ const client = await createClient(params.privateKey);
3871
+ const input = {
3872
+ abi: params.abi,
3873
+ functionName: params.functionName,
3874
+ args: params.args,
3875
+ };
3876
+ const response = await client.invoke("tools/abi/encode", input);
3877
+ result = response.data;
3878
+ break;
3879
+ }
3880
+ case "tools_abi_decode": {
3881
+ const params = args;
3882
+ const client = await createClient(params.privateKey);
3883
+ const input = {
3884
+ abi: params.abi,
3885
+ data: params.data,
3886
+ type: params.type,
3887
+ };
3888
+ const response = await client.invoke("tools/abi/decode", input);
3889
+ result = response.data;
3890
+ break;
3891
+ }
3892
+ case "tools_abi_parse": {
3893
+ const params = args;
3894
+ const client = await createClient(params.privateKey);
3895
+ const input = { abi: params.abi };
3896
+ const response = await client.invoke("tools/abi/parse", input);
3897
+ result = response.data;
3898
+ break;
3899
+ }
3900
+ // Tools - Transaction
3901
+ case "tools_tx_build": {
3902
+ const params = args;
3903
+ const client = await createClient(params.privateKey);
3904
+ const input = { to: params.to };
3905
+ if (params.data !== undefined)
3906
+ input.data = params.data;
3907
+ if (params.value !== undefined)
3908
+ input.value = params.value;
3909
+ if (params.from !== undefined)
3910
+ input.from = params.from;
3911
+ if (params.gasLimit !== undefined)
3912
+ input.gasLimit = params.gasLimit;
3913
+ if (params.gasPrice !== undefined)
3914
+ input.gasPrice = params.gasPrice;
3915
+ if (params.nonce !== undefined)
3916
+ input.nonce = params.nonce;
3917
+ const response = await client.invoke("tools/tx/build", input);
3918
+ result = response.data;
3919
+ break;
3920
+ }
3921
+ case "tools_tx_encode": {
3922
+ const params = args;
3923
+ const client = await createClient(params.privateKey);
3924
+ const input = { transaction: params.transaction };
3925
+ const response = await client.invoke("tools/tx/encode", input);
3926
+ result = response.data;
3927
+ break;
3928
+ }
3929
+ case "tools_tx_decode": {
3930
+ const params = args;
3931
+ const client = await createClient(params.privateKey);
3932
+ const input = { rlp: params.rlp };
3933
+ const response = await client.invoke("tools/tx/decode", input);
3934
+ result = response.data;
3935
+ break;
3936
+ }
3937
+ case "tools_tx_simulate": {
3938
+ const params = args;
3939
+ const client = await createClient(params.privateKey);
3940
+ const input = { transaction: params.transaction };
3941
+ if (params.from !== undefined)
3942
+ input.from = params.from;
3943
+ const response = await client.invoke("tools/tx/simulate", input);
3944
+ result = response.data;
3945
+ break;
3946
+ }
3947
+ case "tools_tx_estimate_gas": {
3948
+ const params = args;
3949
+ const client = await createClient(params.privateKey);
3950
+ const input = { transaction: params.transaction };
3951
+ if (params.from !== undefined)
3952
+ input.from = params.from;
3953
+ const response = await client.invoke("tools/tx/estimate-gas", input);
3954
+ result = response.data;
3955
+ break;
3956
+ }
3957
+ case "tools_tx_prepare": {
3958
+ const params = args;
3959
+ const client = await createClient(params.privateKey);
3960
+ const input = { to: params.to, from: params.from };
3961
+ if (params.data !== undefined)
3962
+ input.data = params.data;
3963
+ if (params.value !== undefined)
3964
+ input.value = params.value;
3965
+ const response = await client.invoke("tools/tx/prepare", input);
3966
+ result = response.data;
3967
+ break;
3968
+ }
3969
+ // Tools - Signature
3970
+ case "tools_signature_eip191": {
3971
+ const params = args;
3972
+ const client = await createClient(params.privateKey);
3973
+ const input = { message: params.message };
3974
+ if (params.address !== undefined)
3975
+ input.address = params.address;
3976
+ const response = await client.invoke("tools/signature/eip191", input);
3977
+ result = response.data;
3978
+ break;
3979
+ }
3980
+ case "tools_signature_eip712": {
3981
+ const params = args;
3982
+ const client = await createClient(params.privateKey);
3983
+ const input = {
3984
+ domain: params.domain,
3985
+ types: params.types,
3986
+ message: params.message,
3987
+ };
3988
+ const response = await client.invoke("tools/signature/eip712", input);
3989
+ result = response.data;
3990
+ break;
3991
+ }
3992
+ case "tools_signature_permit2": {
3993
+ const params = args;
3994
+ const client = await createClient(params.privateKey);
3995
+ const input = {
3996
+ token: params.token,
3997
+ amount: params.amount,
3998
+ spender: params.spender,
3999
+ nonce: params.nonce,
4000
+ deadline: params.deadline,
4001
+ };
4002
+ const response = await client.invoke("tools/signature/permit2", input);
4003
+ result = response.data;
4004
+ break;
4005
+ }
4006
+ // Sign Command - High-level signing operations
4007
+ case "sign_message": {
4008
+ const params = args;
4009
+ const { privateKeyToAccount } = await import("viem/accounts");
4010
+ const { recoverMessageAddress, hashMessage } = await import("viem");
4011
+ const privateKey = resolvePrivateKey(params.privateKey);
4012
+ if (!privateKey) {
4013
+ throw new Error("Private key required for signing");
4014
+ }
4015
+ const account = privateKeyToAccount(privateKey);
4016
+ // Compute message hash locally (no API call needed)
4017
+ const messageHash = hashMessage(params.message);
4018
+ // Sign locally
4019
+ const signature = await account.signMessage({ message: params.message });
4020
+ const signerAddress = account.address;
4021
+ let verified = false;
4022
+ if (params.verify) {
4023
+ const recovered = await recoverMessageAddress({
4024
+ message: params.message,
4025
+ signature,
4026
+ });
4027
+ verified = recovered.toLowerCase() === signerAddress.toLowerCase();
4028
+ }
4029
+ result = {
4030
+ type: "eip191",
4031
+ message: params.message,
4032
+ messageHash: messageHash,
4033
+ signature,
4034
+ signer: signerAddress,
4035
+ verified,
4036
+ };
4037
+ break;
4038
+ }
4039
+ case "sign_file": {
4040
+ const params = args;
4041
+ const { privateKeyToAccount } = await import("viem/accounts");
4042
+ const { recoverMessageAddress, hashMessage, keccak256 } = await import("viem");
4043
+ const { readFileSync, existsSync } = await import("fs");
4044
+ const { createHash } = await import("crypto");
4045
+ const privateKey = resolvePrivateKey(params.privateKey);
4046
+ if (!privateKey) {
4047
+ throw new Error("Private key required for signing");
4048
+ }
4049
+ const account = privateKeyToAccount(privateKey);
4050
+ if (!existsSync(params.file)) {
4051
+ throw new Error(`File not found: ${params.file}`);
4052
+ }
4053
+ const fileContent = readFileSync(params.file);
4054
+ const hashAlgo = params.hashAlgorithm || "sha256";
4055
+ let fileHash;
4056
+ if (hashAlgo === "sha256") {
4057
+ fileHash = createHash("sha256").update(fileContent).digest("hex");
4058
+ }
4059
+ else {
4060
+ const hexString = `0x${fileContent.toString("hex")}`;
4061
+ fileHash = keccak256(hexString).slice(2);
4062
+ }
4063
+ const fileHashHex = `0x${fileHash}`;
4064
+ // Compute message hash locally (no API call needed)
4065
+ const messageHash = hashMessage(fileHashHex);
4066
+ // Sign locally
4067
+ const signature = await account.signMessage({ message: fileHashHex });
4068
+ const signerAddress = account.address;
4069
+ let verified = false;
4070
+ if (params.verify) {
4071
+ const recovered = await recoverMessageAddress({
4072
+ message: fileHashHex,
4073
+ signature,
4074
+ });
4075
+ verified = recovered.toLowerCase() === signerAddress.toLowerCase();
4076
+ }
4077
+ result = {
4078
+ type: "file",
4079
+ file: params.file,
4080
+ fileHash: fileHashHex,
4081
+ hashAlgorithm: hashAlgo,
4082
+ messageHash: messageHash,
4083
+ signature,
4084
+ signer: signerAddress,
4085
+ verified,
4086
+ };
4087
+ break;
4088
+ }
4089
+ case "sign_transaction": {
4090
+ const params = args;
4091
+ const client = await createClient(params.privateKey);
4092
+ // Prepare transaction via backend
4093
+ const prepareResult = await client.invoke("tools/tx/prepare", params.transaction);
4094
+ result = {
4095
+ transaction: prepareResult.data.transaction,
4096
+ messageHash: prepareResult.data.messageHash,
4097
+ note: "Transaction prepared. Use send_transaction or another method to execute.",
4098
+ };
4099
+ break;
4100
+ }
4101
+ case "sign_eip712": {
4102
+ const params = args;
4103
+ const { privateKeyToAccount } = await import("viem/accounts");
4104
+ const { recoverTypedDataAddress, hashTypedData } = await import("viem");
4105
+ const privateKey = resolvePrivateKey(params.privateKey);
4106
+ if (!privateKey) {
4107
+ throw new Error("Private key required for signing");
4108
+ }
4109
+ const account = privateKeyToAccount(privateKey);
4110
+ // Compute message hash locally (no API call needed)
4111
+ const primaryType = Object.keys(params.types).find((k) => k !== "EIP712Domain") || "Message";
4112
+ const messageHash = hashTypedData({
4113
+ domain: params.domain,
4114
+ types: params.types,
4115
+ primaryType: primaryType,
4116
+ message: params.message,
4117
+ });
4118
+ // Sign locally
4119
+ const signature = await account.signTypedData({
4120
+ domain: params.domain,
4121
+ types: params.types,
4122
+ primaryType,
4123
+ message: params.message,
4124
+ });
4125
+ const signerAddress = account.address;
4126
+ let verified = false;
4127
+ if (params.verify) {
4128
+ const recovered = await recoverTypedDataAddress({
4129
+ domain: params.domain,
4130
+ types: params.types,
4131
+ primaryType,
4132
+ message: params.message,
4133
+ signature,
4134
+ });
4135
+ verified = recovered.toLowerCase() === signerAddress.toLowerCase();
4136
+ }
4137
+ result = {
4138
+ type: "eip712",
4139
+ domain: params.domain,
4140
+ types: params.types,
4141
+ message: params.message,
4142
+ messageHash: messageHash,
4143
+ signature,
4144
+ signer: signerAddress,
4145
+ verified,
4146
+ };
4147
+ break;
4148
+ }
4149
+ case "sign_permit2": {
4150
+ const params = args;
4151
+ const { privateKeyToAccount } = await import("viem/accounts");
4152
+ const { recoverTypedDataAddress, hashTypedData } = await import("viem");
4153
+ const { getNetworkConfig } = await import("../utils/constants.js");
4154
+ const { config } = await import("../config.js");
4155
+ const privateKey = resolvePrivateKey(params.privateKey);
4156
+ if (!privateKey) {
4157
+ throw new Error("Private key required for signing");
4158
+ }
4159
+ const account = privateKeyToAccount(privateKey);
4160
+ // Get network for chain ID
4161
+ const network = config.get("network") || "eip155:84532";
4162
+ const { chain } = await getNetworkConfig(network);
4163
+ // Auto-generate nonce and deadline if not provided
4164
+ const nonce = params.nonce ?? Math.floor(Math.random() * 2 ** 32);
4165
+ const deadline = params.deadline ?? Math.floor(Date.now() / 1000) + 3600;
4166
+ // Construct Permit2 EIP-712 data locally (no API call needed)
4167
+ const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
4168
+ const domain = {
4169
+ name: "Permit2",
4170
+ chainId: chain.id,
4171
+ verifyingContract: PERMIT2_ADDRESS,
4172
+ };
4173
+ const types = {
4174
+ PermitSingle: [
4175
+ { name: "details", type: "PermitDetails" },
4176
+ { name: "spender", type: "address" },
4177
+ { name: "sigDeadline", type: "uint256" },
4178
+ ],
4179
+ PermitDetails: [
4180
+ { name: "token", type: "address" },
4181
+ { name: "amount", type: "uint160" },
4182
+ { name: "expiration", type: "uint48" },
4183
+ { name: "nonce", type: "uint48" },
4184
+ ],
4185
+ };
4186
+ const message = {
4187
+ details: {
4188
+ token: params.token,
4189
+ amount: BigInt(params.amount) > BigInt(2 ** 160 - 1) ? BigInt(2 ** 160 - 1) : BigInt(params.amount),
4190
+ expiration: BigInt(deadline),
4191
+ nonce: BigInt(nonce),
4192
+ },
4193
+ spender: params.spender,
4194
+ sigDeadline: BigInt(deadline),
4195
+ };
4196
+ // Compute message hash locally
4197
+ const messageHash = hashTypedData({
4198
+ domain,
4199
+ types: types,
4200
+ primaryType: "PermitSingle",
4201
+ message: message,
4202
+ });
4203
+ // Sign locally
4204
+ const signature = await account.signTypedData({
4205
+ domain,
4206
+ types: types,
4207
+ primaryType: "PermitSingle",
4208
+ message: message,
4209
+ });
4210
+ const signerAddress = account.address;
4211
+ let verified = false;
4212
+ if (params.verify) {
4213
+ const recovered = await recoverTypedDataAddress({
4214
+ domain,
4215
+ types: types,
4216
+ primaryType: "PermitSingle",
4217
+ message: message,
4218
+ signature,
4219
+ });
4220
+ verified = recovered.toLowerCase() === signerAddress.toLowerCase();
4221
+ }
4222
+ result = {
4223
+ type: "permit2",
4224
+ token: params.token,
4225
+ amount: params.amount,
4226
+ spender: params.spender,
4227
+ nonce,
4228
+ deadline,
4229
+ messageHash: messageHash,
4230
+ signature,
4231
+ signer: signerAddress,
4232
+ verified,
4233
+ };
4234
+ break;
4235
+ }
4236
+ case "sign_batch": {
4237
+ const params = args;
4238
+ const { privateKeyToAccount } = await import("viem/accounts");
4239
+ const { hashMessage, keccak256 } = await import("viem");
4240
+ const { readFileSync, existsSync } = await import("fs");
4241
+ const { createHash } = await import("crypto");
4242
+ const privateKey = resolvePrivateKey(params.privateKey);
4243
+ if (!privateKey) {
4244
+ throw new Error("Private key required for signing");
4245
+ }
4246
+ const account = privateKeyToAccount(privateKey);
4247
+ const results = [];
4248
+ // Sign messages (no API calls needed)
4249
+ if (params.messages) {
4250
+ for (const message of params.messages) {
4251
+ // Compute message hash locally
4252
+ const messageHash = hashMessage(message);
4253
+ const signature = await account.signMessage({ message });
4254
+ results.push({
4255
+ type: "message",
4256
+ message,
4257
+ messageHash: messageHash,
4258
+ signature,
4259
+ signer: account.address,
4260
+ });
4261
+ }
4262
+ }
4263
+ // Sign files (no API calls needed)
4264
+ if (params.files) {
4265
+ for (const file of params.files) {
4266
+ if (!existsSync(file.path)) {
4267
+ results.push({
4268
+ type: "file",
4269
+ file: file.path,
4270
+ error: "File not found",
4271
+ });
4272
+ continue;
4273
+ }
4274
+ const fileContent = readFileSync(file.path);
4275
+ const hashAlgo = file.hashAlgorithm || "sha256";
4276
+ let fileHash;
4277
+ if (hashAlgo === "sha256") {
4278
+ fileHash = createHash("sha256").update(fileContent).digest("hex");
4279
+ }
4280
+ else {
4281
+ const hexString = `0x${fileContent.toString("hex")}`;
4282
+ fileHash = keccak256(hexString).slice(2);
4283
+ }
4284
+ const fileHashHex = `0x${fileHash}`;
4285
+ // Compute message hash locally
4286
+ const messageHash = hashMessage(fileHashHex);
4287
+ const signature = await account.signMessage({ message: fileHashHex });
4288
+ results.push({
4289
+ type: "file",
4290
+ file: file.path,
4291
+ fileHash: fileHashHex,
4292
+ hashAlgorithm: hashAlgo,
4293
+ messageHash: messageHash,
4294
+ signature,
4295
+ signer: account.address,
4296
+ });
4297
+ }
4298
+ }
4299
+ result = {
4300
+ count: results.length,
4301
+ signatures: results,
4302
+ };
4303
+ break;
4304
+ }
4305
+ case "sign_verify": {
4306
+ const params = args;
4307
+ const { recoverMessageAddress, recoverTypedDataAddress } = await import("viem");
4308
+ let recoveredAddress;
4309
+ let verified = false;
4310
+ if (params.type === "eip712") {
4311
+ if (!params.domain || !params.types || !params.primaryType) {
4312
+ throw new Error("EIP-712 verification requires domain, types, and primaryType");
4313
+ }
4314
+ const messageObj = typeof params.message === "string" ? JSON.parse(params.message) : params.message;
4315
+ recoveredAddress = await recoverTypedDataAddress({
4316
+ domain: params.domain,
4317
+ types: params.types,
4318
+ primaryType: params.primaryType,
4319
+ message: messageObj,
4320
+ signature: params.signature,
4321
+ });
4322
+ verified = true;
4323
+ }
4324
+ else {
4325
+ // EIP-191
4326
+ recoveredAddress = await recoverMessageAddress({
4327
+ message: params.message,
4328
+ signature: params.signature,
4329
+ });
4330
+ verified = true;
4331
+ }
4332
+ result = {
4333
+ verified,
4334
+ recoveredAddress,
4335
+ signature: params.signature,
4336
+ message: params.message,
4337
+ type: params.type || "eip191",
4338
+ };
4339
+ break;
4340
+ }
4341
+ // Tools - Multicall
4342
+ case "tools_multicall_encode": {
4343
+ const params = args;
4344
+ const client = await createClient(params.privateKey);
4345
+ const input = { calls: params.calls };
4346
+ const response = await client.invoke("tools/multicall/encode", input);
4347
+ result = response.data;
4348
+ break;
4349
+ }
4350
+ case "tools_multicall_decode": {
4351
+ const params = args;
4352
+ const client = await createClient(params.privateKey);
4353
+ const input = {
4354
+ data: params.data,
4355
+ calls: params.calls,
4356
+ };
4357
+ const response = await client.invoke("tools/multicall/decode", input);
4358
+ result = response.data;
4359
+ break;
4360
+ }
4361
+ // Tools - Nonce
4362
+ case "tools_nonce_get": {
4363
+ const params = args;
4364
+ const client = await createClient(params.privateKey);
4365
+ const input = { address: params.address };
4366
+ const response = await client.invoke("tools/nonce/get", input);
4367
+ result = response.data;
4368
+ break;
4369
+ }
4370
+ case "tools_nonce_predict": {
4371
+ const params = args;
4372
+ const client = await createClient(params.privateKey);
4373
+ const input = { address: params.address };
4374
+ const response = await client.invoke("tools/nonce/predict", input);
4375
+ result = response.data;
4376
+ break;
4377
+ }
4378
+ // Tools - Gas
4379
+ case "tools_gas_price": {
4380
+ const params = args;
4381
+ const client = await createClient(params.privateKey);
4382
+ const response = await client.invoke("tools/gas/price", {});
4383
+ result = response.data;
4384
+ break;
4385
+ }
4386
+ case "tools_gas_estimate": {
4387
+ const params = args;
4388
+ const client = await createClient(params.privateKey);
4389
+ const input = { transaction: params.transaction };
4390
+ const response = await client.invoke("tools/gas/estimate", input);
4391
+ result = response.data;
4392
+ break;
4393
+ }
4394
+ case "tools_gas_optimize": {
4395
+ const params = args;
4396
+ const client = await createClient(params.privateKey);
4397
+ const input = { transaction: params.transaction };
4398
+ if (params.priority !== undefined)
4399
+ input.priority = params.priority;
4400
+ const response = await client.invoke("tools/gas/optimize", input);
4401
+ result = response.data;
4402
+ break;
4403
+ }
4404
+ // Tools - Key
4405
+ case "tools_key_derive": {
4406
+ const params = args;
4407
+ const client = await createClient(params.privateKey);
4408
+ const input = { privateKey: params.privateKey };
4409
+ const response = await client.invoke("tools/key/derive", input);
4410
+ result = response.data;
4411
+ break;
4412
+ }
4413
+ case "tools_key_validate": {
4414
+ const params = args;
4415
+ const client = await createClient(params.privateKey);
4416
+ const input = { privateKey: params.privateKey };
4417
+ const response = await client.invoke("tools/key/validate", input);
4418
+ result = response.data;
4419
+ break;
4420
+ }
4421
+ // Tools - RPC
4422
+ case "tools_rpc_proxy": {
4423
+ const params = args;
4424
+ const client = await createClient(params.privateKey);
4425
+ const input = {
4426
+ method: params.method,
4427
+ params: params.params,
4428
+ };
4429
+ const response = await client.invoke("tools/rpc/proxy", input);
4430
+ result = response.data;
4431
+ break;
4432
+ }
4433
+ case "tools_rpc_batch": {
4434
+ const params = args;
4435
+ const client = await createClient(params.privateKey);
4436
+ const input = { requests: params.requests };
4437
+ const response = await client.invoke("tools/rpc/batch", input);
4438
+ result = response.data;
4439
+ break;
4440
+ }
4441
+ case "tools_rpc_health": {
4442
+ const params = args;
4443
+ const client = await createClient(params.privateKey);
4444
+ const response = await client.invoke("tools/rpc/health", {});
4445
+ result = response.data;
4446
+ break;
4447
+ }
4448
+ // Additional Free Endpoints
4449
+ case "resolve_tokens": {
4450
+ const params = args;
4451
+ const client = await createClient(params.privateKey);
4452
+ const input = { tokens: params.tokens };
4453
+ const response = await client.invoke("entrypoints/resolve_tokens/invoke", input);
4454
+ result = response.data;
4455
+ break;
4456
+ }
4457
+ case "wallet_portfolio": {
4458
+ const params = args;
4459
+ const client = await createClient(params.privateKey);
4460
+ const input = { wallet: params.wallet };
4461
+ if (params.tokens !== undefined)
4462
+ input.tokens = params.tokens;
4463
+ if (params.includeMetadata !== undefined)
4464
+ input.includeMetadata = params.includeMetadata;
4465
+ const response = await client.invoke("entrypoints/wallet_portfolio/invoke", input);
4466
+ result = response.data;
4467
+ break;
4468
+ }
4469
+ // Predictions Stream
4470
+ case "predictions_stream": {
4471
+ const params = args;
4472
+ const client = await createClient(params.privateKey);
4473
+ const input = {};
4474
+ if (params.venues !== undefined)
4475
+ input.venues = params.venues;
4476
+ if (params.sports !== undefined)
4477
+ input.sports = params.sports;
4478
+ if (params.min_volume !== undefined)
4479
+ input.min_volume = params.min_volume;
4480
+ if (params.poll_interval !== undefined)
4481
+ input.poll_interval = params.poll_interval;
4482
+ if (params.realtime !== undefined)
4483
+ input.realtime = params.realtime;
4484
+ // Note: SSE endpoints return connection info, not streaming directly
4485
+ const response = await client.invoke("predictions/stream", input);
4486
+ result = {
4487
+ ...response.data,
4488
+ note: "This is an SSE endpoint. Use the connection URL provided to establish a Server-Sent Events connection.",
4489
+ };
540
4490
  break;
541
4491
  }
542
4492
  default: