@zerodust/mcp-server 0.2.2 → 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.
package/README.md CHANGED
@@ -53,9 +53,18 @@ Add to your `.claude/settings.json`:
53
53
  | `ZERODUST_API_URL` | Custom API URL | `https://api.zerodust.xyz` |
54
54
  | `ZERODUST_API_KEY` | API key for higher rate limits | - |
55
55
  | `ZERODUST_ALLOW_EXECUTE` | Set to `true` to enable sweeping | `false` |
56
- | `ZERODUST_PRIVATE_KEY` | Signing key for the agent's wallet | - |
57
56
  | `ZERODUST_ALLOWED_DESTINATIONS` | Comma-separated destination allowlist | own address only |
58
57
 
58
+ Signing keys have their own section below — there are four ways to supply one,
59
+ and exactly one may be set at a time.
60
+
61
+ | Variable | Description |
62
+ |----------|-------------|
63
+ | `ZERODUST_SIGNER_MODULE` | Module returning a viem `LocalAccount` (Turnkey, Privy, KMS, ...) |
64
+ | `ZERODUST_KEYSTORE_FILE` | Encrypted V3 keystore, with `ZERODUST_KEYSTORE_PASSWORD_FILE` or `ZERODUST_KEYSTORE_PASSWORD` |
65
+ | `ZERODUST_PRIVATE_KEY_FILE` | File containing a hex private key |
66
+ | `ZERODUST_PRIVATE_KEY` | Hex private key inline |
67
+
59
68
  ## Available Tools
60
69
 
61
70
  Read-only by default:
@@ -68,6 +77,7 @@ Read-only by default:
68
77
  | `zerodust_get_quote` | Get a quote for sweeping a chain |
69
78
  | `zerodust_get_sweep_status` | Check status of a submitted sweep |
70
79
  | `zerodust_list_sweeps` | List past sweeps for an address |
80
+ | `zerodust_register_api_key` | Issue this agent its own API key, no human signup |
71
81
 
72
82
  Added when execution is enabled (see below):
73
83
 
@@ -77,27 +87,91 @@ Added when execution is enabled (see below):
77
87
  | `zerodust_sweep` | Sweep one chain to exactly zero |
78
88
  | `zerodust_sweep_all` | Sweep every chain with a balance to one destination |
79
89
 
90
+ ## Try it without moving funds
91
+
92
+ Every sweep tool accepts `dryRun`. It fetches a real quote, requests the real
93
+ EIP-712 typed data, and produces all three real signatures with your key, then
94
+ stops before submitting. Nothing is broadcast and no balance changes.
95
+
96
+ > "Do a dry run of sweeping my Arbitrum balance to Base"
97
+
98
+ Use this first. It exercises the entire path an actual sweep takes — key
99
+ handling, chain support, fee limits, signature construction — so anything
100
+ misconfigured surfaces while your funds are still where they were.
101
+
102
+ There is deliberately no testnet mode: the ZeroDust API currently serves no
103
+ testnet chains, so a testnet flag would only produce empty chain lists and
104
+ failing quotes. `dryRun` gives you the same confidence against production.
105
+
80
106
  ## Enabling sweeps
81
107
 
82
- Sweeping moves real funds, so it is off unless you turn it on. Set **both**:
108
+ Sweeping moves real funds, so it is off unless you turn it on. Set
109
+ `ZERODUST_ALLOW_EXECUTE=true` **and** exactly one signing key.
110
+
111
+ Whichever you choose, the key is used locally to sign an EIP-7702 authorization
112
+ and an EIP-712 sweep intent. It is never transmitted — only signatures reach the
113
+ ZeroDust API.
114
+
115
+ ### Option 1: a signer module (recommended for production)
116
+
117
+ Point ZeroDust at a module that returns a viem `LocalAccount`. This is how you
118
+ use Turnkey, Privy, AWS KMS, or any other custody service: ZeroDust never sees a
119
+ raw key, and it does not need to know which vendor you use.
120
+
121
+ ```js
122
+ // my-signer.mjs
123
+ export default async function createAccount() {
124
+ // Build a viem LocalAccount however your custody provider prefers.
125
+ // Any account that can sign EIP-712 typed data and EIP-7702
126
+ // authorizations works.
127
+ return await myProvider.toViemAccount();
128
+ }
129
+ ```
83
130
 
84
131
  ```json
85
- {
86
- "mcpServers": {
87
- "zerodust": {
88
- "command": "npx",
89
- "args": ["@zerodust/mcp-server"],
90
- "env": {
91
- "ZERODUST_ALLOW_EXECUTE": "true",
92
- "ZERODUST_PRIVATE_KEY": "0x..."
93
- }
94
- }
95
- }
132
+ "env": {
133
+ "ZERODUST_ALLOW_EXECUTE": "true",
134
+ "ZERODUST_SIGNER_MODULE": "./my-signer.mjs"
135
+ }
136
+ ```
137
+
138
+ The module is validated when it loads: if the account it returns cannot sign an
139
+ EIP-7702 authorization, the server says so immediately rather than failing part
140
+ way through a sweep.
141
+
142
+ ### Option 2: an encrypted keystore
143
+
144
+ The V3 keystore format produced by `cast wallet import` and geth. Keep the
145
+ password in a file so neither the key nor the password lives in your MCP config.
146
+
147
+ ```json
148
+ "env": {
149
+ "ZERODUST_ALLOW_EXECUTE": "true",
150
+ "ZERODUST_KEYSTORE_FILE": "./agent-keystore.json",
151
+ "ZERODUST_KEYSTORE_PASSWORD_FILE": "./agent-keystore.pass"
152
+ }
153
+ ```
154
+
155
+ ### Option 3: a key file
156
+
157
+ ```json
158
+ "env": {
159
+ "ZERODUST_ALLOW_EXECUTE": "true",
160
+ "ZERODUST_PRIVATE_KEY_FILE": "./agent.key"
96
161
  }
97
162
  ```
98
163
 
99
- The key is used locally to sign an EIP-7702 authorization and an EIP-712 sweep
100
- intent. It is never transmitted — only signatures reach the ZeroDust API.
164
+ ### Option 4: an inline key
165
+
166
+ Simplest, and the least private — the key sits in a config file you may well
167
+ commit. Fine for a throwaway wallet, not for one holding anything you care about.
168
+
169
+ ```json
170
+ "env": {
171
+ "ZERODUST_ALLOW_EXECUTE": "true",
172
+ "ZERODUST_PRIVATE_KEY": "0x..."
173
+ }
174
+ ```
101
175
 
102
176
  ### Destination allowlist
103
177
 
@@ -125,9 +199,30 @@ Once configured, you can ask Claude:
125
199
 
126
200
  With execution enabled:
127
201
 
202
+ - "Do a dry run of sweeping my Arbitrum balance to Base" (moves nothing)
128
203
  - "Sweep my Arbitrum balance to Base"
129
204
  - "Exit every chain and consolidate everything on Base"
130
205
 
206
+ ## No install: the hosted server
207
+
208
+ If you only need the read-only tools, there is nothing to install. Connect to
209
+ the hosted server by URL:
210
+
211
+ ```
212
+ https://api.zerodust.xyz/mcp
213
+ ```
214
+
215
+ It exposes the same tool names as this package. Sweeping is not available there,
216
+ because sweeping needs a key and the hosted server does not have yours.
217
+
218
+ ## Development
219
+
220
+ ```bash
221
+ npm install
222
+ npm test # unit tests
223
+ npm run build
224
+ ```
225
+
131
226
  ## License
132
227
 
133
228
  MIT
package/dist/execute.d.ts CHANGED
@@ -5,9 +5,9 @@
5
5
  * This module adds the tools that actually perform a sweep, which requires a
