@arcadia-finance/mcp-server 0.2.1 → 0.3.0

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 (44) hide show
  1. package/README.md +51 -35
  2. package/dist/config/addresses.js +59 -4
  3. package/dist/index.js +37 -0
  4. package/dist/prompts/workflows.js +11 -8
  5. package/dist/tools/dev/send.js +12 -8
  6. package/dist/tools/index.js +16 -6
  7. package/dist/tools/output-schemas.js +128 -0
  8. package/dist/tools/read/account.js +135 -112
  9. package/dist/tools/read/asset-managers.js +158 -0
  10. package/dist/tools/read/assets.js +52 -16
  11. package/dist/tools/read/guides.js +24 -3
  12. package/dist/tools/read/points.js +14 -20
  13. package/dist/tools/read/pools.js +68 -39
  14. package/dist/tools/read/strategy.js +89 -44
  15. package/dist/tools/read/wallet.js +84 -6
  16. package/dist/tools/write/account/add-liquidity.js +9 -3
  17. package/dist/tools/write/account/borrow.js +13 -9
  18. package/dist/tools/write/account/close.js +5 -1
  19. package/dist/tools/write/account/create.js +14 -13
  20. package/dist/tools/write/account/deleverage.js +6 -2
  21. package/dist/tools/write/account/deposit.js +14 -10
  22. package/dist/tools/write/account/format-response.js +5 -4
  23. package/dist/tools/write/account/remove-liquidity.js +5 -1
  24. package/dist/tools/write/account/repay.js +14 -10
  25. package/dist/tools/write/account/stake.js +8 -2
  26. package/dist/tools/write/account/swap.js +5 -1
  27. package/dist/tools/write/account/withdraw.js +13 -9
  28. package/dist/tools/write/asset-managers/compounder.js +111 -0
  29. package/dist/tools/write/asset-managers/cow-swapper.js +49 -0
  30. package/dist/tools/write/asset-managers/encoding.js +162 -0
  31. package/dist/tools/write/asset-managers/merkl-operator.js +51 -0
  32. package/dist/tools/write/asset-managers/rebalancer.js +108 -0
  33. package/dist/tools/write/asset-managers/set-asset-managers.js +75 -0
  34. package/dist/tools/write/asset-managers/shared.js +29 -0
  35. package/dist/tools/write/asset-managers/yield-claimer.js +115 -0
  36. package/dist/tools/write/wallet/approve.js +14 -10
  37. package/package.json +2 -1
  38. package/server.json +26 -2
  39. package/skills/clamm-liquidity/SKILL.md +34 -28
  40. package/skills/clamm-liquidity/automation.md +83 -73
  41. package/skills/clamm-liquidity/selection.md +2 -2
  42. package/skills/clamm-liquidity/strategies.md +28 -30
  43. package/dist/tools/write/asset-manager/configure.js +0 -254
  44. package/dist/tools/write/asset-manager/set.js +0 -62
@@ -1,9 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { accountAbi } from "../../abis/index.js";
3
3
  import { getPublicClient } from "../../clients/chain.js";
4
- import { getChainAmChecks } from "../../config/addresses.js";
4
+ import { getChainAmChecks, AM_KEY_TO_POOL_PROTOCOL, CHAIN_POSITION_MANAGERS, UNIVERSAL_POSITION_MANAGERS, } from "../../config/addresses.js";
5
5
  import { validateAddress, validateChainId } from "../../utils/validation.js";