6
6
  * signing key and is therefore opt-in.
7
7
  *
8
- * Execution is disabled unless BOTH of these are set:
9
- * ZERODUST_PRIVATE_KEY - hex private key for the agent's own wallet
10
- * ZERODUST_ALLOW_EXECUTE - must be exactly "true"
8
+ * Execution is disabled unless BOTH of these are true:
9
+ * ZERODUST_ALLOW_EXECUTE=true - explicit acknowledgement that funds can move
10
+ * a signing key is configured - see signer.ts for the four accepted forms
11
11
  *
12
12
  * Optional:
13
13
  * ZERODUST_ALLOWED_DESTINATIONS - comma-separated address allowlist.
@@ -16,11 +16,17 @@
16
16
  * The allowlist is the main defence against prompt injection: an agent that is
17
17
  * talked into sweeping somewhere it shouldn't still cannot send funds to an
18
18
  * address the operator never approved.
19
+ *
20
+ * Every sweep tool also accepts `dryRun`, which runs the whole flow and stops
21
+ * before submission. That exists because there is no testnet backend to point
22
+ * at, so without it the only way to evaluate ZeroDust is to move real money.
19
23
  */
20
24
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
25
+ import { type SignerSource } from "./signer.js";
21
26
  /** Resolved execution configuration, or null when execution is not enabled. */
22
27
  export interface ExecuteConfig {
23
- privateKey: `0x${string}`;
28
+ /** Where the signing key comes from. Resolved lazily, on first use. */
29
+ signer: SignerSource;
24
30
  /** Lowercased allowlist. Empty means "agent's own address only". */
25
31
  allowedDestinations: string[];
26
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAqBzE,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,oEAAoE;IACpE,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,aAAa,GAAG,IAAI,CAoC5F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,MAAM,GAAG,IAAI,CAgBf;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAuJ1F"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,EAAqC,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAmBnF,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,MAAM,EAAE,YAAY,CAAC;IACrB,oEAAoE;IACpE,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,aAAa,GAAG,IAAI,CAwC5F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,MAAM,GAAG,IAAI,CAgBf;AA2CD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAiO1F"}
package/dist/execute.js CHANGED
@@ -5,9 +5,9 @@
5
5
  * This module adds the tools that actually perform a sweep, which requires a
6
6
  * signing key and is therefore opt-in.
7
7
  *
8
- * Execution is disabled unless BOTH of these are set:
9
- * ZERODUST_PRIVATE_KEY - hex private key for the agent's own wallet
10
- * ZERODUST_ALLOW_EXECUTE - must be exactly "true"
8
+ * Execution is disabled unless BOTH of these are true:
9
+ * ZERODUST_ALLOW_EXECUTE=true - explicit acknowledgement that funds can move
10
+ * a signing key is configured - see signer.ts for the four accepted forms
11
11
  *
12
12
  * Optional:
13
13
  * ZERODUST_ALLOWED_DESTINATIONS - comma-separated address allowlist.
@@ -16,10 +16,14 @@
16
16
  * The allowlist is the main defence against prompt injection: an agent that is
17
17
  * talked into sweeping somewhere it shouldn't still cannot send funds to an
18
18
  * address the operator never approved.
19
+ *
20
+ * Every sweep tool also accepts `dryRun`, which runs the whole flow and stops
21
+ * before submission. That exists because there is no testnet backend to point
22
+ * at, so without it the only way to evaluate ZeroDust is to move real money.
19
23
  */
20
24
  import { z } from "zod";
25
+ import { hasSignerEnv, resolveSignerSource } from "./signer.js";
21
26
  const ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;
22
- const PRIVATE_KEY_RE = /^0x[a-fA-F0-9]{64}$/;
23
27
  function text(body, isError = false) {
24
28
  const result = { content: [{ type: "text", text: body }] };
25
29
  if (isError)
@@ -37,21 +41,23 @@ function errorText(prefix, error) {
37
41
  * because the agent discovers it only mid-task.
38
42
  */
39
43
  export function readExecuteConfig(env = process.env) {
40
- const privateKey = env.ZERODUST_PRIVATE_KEY?.trim();
41
44
  const allowExecute = env.ZERODUST_ALLOW_EXECUTE?.trim() === "true";
42
- if (!privateKey && !allowExecute)
45
+ const signerConfigured = hasSignerEnv(env);
46
+ if (!signerConfigured && !allowExecute)
43
47
  return null;
44
48
  if (!allowExecute) {
45
- throw new Error("ZERODUST_PRIVATE_KEY is set but ZERODUST_ALLOW_EXECUTE is not \"true\". " +
49
+ throw new Error("A ZeroDust signing key is configured but ZERODUST_ALLOW_EXECUTE is not \"true\". " +
46
50
  "Sweeping moves real funds, so it must be enabled explicitly.");
47
51
  }
48
- if (!privateKey) {
49
- throw new Error("ZERODUST_ALLOW_EXECUTE is \"true\" but ZERODUST_PRIVATE_KEY is not set.");
50
- }
51
- const normalizedKey = (privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
52
- if (!PRIVATE_KEY_RE.test(normalizedKey)) {
53
- throw new Error("ZERODUST_PRIVATE_KEY must be a 32-byte hex private key.");
52
+ if (!signerConfigured) {
53
+ throw new Error("ZERODUST_ALLOW_EXECUTE is \"true\" but no signing key is configured. Set exactly one of:\n" +
54
+ " ZERODUST_SIGNER_MODULE module returning a viem LocalAccount (Turnkey, Privy, KMS, ...)\n" +
55
+ " ZERODUST_KEYSTORE_FILE encrypted V3 keystore, with ZERODUST_KEYSTORE_PASSWORD_FILE\n" +
56
+ " ZERODUST_PRIVATE_KEY_FILE file containing a hex private key\n" +
57
+ " ZERODUST_PRIVATE_KEY hex private key inline");
54
58
  }
59
+ // Throws on a partial or ambiguous signer setup.
60
+ const signer = resolveSignerSource(env);
55
61
  const allowedDestinations = (env.ZERODUST_ALLOWED_DESTINATIONS ?? "")
56
62
  .split(",")
57
63
  .map((entry) => entry.trim())
@@ -62,7 +68,7 @@ export function readExecuteConfig(env = process.env) {
62
68
  }
63
69
  }
64
70
  return {
65
- privateKey: normalizedKey,
71
+ signer,
66
72
  allowedDestinations: allowedDestinations.map((entry) => entry.toLowerCase()),
67
73
  };
68
74
  }
@@ -85,18 +91,40 @@ export function checkDestination(destination, agentAddress, allowedDestinations)
85
91
  `Permitted: ${agentAddress} (own address), ${allowedDestinations.join(", ")}.`);
86
92
  }
87
93
  /** Suffix appended to every sweep tool description so the gate is self-documenting. */
88
- const GATE_NOTE = " Requires ZERODUST_ALLOW_EXECUTE=true and ZERODUST_PRIVATE_KEY; without them this tool returns an error and moves no funds.";
94
+ const GATE_NOTE = " Requires ZERODUST_ALLOW_EXECUTE=true plus a signing key; without them this tool returns an " +
95
+ "error and moves no funds. Pass dryRun=true to rehearse the whole flow without moving anything.";
89
96
  const DISABLED_MESSAGE = [
90
97
  "Sweep execution is disabled on this ZeroDust MCP server, so nothing was moved.",
91
98
  "",
92
- "To enable it, restart the server with both:",
93
- " ZERODUST_ALLOW_EXECUTE=true",
94
- " ZERODUST_PRIVATE_KEY=0x... (the agent's own wallet)",
99
+ "To enable it, restart the server with ZERODUST_ALLOW_EXECUTE=true and exactly",
100
+ "one signing key:",
101
+ "",
102
+ " ZERODUST_SIGNER_MODULE=./my-signer.js",
103
+ " A module whose default export returns a viem LocalAccount. This is how",
104
+ " you use Turnkey, Privy, AWS KMS or any other custody service without",
105
+ " putting a raw key anywhere.",
106
+ "",
107
+ " ZERODUST_KEYSTORE_FILE=./agent-keystore.json",
108
+ " ZERODUST_KEYSTORE_PASSWORD_FILE=./agent-keystore.pass",
109
+ " An encrypted V3 keystore, as produced by `cast wallet import` or geth.",
110
+ "",
111
+ " ZERODUST_PRIVATE_KEY_FILE=./agent.key",
112
+ " A file containing a hex private key, so the key stays out of configs.",
113
+ "",
114
+ " ZERODUST_PRIVATE_KEY=0x...",
115
+ " A hex key inline. Simplest, and the least private of the four.",
95
116
  "",
96
117
  "Optionally set ZERODUST_ALLOWED_DESTINATIONS to permit sweeping to addresses",
97
118
  "other than the agent's own. The read-only tools (balances, quotes, status)",
98
119
  "work without any of this.",
99
120
  ].join("\n");
121
+ /** Shared shape of the dryRun parameter, so both sweep tools describe it identically. */
122
+ const dryRunSchema = z
123
+ .boolean()
124
+ .optional()
125
+ .describe("Rehearse without moving funds (default false). Fetches a real quote and produces " +
126
+ "the real signatures, then stops before submitting. Use this to prove the setup " +
127
+ "works before sweeping a real balance.");
100
128
  /**
101
129
  * Registers the sweep-execution tools on an MCP server.
102
130
  *
@@ -108,19 +136,38 @@ const DISABLED_MESSAGE = [
108
136
  * advertising the tool grants no capability.
109
137
  */
110
138
  export function registerExecuteTools(server, config) {
111
- // The agent is constructed lazily so a bad key surfaces on first use with a
112
- // clear message, rather than crashing the whole server at startup.
139
+ // The agent is constructed lazily so a bad key or an unreachable remote
140
+ // signer surfaces on first use with a clear message, rather than crashing the
141
+ // whole server at startup.
113
142
  let agentPromise = null;
114
143
  async function getAgent(enabled) {
115
144
  if (!agentPromise) {
116
- agentPromise = import("@zerodust/sdk").then(({ createAgentFromPrivateKey }) => createAgentFromPrivateKey(enabled.privateKey, { environment: "mainnet" }));
145
+ agentPromise = (async () => {
146
+ const [{ ZeroDustAgent }, account] = await Promise.all([
147
+ import("@zerodust/sdk"),
148
+ enabled.signer.load(),
149
+ ]);
150
+ return new ZeroDustAgent({ account, environment: "mainnet" });
151
+ })();
152
+ // A failed load must not be cached, or a transient signer outage would
153
+ // wedge the server until restart.
154
+ agentPromise.catch(() => {
155
+ agentPromise = null;
156
+ });
117
157
  }
118
158
  return agentPromise;
119
159
  }
120
160
  const disabled = () => text(DISABLED_MESSAGE, true);
121
161
  server.registerTool("zerodust_get_agent_address", {
122
- description: "Get the wallet address this ZeroDust MCP server signs with, plus which sweep destinations are permitted. Use before sweeping to confirm which wallet will be swept." +
162
+ description: "Show which wallet this ZeroDust server signs with, where its key comes from, and " +
163
+ "which destinations it is allowed to sweep to. Call this before any sweep to confirm " +
164
+ "the right wallet is about to be emptied." +
123
165
  GATE_NOTE,
166
+ annotations: {
167
+ title: "Show the signing wallet",
168
+ readOnlyHint: true,
169
+ openWorldHint: false,
170
+ },
124
171
  inputSchema: {},
125
172
  }, async () => {
126
173
  if (!config)
@@ -132,6 +179,7 @@ export function registerExecuteTools(server, config) {
132
179
  : `own address, ${config.allowedDestinations.join(", ")}`;
133
180
  return text([
134
181
  `Agent address: ${agent.address}`,
182
+ `Signing key: ${config.signer.description}`,
135
183
  `Execution: enabled`,
136
184
  `Permitted destinations: ${allowed}`,
137
185
  ].join("\n"));
@@ -141,10 +189,22 @@ export function registerExecuteTools(server, config) {
141
189
  }
142
190
  });
143
191
  server.registerTool("zerodust_sweep", {
144
- description: "Sweep 100% of the native gas token from one chain, leaving exactly zero balance. Moves real funds. Call zerodust_get_quote first to show the user what they will receive." +
192
+ description: "Empty one chain completely: move 100% of the native gas token off it and leave the " +
193
+ "balance at exactly zero. This is the operation an ordinary transfer cannot do, because " +
194
+ "sending the gas token requires keeping some gas token back to pay for the send. Use " +
195
+ "when the goal is to close out, wind down, decommission or fully exit a chain, or to " +
196
+ "recover a leftover or stranded balance that is too small to move normally. Moves real " +
197
+ "funds. Call zerodust_get_quote first to show the user what they will receive." +
145
198
  GATE_NOTE,
199
+ annotations: {
200
+ title: "Empty a chain to exactly zero",
201
+ readOnlyHint: false,
202
+ destructiveHint: true,
203
+ idempotentHint: false,
204
+ openWorldHint: true,
205
+ },
146
206
  inputSchema: {
147
- fromChainId: z.number().int().positive().describe("Chain to sweep from"),
207
+ fromChainId: z.number().int().positive().describe("Chain to empty"),
148
208
  toChainId: z
149
209
  .number()
150
210
  .int()
@@ -155,8 +215,9 @@ export function registerExecuteTools(server, config) {
155
215
  .regex(ADDRESS_RE)
156
216
  .optional()
157
217
  .describe("Destination address (defaults to the agent's own address)"),
218
+ dryRun: dryRunSchema,
158
219
  },
159
- }, async ({ fromChainId, toChainId, destination }) => {
220
+ }, async ({ fromChainId, toChainId, destination, dryRun }) => {
160
221
  if (!config)
161
222
  return disabled();
162
223
  try {
@@ -169,10 +230,26 @@ export function registerExecuteTools(server, config) {
169
230
  fromChainId,
170
231
  toChainId,
171
232
  destination: target,
172
- });
233
+ }, dryRun ? { dryRun: true } : {});
173
234
  if (!result.success) {
174
235
  return text(`Sweep failed: ${result.error ?? "unknown error"}`, true);
175
236
  }
237
+ if (result.dryRun) {
238
+ return text([
239
+ `Dry run only - nothing was submitted and chain ${fromChainId} is untouched.`,
240
+ `Would send to: ${target} (chain ${toChainId})`,
241
+ result.quote
242
+ ? `Current balance: ${result.quote.userBalance} wei`
243
+ : null,
244
+ result.quote
245
+ ? `Would receive: ${result.quote.estimatedReceive} wei`
246
+ : null,
247
+ `Signatures produced: intent, delegation, revoke (all valid, none broadcast)`,
248
+ `Re-run without dryRun to execute for real.`,
249
+ ]
250
+ .filter(Boolean)
251
+ .join("\n"));
252
+ }
176
253
  const lines = [
177
254
  `Sweep complete. Chain ${fromChainId} balance is now exactly zero.`,
178
255
  `Sweep ID: ${result.sweepId}`,
@@ -187,8 +264,19 @@ export function registerExecuteTools(server, config) {
187
264
  }
188
265
  });
189
266
  server.registerTool("zerodust_sweep_all", {
190
- description: "Sweep every chain that holds a sweepable balance, consolidating to one destination chain. Moves real funds across multiple chains. Call zerodust_get_balances first to show the user what will be swept." +
267
+ description: "Empty every chain that still holds a native gas balance, consolidating all of it onto " +
268
+ "one destination chain and leaving each source at exactly zero. Use when the goal is to " +
269
+ "clean up a wallet across chains, collect scattered leftover gas, or retire a wallet " +
270
+ "entirely. Moves real funds across multiple chains. Call zerodust_get_balances first to " +
271
+ "show the user what will be swept." +
191
272
  GATE_NOTE,
273
+ annotations: {
274
+ title: "Empty every chain with a balance",
275
+ readOnlyHint: false,
276
+ destructiveHint: true,
277
+ idempotentHint: false,
278
+ openWorldHint: true,
279
+ },
192
280
  inputSchema: {
193
281
  toChainId: z
194
282
  .number()
@@ -200,8 +288,9 @@ export function registerExecuteTools(server, config) {
200
288
  .regex(ADDRESS_RE)
201
289
  .optional()
202
290
  .describe("Destination address (defaults to the agent's own address)"),
291
+ dryRun: dryRunSchema,
203
292
  },
204
- }, async ({ toChainId, destination }) => {
293
+ }, async ({ toChainId, destination, dryRun }) => {
205
294
  if (!config)
206
295
  return disabled();
207
296
  try {
@@ -213,16 +302,23 @@ export function registerExecuteTools(server, config) {
213
302
  const result = await agent.sweepAll({
214
303
  toChainId,
215
304
  destination: target,
216
- });
305
+ }, dryRun ? { dryRun: true } : {});
217
306
  const summary = result.results
218
- .map((sweep) => sweep.success
219
- ? ` chain ${sweep.fromChainId}: swept${sweep.txHash ? ` (${sweep.txHash})` : ""}`
220
- : ` chain ${sweep.fromChainId}: failed - ${sweep.error ?? "unknown error"}`)
307
+ .map((sweep) => {
308
+ if (!sweep.success) {
309
+ return ` chain ${sweep.fromChainId}: failed - ${sweep.error ?? "unknown error"}`;
310
+ }
311
+ if (sweep.dryRun) {
312
+ const receive = sweep.quote ? ` (would receive ${sweep.quote.estimatedReceive} wei)` : "";
313
+ return ` chain ${sweep.fromChainId}: would sweep${receive}`;
314
+ }
315
+ return ` chain ${sweep.fromChainId}: swept${sweep.txHash ? ` (${sweep.txHash})` : ""}`;
316
+ })
221
317
  .join("\n");
222
- return text([
223
- `Swept ${result.successful}/${result.total} chains to ${target} on chain ${toChainId}.`,
224
- summary,
225
- ]
318
+ const headline = dryRun
319
+ ? `Dry run only - nothing was submitted. ${result.successful}/${result.total} chains would sweep to ${target} on chain ${toChainId}.`
320
+ : `Swept ${result.successful}/${result.total} chains to ${target} on chain ${toChainId}.`;
321
+ return text([headline, summary, dryRun ? "Re-run without dryRun to execute for real." : null]
226
322
  .filter(Boolean)
227
323
  .join("\n"));
228
324
  }
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,GAAG,qBAAqB,CAAC;AACzC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAO7C,SAAS,IAAI,CAAC,IAAY,EAAE,OAAO,GAAG,KAAK;IACzC,MAAM,MAAM,GAAe,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAChF,IAAI,OAAO;QAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACnC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,KAAc;IAC/C,OAAO,IAAI,CAAC,GAAG,MAAM,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK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;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,MAAM,QAAQ,GAAG,MAAM;gBACrB,CAAC,CAAC,yCAAyC,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,KAAK,0BAA0B,MAAM,aAAa,SAAS,GAAG;gBACrI,CAAC,CAAC,SAAS,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,KAAK,cAAc,MAAM,aAAa,SAAS,GAAG,CAAC;YAE5F,OAAO,IAAI,CACT,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,IAAI,CAAC;iBAC9E,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,IAAI,CAAC,CACd,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,SAAS,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -14,7 +14,23 @@
14
14
  * ZERODUST_API_KEY - Optional API key for higher rate limits
15
15
  *
16
16
  * Sweeping is read-only by default. To let an agent actually move funds, see
17
- * `execute.ts` for the ZERODUST_ALLOW_EXECUTE / ZERODUST_PRIVATE_KEY opt-in.
17
+ * `execute.ts` for the ZERODUST_ALLOW_EXECUTE opt-in and `signer.ts` for the
18
+ * four accepted ways to supply a signing key.
19
+ *
20
+ * Tool descriptions here lead with the problem rather than the product. An
21
+ * agent picks a tool by matching the user's words against a description, and
22
+ * "check balances" collides with every other balance tool in the client. What
23
+ * is actually distinctive is the impossibility ZeroDust removes: you cannot
24
+ * send 100% of a native gas token, because sending it costs it.
25
+ */
26
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
27
+ declare const server: McpServer;
28
+ /**
29
+ * The server instance with every read-only tool registered.
30
+ *
31
+ * Exported so tests can attach the execution tools and introspect the real tool
32
+ * surface over an in-memory transport, rather than asserting against a copy of
33
+ * the tool list that could drift from what agents actually see.
18
34
  */
19
- export {};
35
+ export { server };
20
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;GAgBG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAepE,QAAA,MAAM,MAAM,WAGV,CAAC;AAkjBH;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -14,9 +14,17 @@
14
14
  * ZERODUST_API_KEY - Optional API key for higher rate limits
15
15
  *
16
16
  * Sweeping is read-only by default. To let an agent actually move funds, see
17
- * `execute.ts` for the ZERODUST_ALLOW_EXECUTE / ZERODUST_PRIVATE_KEY opt-in.
17
+ * `execute.ts` for the ZERODUST_ALLOW_EXECUTE opt-in and `signer.ts` for the
18
+ * four accepted ways to supply a signing key.
19
+ *
20
+ * Tool descriptions here lead with the problem rather than the product. An
21
+ * agent picks a tool by matching the user's words against a description, and
22
+ * "check balances" collides with every other balance tool in the client. What
23
+ * is actually distinctive is the impossibility ZeroDust removes: you cannot
24
+ * send 100% of a native gas token, because sending it costs it.
18
25
  */
19
26
  import { createRequire } from "node:module";
27
+ import { pathToFileURL } from "node:url";
20
28
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
21
29
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
22
30
  import { z } from "zod";
@@ -53,7 +61,14 @@ async function apiRequest(path, options = {}) {
53
61
  }
54
62
  // ============ Tool: Get Supported Chains ============
55
63
  server.registerTool("zerodust_get_chains", {
56
- description: "Get a list of all blockchain chains supported by ZeroDust for sweeping native gas tokens. Returns chain IDs, names, native tokens, and contract addresses.",
64
+ description: "List the EVM chains a native gas balance can be emptied to exactly zero on. Returns " +
65
+ "chain IDs, names, and native tokens. Call this to check whether a specific chain is " +
66
+ "supported before quoting or sweeping.",
67
+ annotations: {
68
+ title: "List supported chains",
69
+ readOnlyHint: true,
70
+ openWorldHint: true,
71
+ },
57
72
  inputSchema: {},
58
73
  }, async () => {
59
74
  try {
@@ -85,7 +100,18 @@ server.registerTool("zerodust_get_chains", {
85
100
  });
86
101
  // ============ Tool: Get Balances ============
87
102
  server.registerTool("zerodust_get_balances", {
88
- description: "Check native gas token balances across all supported chains for a wallet address. Shows which chains have sweepable balances and their USD values.",
103
+ description: "Find leftover native gas token (ETH, BNB, POL, ...) stranded across every supported EVM " +
104
+ "chain for one address, and report which of it can be recovered. Normally these balances " +
105
+ "are unrecoverable: you cannot transfer 100% of a gas token, because paying for the " +
106
+ "transfer consumes the thing you are transferring, so a remainder is always left behind. " +
107
+ "This reports what is stuck and what could be moved out. Useful when a wallet has small " +
108
+ "amounts scattered over many chains, when someone cannot send their full balance, or " +
109
+ "before closing out, winding down or decommissioning a wallet.",
110
+ annotations: {
111
+ title: "Find stranded gas across chains",
112
+ readOnlyHint: true,
113
+ openWorldHint: true,
114
+ },
89
115
  inputSchema: {
90
116
  address: z
91
117
  .string()
@@ -131,7 +157,15 @@ server.registerTool("zerodust_get_balances", {
131
157
  });
132
158
  // ============ Tool: Get Quote ============
133
159
  server.registerTool("zerodust_get_quote", {
134
- description: "Get a quote for sweeping native gas tokens from one chain. Returns the estimated amount the user will receive, fee breakdown, and a quote ID for executing the sweep. Quotes expire in 60 seconds.",
160
+ description: "Price out emptying a chain's native gas balance to exactly zero: how much actually " +
161
+ "arrives, the full fee breakdown, and whether the balance is even large enough to be " +
162
+ "worth recovering. Call this before sweeping so the user sees the numbers first. Returns " +
163
+ "a quote ID; quotes expire after about 60 seconds.",
164
+ annotations: {
165
+ title: "Quote emptying a chain",
166
+ readOnlyHint: true,
167
+ openWorldHint: true,
168
+ },
135
169
  inputSchema: {
136
170
  fromChainId: z.number().int().positive().describe("Source chain ID to sweep from"),
137
171
  toChainId: z.number().int().positive().describe("Destination chain ID to receive funds"),
@@ -175,7 +209,14 @@ server.registerTool("zerodust_get_quote", {
175
209
  });
176
210
  // ============ Tool: Check Sweep Status ============
177
211
  server.registerTool("zerodust_get_sweep_status", {
178
- description: "Check the status of a previously submitted sweep. Returns the current status (pending, simulating, executing, bridging, completed, failed), transaction hash if available, and error messages if failed.",
212
+ description: "Check how a previously submitted sweep is progressing. Returns the current status " +
213
+ "(pending, simulating, executing, bridging, completed, failed), the transaction hash once " +
214
+ "there is one, and the error message if it failed.",
215
+ annotations: {
216
+ title: "Check sweep status",
217
+ readOnlyHint: true,
218
+ openWorldHint: true,
219
+ },
179
220
  inputSchema: {
180
221
  sweepId: z
181
222
  .string()
@@ -219,7 +260,13 @@ server.registerTool("zerodust_get_sweep_status", {
219
260
  });
220
261
  // ============ Tool: List Sweeps ============
221
262
  server.registerTool("zerodust_list_sweeps", {
222
- description: "List past sweeps for a wallet address. Shows sweep history with status and amounts.",
263
+ description: "List past sweeps for a wallet address, with status and amounts. Useful for confirming a " +
264
+ "chain was already emptied before trying again.",
265
+ annotations: {
266
+ title: "List past sweeps",
267
+ readOnlyHint: true,
268
+ openWorldHint: true,
269
+ },
223
270
  inputSchema: {
224
271
  address: z
225
272
  .string()
@@ -277,9 +324,91 @@ server.registerTool("zerodust_list_sweeps", {
277
324
  };
278
325
  }
279
326
  });
327
+ // ============ Tool: Register API Key ============
328
+ server.registerTool("zerodust_register_api_key", {
329
+ description: "Issue this agent its own ZeroDust API key for higher rate limits, with no human signup " +
330
+ "step. The read-only tools work without a key, so only call this when rate limits are " +
331
+ "actually being hit, or when setting up an unattended agent that will run repeatedly. " +
332
+ "The key is returned once and is not stored by this server - report it to the operator " +
333
+ "so they can set ZERODUST_API_KEY.",
334
+ annotations: {
335
+ title: "Get an API key for this agent",
336
+ readOnlyHint: false,
337
+ // Creates a credential, but destroys nothing and touches no funds.
338
+ destructiveHint: false,
339
+ idempotentHint: false,
340
+ openWorldHint: true,
341
+ },
342
+ inputSchema: {
343
+ name: z
344
+ .string()
345
+ .min(3)
346
+ .max(100)
347
+ .describe("Human-readable name for this agent, e.g. 'arbitrage-bot-prod'"),
348
+ agentId: z
349
+ .string()
350
+ .max(255)
351
+ .optional()
352
+ .describe("Stable unique identifier for this agent, if it has one"),
353
+ contactEmail: z
354
+ .string()
355
+ .email()
356
+ .optional()
357
+ .describe("Contact email for support and abuse notices"),
358
+ },
359
+ }, async ({ name, agentId, contactEmail }) => {
360
+ try {
361
+ const body = { name };
362
+ if (agentId)
363
+ body.agentId = agentId;
364
+ if (contactEmail)
365
+ body.contactEmail = contactEmail;
366
+ const data = await apiRequest("/agent/register", { method: "POST", body });
367
+ return {
368
+ content: [
369
+ {
370
+ type: "text",
371
+ text: [
372
+ "API key issued. It is shown once and is not stored by this server.",
373
+ "",
374
+ ` ZERODUST_API_KEY=${data.apiKey}`,
375
+ "",
376
+ `Key type: ${data.keyType}`,
377
+ data.rateLimits
378
+ ? `Rate limits: ${data.rateLimits.perMinute}/minute, ${data.rateLimits.daily}/day`
379
+ : null,
380
+ "",
381
+ "Give this to the operator to add to the server environment. Treat it as a",
382
+ "secret: it raises rate limits, it does not authorise moving funds.",
383
+ ]
384
+ .filter(Boolean)
385
+ .join("\n"),
386
+ },
387
+ ],
388
+ };
389
+ }
390
+ catch (error) {
391
+ return {
392
+ content: [
393
+ {
394
+ type: "text",
395
+ text: `Error registering API key: ${error instanceof Error ? error.message : String(error)}`,
396
+ },
397
+ ],
398
+ isError: true,
399
+ };
400
+ }
401
+ });
280
402
  // ============ Tool: Service Info ============
281
403
  server.registerTool("zerodust_info", {
282
- description: "Get information about ZeroDust service, including what it does, fee structure, and how to use it. Use this tool when the user asks about ZeroDust or needs to understand the service.",
404
+ description: "Explain how a native gas balance can be emptied to exactly zero, what it costs, and how " +
405
+ "to set this server up to do it. Call this when asked how ZeroDust works, why a full " +
406
+ "balance normally cannot be sent, or what sweeping will cost.",
407
+ annotations: {
408
+ title: "How ZeroDust works",
409
+ readOnlyHint: true,
410
+ openWorldHint: false,
411
+ },
283
412
  inputSchema: {},
284
413
  }, async () => {
285
414
  return {
@@ -307,25 +436,50 @@ server.registerTool("zerodust_info", {
307
436
  " - Gas costs: Paid by relayer, reimbursed from swept amount",
308
437
  " - Users always receive the quoted amount or more",
309
438
  "",
310
- "Supported chains: 25+ EVM chains including Ethereum, Arbitrum, Base,",
311
- " Optimism, Polygon, BSC, Gnosis, and more.",
439
+ "Supported chains:",
440
+ " 25 EVM chains with EIP-7702 support. Call zerodust_get_chains for the",
441
+ " authoritative live list rather than relying on any written-down count.",
312
442
  "",
313
443
  "Integration:",
314
444
  " - SDK: npm install @zerodust/sdk viem",
315
- " - API: POST /quote, POST /sweep, GET /sweep/:id/status",
316
- " - MCP: This server (stdio transport)",
445
+ " - API: GET /quote, POST /authorization, POST /sweep, GET /sweep/:id",
446
+ " - MCP: this server (stdio), or https://api.zerodust.xyz/mcp (no install)",
447
+ "",
448
+ "Trying it safely:",
449
+ " Every sweep tool accepts dryRun=true. That fetches a real quote and",
450
+ " produces the real signatures, then stops before submitting, so an",
451
+ " integration can be proven end to end without moving any funds.",
317
452
  "",
318
453
  "Sweeping from this MCP server:",
319
454
  " The zerodust_sweep and zerodust_sweep_all tools are always listed, but",
320
- " refuse to move funds unless both ZERODUST_PRIVATE_KEY and",
321
- " ZERODUST_ALLOW_EXECUTE=true are set. Funds may only be sent to the",
322
- " agent's own address unless ZERODUST_ALLOWED_DESTINATIONS lists more.",
455
+ " refuse to move funds unless ZERODUST_ALLOW_EXECUTE=true and a signing",
456
+ " key are both configured. A key may be supplied four ways:",
457
+ " ZERODUST_SIGNER_MODULE module returning a viem LocalAccount,",
458
+ " which is how Turnkey, Privy and KMS are used",
459
+ " ZERODUST_KEYSTORE_FILE encrypted V3 keystore + password file",
460
+ " ZERODUST_PRIVATE_KEY_FILE hex key in a file, not in the config",
461
+ " ZERODUST_PRIVATE_KEY hex key inline",
462
+ " Funds may only be sent to the agent's own address unless",
463
+ " ZERODUST_ALLOWED_DESTINATIONS lists more.",
464
+ "",
465
+ "Rate limits:",
466
+ " The read-only tools work with no credential at all. For higher limits an",
467
+ " agent can issue itself an API key with zerodust_register_api_key, with no",
468
+ " human signup step, then pass it as ZERODUST_API_KEY.",
323
469
  ].join("\n"),
324
470
  },
325
471
  ],
326
472
  };
327
473
  });
328
474
  // ============ Start Server ============
475
+ /**
476
+ * The server instance with every read-only tool registered.
477
+ *
478
+ * Exported so tests can attach the execution tools and introspect the real tool
479
+ * surface over an in-memory transport, rather than asserting against a copy of
480
+ * the tool list that could drift from what agents actually see.
481
+ */
482
+ export { server };
329
483
  async function main() {
330
484
  const executeConfig = readExecuteConfig();
331
485
  // Registered unconditionally: when executeConfig is null the sweep tools are
@@ -335,11 +489,19 @@ async function main() {
335
489
  const transport = new StdioServerTransport();
336
490
  await server.connect(transport);
337
491
  console.error(executeConfig
338
- ? "ZeroDust MCP Server running on stdio (sweep execution ENABLED)"
339
- : "ZeroDust MCP Server running on stdio (sweep tools listed but DISABLED; set ZERODUST_ALLOW_EXECUTE=true and ZERODUST_PRIVATE_KEY to enable)");
492
+ ? `ZeroDust MCP Server running on stdio (sweep execution ENABLED via ${executeConfig.signer.description})`
493
+ : "ZeroDust MCP Server running on stdio (sweep tools listed but DISABLED; set " +
494
+ "ZERODUST_ALLOW_EXECUTE=true plus one of ZERODUST_SIGNER_MODULE, " +
495
+ "ZERODUST_KEYSTORE_FILE, ZERODUST_PRIVATE_KEY_FILE or ZERODUST_PRIVATE_KEY to enable)");
496
+ }
497
+ // Only start the transport when run as a binary. Importing this module — which
498
+ // the tests do — must not take over stdio.
499
+ const invokedDirectly = process.argv[1] !== undefined &&
500
+ import.meta.url === pathToFileURL(process.argv[1]).href;
501
+ if (invokedDirectly) {
502
+ main().catch((error) => {
503
+ console.error("Fatal error:", error);
504
+ process.exit(1);
505
+ });
340
506
  }
341
- main().catch((error) => {
342
- console.error("Fatal error:", error);
343
- process.exit(1);
344
- });
345
507
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;AAC5E,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;AAE7C,6EAA6E;AAC7E,4EAA4E;AAC5E,uCAAuC;AACvC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAE5E,CAAC;AAEF,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,8BAA8B;AAC9B,KAAK,UAAU,UAAU,CACvB,IAAY,EACZ,UAA+C,EAAE;IAEjD,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,YAAY,EAAE,2BAA2B;KAC1C,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;IACjC,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,QAAQ,GAAG,IAAI,EAAE,EAAE;QACjD,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,CAAC,KAAK,CACX,aAAa;QACX,CAAC,CAAC,qEAAqE,aAAa,CAAC,MAAM,CAAC,WAAW,GAAG;QAC1G,CAAC,CAAC,6EAA6E;YAC3E,kEAAkE;YAClE,sFAAsF,CAC7F,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,2CAA2C;AAC3C,MAAM,eAAe,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS;IAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE1D,IAAI,eAAe,EAAE,CAAC;IACpB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @fileoverview Signer resolution for the ZeroDust MCP server
3
+ *
4
+ * Sweeping requires a key that can produce an EIP-712 signature and two
5
+ * EIP-7702 authorizations. The original server accepted exactly one form of
6
+ * that key: a raw hex private key in an environment variable, which in practice
7
+ * means pasting a hot key into an MCP client's JSON config. Operators running
8
+ * agents with real balances decline to do that, which is precisely the
9
+ * population with the most stranded gas.
10
+ *
11
+ * So there are four ways in, in descending order of precedence:
12
+ *
13
+ * ZERODUST_SIGNER_MODULE a module that returns a viem LocalAccount
14
+ * ZERODUST_KEYSTORE_FILE an encrypted V3 keystore + password
15
+ * ZERODUST_PRIVATE_KEY_FILE a file containing a hex key
16
+ * ZERODUST_PRIVATE_KEY a hex key inline (unchanged, still supported)
17
+ *
18
+ * The module hook is the important one. Rather than depending on Turnkey,
19
+ * Privy, AWS KMS and every future custody vendor, this server loads any module
20
+ * that hands back a viem `LocalAccount` — which every one of those vendors
21
+ * already knows how to produce. ZeroDust stays out of the custody business and
22
+ * the integration surface stops growing.
23
+ */
24
+ import { type LocalAccount } from "viem";
25
+ /** How the signing key was supplied, for diagnostics and the address tool. */
26
+ export type SignerKind = "module" | "keystore" | "key-file" | "key-env";
27
+ export interface SignerSource {
28
+ kind: SignerKind;
29
+ /** Human-readable origin, safe to show an agent. Never contains key material. */
30
+ description: string;
31
+ /** Resolves the account. Called at most once per process. */
32
+ load: () => Promise<LocalAccount>;
33
+ }
34
+ /** True when any signer variable is present, used to detect a partial setup. */
35
+ export declare function hasSignerEnv(env: NodeJS.ProcessEnv): boolean;
36
+ /**
37
+ * Picks the signer source from the environment.
38
+ *
39
+ * @returns the source, or null when no signer variable is set
40
+ * @throws when more than one is set, or when the chosen one is incomplete
41
+ */
42
+ export declare function resolveSignerSource(env?: NodeJS.ProcessEnv): SignerSource | null;
43
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAYH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAkC9D,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAExE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;CACnC;AAUD,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,YAAY,GAAG,IAAI,CAuB7F"}
package/dist/signer.js ADDED
@@ -0,0 +1,270 @@
1
+ /**
2
+ * @fileoverview Signer resolution for the ZeroDust MCP server
3
+ *
4
+ * Sweeping requires a key that can produce an EIP-712 signature and two
5
+ * EIP-7702 authorizations. The original server accepted exactly one form of
6
+ * that key: a raw hex private key in an environment variable, which in practice
7
+ * means pasting a hot key into an MCP client's JSON config. Operators running
8
+ * agents with real balances decline to do that, which is precisely the
9
+ * population with the most stranded gas.
10
+ *
11
+ * So there are four ways in, in descending order of precedence:
12
+ *
13
+ * ZERODUST_SIGNER_MODULE a module that returns a viem LocalAccount
14
+ * ZERODUST_KEYSTORE_FILE an encrypted V3 keystore + password
15
+ * ZERODUST_PRIVATE_KEY_FILE a file containing a hex key
16
+ * ZERODUST_PRIVATE_KEY a hex key inline (unchanged, still supported)
17
+ *
18
+ * The module hook is the important one. Rather than depending on Turnkey,
19
+ * Privy, AWS KMS and every future custody vendor, this server loads any module
20
+ * that hands back a viem `LocalAccount` — which every one of those vendors
21
+ * already knows how to produce. ZeroDust stays out of the custody business and
22
+ * the integration surface stops growing.
23
+ */
24
+ import { readFile } from "node:fs/promises";
25
+ import { createDecipheriv, pbkdf2 as pbkdf2Cb, scrypt as scryptCb, timingSafeEqual, } from "node:crypto";
26
+ import { pathToFileURL } from "node:url";
27
+ import { isAbsolute, resolve as resolvePath } from "node:path";
28
+ import { keccak256 } from "viem";
29
+ // Hand-rolled rather than promisify()'d: both functions are overloaded, and
30
+ // promisify resolves to the shortest overload, which drops the options argument
31
+ // scrypt needs for its memory limit.
32
+ function scrypt(secret, salt, keylen, options) {
33
+ return new Promise((resolve, reject) => {
34
+ scryptCb(secret, salt, keylen, options, (error, key) => error ? reject(error) : resolve(key));
35
+ });
36
+ }
37
+ function pbkdf2(secret, salt, iterations, keylen, digest) {
38
+ return new Promise((resolve, reject) => {
39
+ pbkdf2Cb(secret, salt, iterations, keylen, digest, (error, key) => error ? reject(error) : resolve(key));
40
+ });
41
+ }
42
+ const PRIVATE_KEY_RE = /^0x[a-fA-F0-9]{64}$/;
43
+ /** Env var names that supply a key, in precedence order. */
44
+ const SIGNER_ENV_VARS = [
45
+ "ZERODUST_SIGNER_MODULE",
46
+ "ZERODUST_KEYSTORE_FILE",
47
+ "ZERODUST_PRIVATE_KEY_FILE",
48
+ "ZERODUST_PRIVATE_KEY",
49
+ ];
50
+ /** True when any signer variable is present, used to detect a partial setup. */
51
+ export function hasSignerEnv(env) {
52
+ return SIGNER_ENV_VARS.some((name) => Boolean(env[name]?.trim()));
53
+ }
54
+ /**
55
+ * Picks the signer source from the environment.
56
+ *
57
+ * @returns the source, or null when no signer variable is set
58
+ * @throws when more than one is set, or when the chosen one is incomplete
59
+ */
60
+ export function resolveSignerSource(env = process.env) {
61
+ const present = SIGNER_ENV_VARS.filter((name) => Boolean(env[name]?.trim()));
62
+ if (present.length === 0)
63
+ return null;
64
+ if (present.length > 1) {
65
+ throw new Error(`Multiple signing keys configured (${present.join(", ")}). ` +
66
+ "Set exactly one so it is unambiguous which key signs.");
67
+ }
68
+ const [chosen] = present;
69
+ switch (chosen) {
70
+ case "ZERODUST_SIGNER_MODULE":
71
+ return moduleSource(env.ZERODUST_SIGNER_MODULE.trim());
72
+ case "ZERODUST_KEYSTORE_FILE":
73
+ return keystoreSource(env);
74
+ case "ZERODUST_PRIVATE_KEY_FILE":
75
+ return keyFileSource(env.ZERODUST_PRIVATE_KEY_FILE.trim());
76
+ default:
77
+ return keyEnvSource(env.ZERODUST_PRIVATE_KEY.trim());
78
+ }
79
+ }
80
+ // ============ Sources ============
81
+ /**
82
+ * Loads a caller-supplied module and uses whatever account it returns.
83
+ *
84
+ * Accepted shapes, in order: a default export that is a function, a named
85
+ * `createAccount` function, or a default export that is already an account.
86
+ * Functions may be async, which is what lets a remote signer do a round trip
87
+ * (fetch a Turnkey/Privy session, resolve a KMS key) before returning.
88
+ */
89
+ function moduleSource(specifier) {
90
+ return {
91
+ kind: "module",
92
+ description: `signer module ${specifier}`,
93
+ load: async () => {
94
+ // Relative paths resolve against cwd, not against this file, because the
95
+ // operator writes them relative to where they launch the server.
96
+ const target = specifier.startsWith(".") || isAbsolute(specifier)
97
+ ? pathToFileURL(resolvePath(process.cwd(), specifier)).href
98
+ : specifier;
99
+ let mod;
100
+ try {
101
+ mod = (await import(target));
102
+ }
103
+ catch (error) {
104
+ throw new Error(`ZERODUST_SIGNER_MODULE could not be loaded (${specifier}): ` +
105
+ `${error instanceof Error ? error.message : String(error)}`);
106
+ }
107
+ const factory = mod.default ?? mod.createAccount;
108
+ const candidate = typeof factory === "function" ? await factory() : factory;
109
+ return assertLocalAccount(candidate, specifier);
110
+ },
111
+ };
112
+ }
113
+ /**
114
+ * Decrypts a Web3 Secret Storage (V3) keystore — the format produced by
115
+ * `cast wallet import`, geth, and most key management tooling. The password can
116
+ * come from a variable or, better, from a file that never enters the MCP config.
117
+ */
118
+ function keystoreSource(env) {
119
+ const file = env.ZERODUST_KEYSTORE_FILE.trim();
120
+ const inlinePassword = env.ZERODUST_KEYSTORE_PASSWORD;
121
+ const passwordFile = env.ZERODUST_KEYSTORE_PASSWORD_FILE?.trim();
122
+ if (inlinePassword === undefined && !passwordFile) {
123
+ throw new Error("ZERODUST_KEYSTORE_FILE is set but no password was provided. " +
124
+ "Set ZERODUST_KEYSTORE_PASSWORD_FILE (preferred) or ZERODUST_KEYSTORE_PASSWORD.");
125
+ }
126
+ if (inlinePassword !== undefined && passwordFile) {
127
+ throw new Error("Both ZERODUST_KEYSTORE_PASSWORD and ZERODUST_KEYSTORE_PASSWORD_FILE are set. Choose one.");
128
+ }
129
+ return {
130
+ kind: "keystore",
131
+ description: `keystore ${file}`,
132
+ load: async () => {
133
+ const password = passwordFile
134
+ ? // Trailing newlines are near-universal in password files and are
135
+ // essentially never part of the password.
136
+ (await readFileText(passwordFile, "ZERODUST_KEYSTORE_PASSWORD_FILE")).replace(/\r?\n$/, "")
137
+ : inlinePassword;
138
+ const raw = await readFileText(file, "ZERODUST_KEYSTORE_FILE");
139
+ const privateKey = await decryptV3Keystore(raw, password);
140
+ return toAccount(privateKey);
141
+ },
142
+ };
143
+ }
144
+ /** Reads a hex private key from a file, so it never appears in a config file. */
145
+ function keyFileSource(file) {
146
+ return {
147
+ kind: "key-file",
148
+ description: `key file ${file}`,
149
+ load: async () => {
150
+ const contents = (await readFileText(file, "ZERODUST_PRIVATE_KEY_FILE")).trim();
151
+ return toAccount(normalizeKey(contents, `the contents of ${file}`));
152
+ },
153
+ };
154
+ }
155
+ function keyEnvSource(value) {
156
+ return {
157
+ kind: "key-env",
158
+ description: "ZERODUST_PRIVATE_KEY (inline)",
159
+ load: async () => toAccount(normalizeKey(value, "ZERODUST_PRIVATE_KEY")),
160
+ };
161
+ }
162
+ // ============ Helpers ============
163
+ async function readFileText(file, label) {
164
+ try {
165
+ return await readFile(file, "utf8");
166
+ }
167
+ catch (error) {
168
+ throw new Error(`${label} could not be read (${file}): ` +
169
+ `${error instanceof Error ? error.message : String(error)}`);
170
+ }
171
+ }
172
+ function normalizeKey(value, label) {
173
+ const candidate = (value.startsWith("0x") ? value : `0x${value}`);
174
+ if (!PRIVATE_KEY_RE.test(candidate)) {
175
+ throw new Error(`${label} must be a 32-byte hex private key.`);
176
+ }
177
+ return candidate;
178
+ }
179
+ async function toAccount(privateKey) {
180
+ const { privateKeyToAccount } = await import("viem/accounts");
181
+ return privateKeyToAccount(privateKey);
182
+ }
183
+ /**
184
+ * Verifies a module returned something that can actually sign a sweep.
185
+ *
186
+ * `signAuthorization` is the load-bearing one: without it the EIP-7702
187
+ * delegation cannot be produced, and a signer missing it would otherwise fail
188
+ * deep inside a sweep instead of at startup.
189
+ */
190
+ function assertLocalAccount(candidate, specifier) {
191
+ const account = candidate;
192
+ if (!account || typeof account !== "object") {
193
+ throw new Error(`ZERODUST_SIGNER_MODULE (${specifier}) did not return an account. ` +
194
+ "Export a default function returning a viem LocalAccount.");
195
+ }
196
+ const missing = ["address", "signTypedData", "signAuthorization"].filter((key) => {
197
+ const value = account[key];
198
+ return key === "address" ? typeof value !== "string" : typeof value !== "function";
199
+ });
200
+ if (missing.length > 0) {
201
+ throw new Error(`ZERODUST_SIGNER_MODULE (${specifier}) returned an object missing ${missing.join(", ")}. ` +
202
+ "ZeroDust needs a viem LocalAccount that can sign EIP-712 typed data and " +
203
+ "EIP-7702 authorizations.");
204
+ }
205
+ return account;
206
+ }
207
+ /**
208
+ * Decrypts a V3 keystore to its private key.
209
+ *
210
+ * Implemented directly on node:crypto rather than pulling in a keystore
211
+ * library, because the whole format is one KDF, one AES-CTR decryption, and one
212
+ * keccak MAC check, and this server's dependency surface is worth keeping thin.
213
+ */
214
+ async function decryptV3Keystore(raw, password) {
215
+ let parsed;
216
+ try {
217
+ parsed = JSON.parse(raw);
218
+ }
219
+ catch {
220
+ throw new Error("Keystore file is not valid JSON.");
221
+ }
222
+ // Older tooling capitalises the key.
223
+ const crypto = parsed.crypto ?? parsed.Crypto;
224
+ if (!crypto)
225
+ throw new Error("Keystore file has no \"crypto\" section.");
226
+ if (parsed.version !== 3) {
227
+ throw new Error(`Unsupported keystore version ${parsed.version}. Only V3 is supported.`);
228
+ }
229
+ if (crypto.cipher !== "aes-128-ctr") {
230
+ throw new Error(`Unsupported keystore cipher "${crypto.cipher}". Expected aes-128-ctr.`);
231
+ }
232
+ const derived = await deriveKey(crypto, password);
233
+ const ciphertext = Buffer.from(crypto.ciphertext, "hex");
234
+ // MAC covers the second half of the derived key plus the ciphertext. A
235
+ // mismatch means the password is wrong (or the file was tampered with).
236
+ const mac = keccak256(Buffer.concat([derived.subarray(16, 32), ciphertext])).slice(2);
237
+ const expected = Buffer.from(crypto.mac.replace(/^0x/, ""), "hex");
238
+ const actual = Buffer.from(mac, "hex");
239
+ if (expected.length !== actual.length || !timingSafeEqual(expected, actual)) {
240
+ throw new Error("Keystore MAC mismatch - the password is incorrect.");
241
+ }
242
+ const decipher = createDecipheriv("aes-128-ctr", derived.subarray(0, 16), Buffer.from(crypto.cipherparams.iv, "hex"));
243
+ const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
244
+ return normalizeKey(plaintext.toString("hex"), "The decrypted keystore key");
245
+ }
246
+ async function deriveKey(crypto, password) {
247
+ const params = crypto.kdfparams;
248
+ const salt = Buffer.from(String(params.salt), "hex");
249
+ const dklen = Number(params.dklen ?? 32);
250
+ const secret = Buffer.from(password, "utf8");
251
+ if (crypto.kdf === "scrypt") {
252
+ const N = Number(params.n);
253
+ const r = Number(params.r);
254
+ const p = Number(params.p);
255
+ // Node caps scrypt memory at 32MB by default, which the standard geth
256
+ // parameters (N=262144, r=8) blow straight through. Size it from the
257
+ // parameters instead of failing with an opaque error.
258
+ const maxmem = 256 * N * r;
259
+ return scrypt(secret, salt, dklen, { N, r, p, maxmem });
260
+ }
261
+ if (crypto.kdf === "pbkdf2") {
262
+ const prf = String(params.prf ?? "hmac-sha256");
263
+ if (prf !== "hmac-sha256") {
264
+ throw new Error(`Unsupported keystore PRF "${prf}". Expected hmac-sha256.`);
265
+ }
266
+ return pbkdf2(secret, salt, Number(params.c), dklen, "sha256");
267
+ }
268
+ throw new Error(`Unsupported keystore KDF "${crypto.kdf}". Expected scrypt or pbkdf2.`);
269
+ }
270
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,MAAM,IAAI,QAAQ,EAClB,MAAM,IAAI,QAAQ,EAClB,eAAe,GAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,SAAS,EAA+B,MAAM,MAAM,CAAC;AAE9D,4EAA4E;AAC5E,gFAAgF;AAChF,qCAAqC;A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MCP server that lets an AI agent sweep its own wallet to exactly zero on 25+ EVM chains, with no gas left stranded.",
6
6
  "type": "module",
@@ -18,7 +18,9 @@
18
18
  "dev": "tsc --watch",
19
19
  "start": "node dist/index.js",
20
20
  "clean": "rm -rf dist",
21
- "prepublishOnly": "npm run clean && npm run build"
21
+ "prepublishOnly": "npm run clean && npm run build",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
22
24
  },
23
25
  "keywords": [
24
26
  "zerodust",
@@ -58,12 +60,13 @@
58
60
  },
59
61
  "dependencies": {
60
62
  "@modelcontextprotocol/sdk": "^1.2.0",
61
- "@zerodust/sdk": "^0.1.0",
63
+ "@zerodust/sdk": "^0.2.0",
62
64
  "viem": "^2.21.0",
63
65
  "zod": "^3.22.0"
64
66
  },
65
67
  "devDependencies": {
66
68
  "@types/node": "^20.11.0",
67
- "typescript": "^5.3.3"
69
+ "typescript": "^5.3.3",
70
+ "vitest": "^1.6.1"
68
71
  }
69
72
  }