6
- function trimOverview(overview) {
6
+ import { AccountInfoOutput, AccountHistoryOutput, AccountPnlOutput } from "../output-schemas.js";
7
+ function trimOverview(overview, chainId) {
7
8
  const trimmed = { ...overview };
8
9
  if (Array.isArray(trimmed.historic_actions)) {
9
10
  trimmed.historic_actions_count = trimmed.historic_actions.length;
@@ -11,11 +12,26 @@ function trimOverview(overview) {
11
12
  }
12
13
  if (Array.isArray(trimmed.assets)) {
13
14
  trimmed.assets = trimmed.assets.map((a) => {
14
- const { related_strategies, asset_details: _ad, ...rest } = a;
15
+ const { related_strategies, asset_details, ...rest } = a;
15
16
  const asset = { ...rest };
16
17
  if (Array.isArray(related_strategies) && related_strategies.length > 0) {
17
18
  asset.strategy_count = related_strategies.length;
18
19
  }
20
+ const details = asset_details;
21
+ if (details) {
22
+ if (details.reward_token)
23
+ asset.reward_token = details.reward_token;
24
+ if (details.token0)
25
+ asset.token0 = details.token0;
26
+ if (details.token1)
27
+ asset.token1 = details.token1;
28
+ }
29
+ if (typeof rest.address === "string") {
30
+ const addr = rest.address.toLowerCase();
31
+ const dexProtocol = CHAIN_POSITION_MANAGERS[chainId]?.[addr] ?? UNIVERSAL_POSITION_MANAGERS[addr];
32
+ if (dexProtocol)
33
+ asset.dex_protocol = dexProtocol;
34
+ }
19
35
  return asset;
20
36
  });
21
37
  }
@@ -45,127 +61,118 @@ export function registerAccountTools(server, api, chains) {
45
61
  idempotentHint: true,
46
62
  openWorldHint: true,
47
63
  },
48
- description: "Get full overview of an Arcadia account: health factor, collateral value, debt, deposited assets, liquidation price, and automation status. Pass account_address for a specific account, or wallet_address to list all accounts owned by a wallet. Health factor = 1 - (used_margin / liquidation_value): 1 = no debt (safest), >0 = healthy, 0 = liquidation threshold, <0 = past liquidation. Higher is safer. On Base, also returns which asset managers are enabled (rebalancer, compounder, yield_claimer, merkl_operator, cow_swapper).",
64
+ description: "Get full overview of an Arcadia account: health factor, collateral value, debt, deposited assets, liquidation price, and automation status. Health factor = 1 - (used_margin / liquidation_value): 1 = no debt (safest), >0 = healthy, 0 = liquidation threshold, <0 = past liquidation. Higher is safer. On Base, also returns which asset managers are enabled (rebalancer, compounder, yield_claimer, merkl_operator, cow_swapper). LP positions in assets[] include a dex_protocol field (slipstream, slipstream_v2, staked_slipstream, staked_slipstream_v2, uniV3, uniV4) — use this as the dex_protocol param for write.asset_manager.* tools. The automation object uses internal AM key names (slipstreamV1, slipstreamV2, uniV3, uniV4): map slipstreamV1 → 'slipstream'/'staked_slipstream', slipstreamV2 → 'slipstream_v2'/'staked_slipstream_v2', uniV3 → 'uniV3', uniV4 → 'uniV4'. Numeric fields without a _usd suffix are in the account's numeraire token raw units (divide by 10^decimals: 6 for USDC, 18 for WETH, 8 for cbBTC). Fields ending in _usd are in USD with 18 decimals (divide by 1e18). health_factor is unitless. Asset amounts are raw token units. To list all accounts for a wallet, use read.wallet.accounts.",
49
65
  inputSchema: {
50
- account_address: z.string().optional().describe("Arcadia account address"),
51
- wallet_address: z
52
- .string()
53
- .optional()
54
- .describe("Wallet address to list all owned accounts (returns summary: address, name). Call again with a specific account_address for full details like health factor, collateral, and debt."),
66
+ account_address: z.string().describe("Arcadia account address"),
55
67
  chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
56
68
  },
57
- }, async ({ account_address, wallet_address, chain_id }) => {
69
+ outputSchema: AccountInfoOutput,
70
+ }, async ({ account_address, chain_id }) => {
58
71
  try {
59
72
  const validChainId = validateChainId(chain_id);
60
- if (wallet_address) {
61
- validateAddress(wallet_address, "wallet_address");
62
- const result = await api.getAccounts(validChainId, wallet_address);
63
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
64
- }
65
- if (account_address) {
66
- const validAccount = validateAddress(account_address, "account_address");
67
- const client = getPublicClient(validChainId, chains);
68
- const [overview, liquidation_price, accountVersion] = await Promise.all([
69
- api.getAccountOverview(validChainId, account_address).catch(() => null),
70
- api.getLiquidationPrice(validChainId, account_address).catch(() => null),
71
- client
72
- .readContract({
73
- address: validAccount,
74
- abi: accountAbi,
75
- functionName: "ACCOUNT_VERSION",
76
- })
77
- .then((v) => Number(v))
78
- .catch(() => null),
79
- ]);
80
- if (!overview && !liquidation_price && !accountVersion) {
81
- return {
82
- content: [
83
- {
84
- type: "text",
85
- text: "Error: Could not fetch any data for this account. The account may not exist or the API may be temporarily unavailable.",
86
- },
87
- ],
88
- isError: true,
89
- };
90
- }
91
- const notes = [];
92
- if (!overview) {
93
- notes.push("Account overview unavailable. Partial data returned.");
94
- }
95
- if (overview) {
96
- const ov = overview;
97
- const hf = Number(ov.health_factor ?? 0);
98
- const totalDebt = Number(ov.total_open_debt ?? 0);
99
- if (hf >= 1 && totalDebt === 0) {
100
- notes.push("health_factor is 1 with zero debt — this is the safest state. The account has no outstanding loans.");
101
- }
102
- }
103
- if (liquidation_price) {
104
- const liq = liquidation_price;
105
- const liqPrice = Number(liq.liquidation_price ?? 0);
106
- if (liqPrice > 1_000_000) {
107
- notes.push(`liquidation_price is extremely high ($${liqPrice.toLocaleString()}) — this is typical for delta-neutral positions where both sides of the LP move together. Liquidation is very unlikely.`);
108
- }
109
- }
110
- let automation = null;
111
- const owner = overview?.owner;
112
- if (owner) {
113
- const amChecks = getChainAmChecks(validChainId);
114
- automation = await client
115
- .multicall({
116
- contracts: amChecks.map((c) => ({
117
- address: validAccount,
118
- abi: accountAbi,
119
- functionName: "isAssetManager",
120
- args: [owner, c.address],
121
- })),
122
- allowFailure: true,
123
- })
124
- .then((results) => {
125
- const out = {};
126
- for (const c of amChecks)
127
- out[c.group] = false;
128
- results.forEach((r, i) => {
129
- if (r.status !== "success" || !r.result)
130
- return;
131
- const check = amChecks[i];
132
- if (check.protocol) {
133
- out[check.group] = check.protocol;
134
- }
135
- else {
136
- out[check.group] = true;
137
- }
138
- });
139
- return out;
140
- })
141
- .catch(() => null);
142
- }
143
- const result = {
144
- account_version: accountVersion,
145
- overview: overview ? trimOverview(overview) : null,
146
- liquidation_price,
147
- };
148
- if (automation)
149
- result.automation = automation;
150
- if (notes.length > 0)
151
- result.context_notes = notes;
73
+ const validAccount = validateAddress(account_address, "account_address");
74
+ const client = getPublicClient(validChainId, chains);
75
+ const [overview, liquidation_price, accountVersion] = await Promise.all([
76
+ api.getAccountOverview(validChainId, account_address).catch(() => null),
77
+ api.getLiquidationPrice(validChainId, account_address).catch(() => null),
78
+ client
79
+ .readContract({
80
+ address: validAccount,
81
+ abi: accountAbi,
82
+ functionName: "ACCOUNT_VERSION",
83
+ })
84
+ .then((v) => Number(v))
85
+ .catch(() => null),
86
+ ]);
87
+ if (!overview && !liquidation_price && !accountVersion) {
152
88
  return {
153
89
  content: [
154
90
  {
155
91
  type: "text",
156
- text: JSON.stringify(result, null, 2),
92
+ text: "Error: Could not fetch any data for this account. The account may not exist or the API may be temporarily unavailable.",
157
93
  },
158
94
  ],
95
+ isError: true,
159
96
  };
160
97
  }
98
+ const notes = [];
99
+ if (!overview) {
100
+ notes.push("Account overview unavailable. Partial data returned.");
101
+ }
102
+ if (overview) {
103
+ const ov = overview;
104
+ const hf = Number(ov.health_factor ?? 0);
105
+ const totalDebt = Number(ov.total_open_debt ?? 0);
106
+ if (hf >= 1 && totalDebt === 0) {
107
+ notes.push("health_factor is 1 with zero debt — this is the safest state. The account has no outstanding loans.");
108
+ }
109
+ }
110
+ if (liquidation_price) {
111
+ const liq = liquidation_price;
112
+ const liqPrice = Number(liq.liquidation_price ?? 0);
113
+ if (liqPrice > 1_000_000) {
114
+ notes.push(`liquidation_price is extremely high ($${liqPrice.toLocaleString()}) — this is typical for delta-neutral positions where both sides of the LP move together. Liquidation is very unlikely.`);
115
+ }
116
+ }
117
+ let automation = null;
118
+ const owner = overview?.owner;
119
+ if (owner) {
120
+ const amChecks = getChainAmChecks(validChainId);
121
+ automation = await client
122
+ .multicall({
123
+ contracts: amChecks.map((c) => ({
124
+ address: validAccount,
125
+ abi: accountAbi,
126
+ functionName: "isAssetManager",
127
+ args: [owner, c.address],
128
+ })),
129
+ allowFailure: true,
130
+ })
131
+ .then((results) => {
132
+ const out = {};
133
+ for (const c of amChecks)
134
+ out[c.group] = false;
135
+ let activeProtocol = null;
136
+ results.forEach((r, i) => {
137
+ if (r.status !== "success" || !r.result)
138
+ return;
139
+ const check = amChecks[i];
140
+ if (check.protocol) {
141
+ const userFacing = AM_KEY_TO_POOL_PROTOCOL[check.protocol];
142
+ out[check.group] = userFacing ?? check.protocol;
143
+ if (!activeProtocol)
144
+ activeProtocol = userFacing ?? check.protocol;
145
+ }
146
+ else {
147
+ out[check.group] = true;
148
+ }
149
+ });
150
+ if (activeProtocol) {
151
+ out.dex_protocol = activeProtocol;
152
+ }
153
+ return out;
154
+ })
155
+ .catch(() => null);
156
+ }
157
+ const result = {
158
+ account_version: accountVersion,
159
+ overview: overview
160
+ ? trimOverview(overview, validChainId)
161
+ : null,
162
+ liquidation_price,
163
+ };
164
+ if (automation)
165
+ result.automation = automation;
166
+ if (notes.length > 0)
167
+ result.context_notes = notes;
161
168
  return {
162
169
  content: [
163
170
  {
164
171
  type: "text",
165
- text: "Error: Provide either account_address or wallet_address",
172
+ text: JSON.stringify(result, null, 2),
166
173
  },
167
174
  ],
168
- isError: true,
175
+ structuredContent: result,
169
176
  };
170
177
  }
171
178
  catch (err) {
@@ -188,16 +195,28 @@ export function registerAccountTools(server, api, chains) {
188
195
  idempotentHint: true,
189
196
  openWorldHint: true,
190
197
  },
191
- description: "Get historical collateral and debt values for an Arcadia account over time. Returns a time series of snapshots (timestamp, collateral_value, debt_value, net_value in USD). Useful for charting account performance over a period.",
198
+ description: "Get historical collateral and debt values for an Arcadia account over time. Returns a time series of snapshots (timestamp, collateral_value, debt_value, net_value). Each value is the account's net value in USD (human-readable, not raw units). Useful for charting account performance over a period.",
192
199
  inputSchema: {
193
200
  account_address: z.string().describe("Arcadia account address"),
194
201
  days: z.number().default(14).describe("Number of days of history (default 14)"),
195
202
  chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
196
203
  },
204
+ outputSchema: AccountHistoryOutput,
197
205
  }, async ({ account_address, days, chain_id }) => {
198
206
  try {
199
- const result = await api.getAccountHistory(chain_id, account_address, days);
200
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
207
+ const validChainId = validateChainId(chain_id);
208
+ if (days <= 0) {
209
+ return {
210
+ content: [{ type: "text", text: "Error: days must be a positive number" }],
211
+ isError: true,
212
+ };
213
+ }
214
+ const raw = await api.getAccountHistory(validChainId, account_address, days);
215
+ const result = { history: Array.isArray(raw) ? raw : [] };
216
+ return {
217
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
218
+ structuredContent: result,
219
+ };
201
220
  }
202
221
  catch (err) {
203
222
  return {
@@ -219,16 +238,18 @@ export function registerAccountTools(server, api, chains) {
219
238
  idempotentHint: true,
220
239
  openWorldHint: true,
221
240
  },
222
- description: "Get PnL (cost basis) and yield earned for an Arcadia account. Returns lifetime totals: cost basis vs current value (negative cost_basis = net profit withdrawn), net transfers per token, total yield earned in USD and per token. All monetary values are in USD unless suffixed otherwise.",
241
+ description: "Get PnL (cost basis) and yield earned for an Arcadia account. Returns lifetime totals: cost basis vs current value (negative cost_basis = net profit withdrawn), net transfers per token, total yield earned in USD and per token. cost_basis, current_value, cost_diff are in USD (human-readable). Per-token fields (net_transfers, summed_yields_earned) are in raw token units.",
223
242
  inputSchema: {
224
243
  account_address: z.string().describe("Arcadia account address"),
225
244
  chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
226
245
  },
246
+ outputSchema: AccountPnlOutput,
227
247
  }, async ({ account_address, chain_id }) => {
228
248
  try {
249
+ const validChainId = validateChainId(chain_id);
229
250
  const [pnlRaw, yieldRaw] = await Promise.all([
230
- api.getPnlCostBasis(chain_id, account_address),
231
- api.getYieldEarned(chain_id, account_address),
251
+ api.getPnlCostBasis(validChainId, account_address),
252
+ api.getYieldEarned(validChainId, account_address),
232
253
  ]);
233
254
  const { direct_deposits: _, flashaction_deposits, flashaction_withdrawals, direct_withdrawals, yield_withdrawals, ...pnl } = pnlRaw;
234
255
  if (Array.isArray(flashaction_deposits) && flashaction_deposits.length > 0)
@@ -241,13 +262,15 @@ export function registerAccountTools(server, api, chains) {
241
262
  if (Array.isArray(yield_withdrawals) && yield_withdrawals.length > 0)
242
263
  pnl.yield_withdrawal_count = yield_withdrawals.length;
243
264
  const { daily_yields: _dy, daily_yields_usd: _dyu, ...yieldData } = yieldRaw;
265
+ const result = { pnl_cost_basis: pnl, yield_earned: yieldData };
244
266
  return {
245
267
  content: [
246
268
  {
247
269
  type: "text",
248
- text: JSON.stringify({ pnl_cost_basis: pnl, yield_earned: yieldData }, null, 2),
270
+ text: JSON.stringify(result, null, 2),
249
271
  },
250
272
  ],
273
+ structuredContent: result,
251
274
  };
252
275
  }
253
276
  catch (err) {
@@ -0,0 +1,158 @@
1
+ import { z } from "zod";
2
+ import { validateChainId } from "../../utils/validation.js";
3
+ import { IntentsListOutput } from "../output-schemas.js";
4
+ const POOL_PROTOCOLS = [
5
+ "slipstream",
6
+ "slipstream_v2",
7
+ "staked_slipstream",
8
+ "staked_slipstream_v2",
9
+ "uniV3",
10
+ "uniV4",
11
+ ];
12
+ const DEX_PROTOCOL_PARAM = {
13
+ name: "dex_protocol",
14
+ type: "enum",
15
+ values: POOL_PROTOCOLS,
16
+ hint: "LP DEX protocol of the position",
17
+ };
18
+ const ALL_CHAINS = [8453, 130];
19
+ const BASE_ONLY = [8453];
20
+ const INTENTS = [
21
+ {
22
+ id: "rebalancer",
23
+ tool: "write.asset_manager.rebalancer",
24
+ description: "Repositions LP when out of range, compounds fees and rewards. Configurable triggers, cooldowns, and token composition.",
25
+ sets_managers: ["rebalancer"],
26
+ required_params: [DEX_PROTOCOL_PARAM],
27
+ optional_params: [
28
+ "compound_leftovers",
29
+ "optimal_token0_ratio",
30
+ "trigger_lower_ratio",
31
+ "trigger_upper_ratio",
32
+ "min_rebalance_time",
33
+ "max_rebalance_time",
34
+ "strategy_hook",
35
+ ],
36
+ chains: ALL_CHAINS,
37
+ },
38
+ {
39
+ id: "compounder",
40
+ tool: "write.asset_manager.compounder",
41
+ description: "Claims LP fees and reinvests into position. Pair with rebalancer for compounding between rebalances.",
42
+ sets_managers: ["compounder"],
43
+ required_params: [DEX_PROTOCOL_PARAM],
44
+ optional_params: [],
45
+ chains: ALL_CHAINS,
46
+ },
47
+ {
48
+ id: "compounder_staked",
49
+ tool: "write.asset_manager.compounder_staked",
50
+ description: "Compounder + CowSwap for staked LP positions (e.g. staked Slipstream/Aerodrome). Claims staked rewards (AERO) — staked positions earn staking rewards only, not LP fees. Swaps rewards to a target token via CowSwap batch auction, then compounds back into the LP. Base only.",
51
+ sets_managers: ["cow_swapper", "compounder"],
52
+ required_params: [
53
+ DEX_PROTOCOL_PARAM,
54
+ { name: "sell_tokens", type: "string[]", hint: "array of ERC20 addresses to sell" },
55
+ { name: "buy_token", type: "string", hint: "ERC20 address to buy" },
56
+ ],
57
+ optional_params: [],
58
+ chains: BASE_ONLY,
59
+ },
60
+ {
61
+ id: "yield_claimer",
62
+ tool: "write.asset_manager.yield_claimer",
63
+ description: "Claims pending fees/emissions and sends to a designated recipient address.",
64
+ sets_managers: ["yield_claimer"],
65
+ required_params: [
66
+ DEX_PROTOCOL_PARAM,
67
+ { name: "fee_recipient", type: "address", hint: "address to receive claimed fees" },
68
+ ],
69
+ optional_params: [],
70
+ chains: ALL_CHAINS,
71
+ },
72
+ {
73
+ id: "yield_claimer_cowswap",
74
+ tool: "write.asset_manager.yield_claimer_cowswap",
75
+ description: "Yield claimer coupled with CowSwap. Claims fees, swaps to target token via batch auction, sends to recipient.",
76
+ sets_managers: ["cow_swapper", "yield_claimer"],
77
+ required_params: [
78
+ DEX_PROTOCOL_PARAM,
79
+ { name: "sell_tokens", type: "string[]", hint: "array of ERC20 addresses to sell" },
80
+ { name: "buy_token", type: "string", hint: "ERC20 address to buy" },
81
+ { name: "fee_recipient", type: "address", hint: "address to receive claimed fees" },
82
+ ],
83
+ optional_params: [],
84
+ chains: BASE_ONLY,
85
+ },
86
+ {
87
+ id: "cow_swapper",
88
+ tool: "write.asset_manager.cow_swapper",
89
+ description: "Standalone CowSwap mode. Swap any ERC20 via batch auctions. Each swap requires account owner signature.",
90
+ sets_managers: ["cow_swapper"],
91
+ required_params: [],
92
+ optional_params: [],
93
+ chains: BASE_ONLY,
94
+ },
95
+ {
96
+ id: "merkl_operator",
97
+ tool: "write.asset_manager.merkl_operator",
98
+ description: "Claims external Merkl incentive rewards. Enable when pool has active Merkl campaigns. Combine with rebalancer for extra yield.",
99
+ sets_managers: ["merkl_operator"],
100
+ required_params: [
101
+ { name: "reward_recipient", type: "address", hint: "address to receive Merkl rewards" },
102
+ ],
103
+ optional_params: [],
104
+ chains: ALL_CHAINS,
105
+ },
106
+ ];
107
+ export function registerAssetManagerTools(server) {
108
+ server.registerTool("read.asset_manager.intents", {
109
+ annotations: {
110
+ title: "List Available Automations",
111
+ readOnlyHint: true,
112
+ destructiveHint: false,
113
+ idempotentHint: true,
114
+ openWorldHint: false,
115
+ },
116
+ description: "List all available automation intents with their tool names, required parameters, and supported chains. Use this to discover which automations can be configured and what each one does. Each intent has a corresponding write.asset_manager.{id} tool that returns encoded args. To apply automations, call the intent tools then pass the combined result to write.account.set_asset_managers. All intent tools accept enabled=false to disable. Multiple intents can be combined by merging their returned arrays into a single set_asset_managers call.",
117
+ inputSchema: {
118
+ chain_id: z
119
+ .number()
120
+ .optional()
121
+ .describe("Filter to automations available on this chain. Omit to see all."),
122
+ },
123
+ outputSchema: IntentsListOutput,
124
+ }, async (params) => {
125
+ try {
126
+ let filtered = INTENTS;
127
+ if (params.chain_id !== undefined) {
128
+ const validChainId = validateChainId(params.chain_id);
129
+ filtered = INTENTS.filter((i) => i.chains.includes(validChainId));
130
+ }
131
+ const result = {
132
+ automations: filtered,
133
+ shared_params: ["enabled (boolean, default true)", "chain_id (number, default 8453)"],
134
+ usage: "1. Call the intent tool (e.g. write.asset_manager.rebalancer) with enabled + chain_id to get encoded args. 2. Optionally merge arrays from multiple intent calls. 3. Pass to write.account.set_asset_managers to build the unsigned tx.",
135
+ };
136
+ return {
137
+ content: [
138
+ {
139
+ type: "text",
140
+ text: JSON.stringify(result, null, 2),
141
+ },
142
+ ],
143
+ structuredContent: result,
144
+ };
145
+ }
146
+ catch (err) {
147
+ return {
148
+ content: [
149
+ {
150
+ type: "text",
151
+ text: `Error: ${err instanceof Error ? err.message : String(err)}`,
152
+ },
153
+ ],
154
+ isError: true,
155
+ };
156
+ }
157
+ });
158
+ }
@@ -1,34 +1,25 @@
1
1
  import { z } from "zod";
2
+ import { AssetListOutput, AssetPricesOutput } from "../output-schemas.js";
2
3
  export function registerAssetTools(server, api) {
3
- server.registerTool("read.assets", {
4
+ server.registerTool("read.asset.list", {
4
5
  annotations: {
5
- title: "Get Supported Assets",
6
+ title: "List Supported Assets",
6
7
  readOnlyHint: true,
7
8
  destructiveHint: false,
8
9
  idempotentHint: true,
9
10
  openWorldHint: true,
10
11
  },
11
- description: "Get supported collateral assets on Arcadia. Returns compact list (address, symbol, decimals, type) by default. Use asset_addresses for USD price lookup. Use search to filter by symbol substring.",
12
+ description: "List supported collateral assets on Arcadia. Returns compact list (address, symbol, decimals, type). Use search to filter by symbol substring. For USD prices, use read.asset.prices.",
12
13
  inputSchema: {
13
- asset_addresses: z
14
- .string()
15
- .optional()
16
- .describe("Single address or comma-separated addresses for price lookup"),
17
14
  search: z
18
15
  .string()
19
16
  .optional()
20
17
  .describe("Filter assets by symbol (case-insensitive substring match)"),
21
18
  chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
22
19
  },
23
- }, async ({ asset_addresses, search, chain_id }) => {
20
+ outputSchema: AssetListOutput,
21
+ }, async ({ search, chain_id }) => {
24
22
  try {
25
- if (asset_addresses) {
26
- const addresses = asset_addresses.split(",").map((a) => a.trim());
27
- const result = addresses.length === 1
28
- ? await api.getPrice(chain_id, addresses[0])
29
- : await api.getPrices(chain_id, addresses);
30
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
31
- }
32
23
  const raw = await api.getAssets(chain_id);
33
24
  const obj = raw;
34
25
  const allAssets = (Array.isArray(raw) ? raw : (obj.assets ?? obj.data ?? []));
@@ -43,7 +34,52 @@ export function registerAssetTools(server, api) {
43
34
  assets = assets.filter((a) => (a.symbol ?? "").toLowerCase().includes(q));
44
35
  }
45
36
  const result = { total: assets.length, assets };
46
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
37
+ return {
38
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
39
+ structuredContent: result,
40
+ };
41
+ }
42
+ catch (err) {
43
+ return {
44
+ content: [
45
+ {
46
+ type: "text",
47
+ text: `Error: ${err instanceof Error ? err.message : String(err)}`,
48
+ },
49
+ ],
50
+ isError: true,
51
+ };
52
+ }
53
+ });
54
+ server.registerTool("read.asset.prices", {
55
+ annotations: {
56
+ title: "Get Asset Prices",
57
+ readOnlyHint: true,
58
+ destructiveHint: false,
59
+ idempotentHint: true,
60
+ openWorldHint: true,
61
+ },
62
+ description: "Get USD prices for one or more asset addresses. Pass a single address or comma-separated addresses. Returns a price map keyed by address.",
63
+ inputSchema: {
64
+ asset_addresses: z
65
+ .string()
66
+ .describe("Single address or comma-separated addresses for price lookup"),
67
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
68
+ },
69
+ outputSchema: AssetPricesOutput,
70
+ }, async ({ asset_addresses, chain_id }) => {
71
+ try {
72
+ const addresses = asset_addresses.split(",").map((a) => a.trim());
73
+ const result = addresses.length === 1
74
+ ? await api.getPrice(chain_id, addresses[0])
75
+ : await api.getPrices(chain_id, addresses);
76
+ const wrapped = typeof result === "number"
77
+ ? { prices: { [addresses[0]]: result } }
78
+ : { prices: result };
79
+ return {
80
+ content: [{ type: "text", text: JSON.stringify(wrapped, null, 2) }],
81
+ structuredContent: wrapped,
82
+ };
47
83
  }
48
84
  catch (err) {
49
85
  return {
@@ -2,6 +2,7 @@ import { readFileSync } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { dirname, resolve } from "node:path";
4
4
  import { z } from "zod";
5
+ import { GuideOutput } from "../output-schemas.js";
5
6
  const TOPICS = {
6
7
  overview: {
7
8
  file: "SKILL.md",
@@ -45,9 +46,29 @@ export function registerGuideTools(server) {
45
46
  inputSchema: {
46
47
  topic: z
47
48
  .enum(TOPIC_KEYS)
49
+ .optional()
48
50
  .describe("overview = addresses + tool catalog, automation = rebalancer/compounder/claimer setup, strategies = step-by-step LP templates, selection = pool evaluation + leverage sizing"),
49
51
  },
50
- }, async ({ topic }) => ({
51
- content: [{ type: "text", text: guides.get(topic) }],
52
- }));
52
+ outputSchema: GuideOutput,
53
+ }, async ({ topic }) => {
54
+ if (!topic) {
55
+ const topicList = Object.entries(TOPICS)
56
+ .map(([key, { summary }]) => ` ${key}: ${summary}`)
57
+ .join("\n");
58
+ const result = {
59
+ topic: "",
60
+ content: `topic is required. Valid topics:\n${topicList}`,
61
+ };
62
+ return {
63
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
64
+ structuredContent: result,
65
+ isError: true,
66
+ };
67
+ }
68
+ const result = { topic, content: guides.get(topic) };
69
+ return {
70
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
71
+ structuredContent: result,
72
+ };
73
+ });
53
74
  }