@keyban/cli 0.2.4 → 0.4.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
@@ -19,7 +19,7 @@ key.
19
19
 
20
20
  **This server drives a wallet Keyban provisions. It does not create one, and it
21
21
  has nothing to drive without one** — installing the package on its own gets you
22
- a server offering only `setup_instructions` and the guide tool `get_instructions`,
22
+ a server offering only `setup_instructions` and the guide tool `get_wallet_instructions`,
23
23
  which point back here. The
24
24
  threshold key is the reason: one share lives here, the other lives with us, so
25
25
  there is a Keyban side to every wallet by construction and no configuration can
@@ -31,17 +31,18 @@ So the order is:
31
31
  2. **Create an agent wallet** in the admin app, or from your assistant with the
32
32
  Keyban admin MCP (`https://mcp.keyban.io/mcp`). It provisions the wallet, its
33
33
  API key, and a one-shot invite key that authorises this client as a signer.
34
- 3. **Take the configuration the wallet's page in the admin app hands you** —
35
- either the environment block for the table below, or a ready-to-install
36
- `.mcpb` bundle with the values already in it.
37
- 4. **Then** install, with those values in the environment.
34
+ 3. **Keep the wallet's configuration on this machine**:
35
+ `keyban wallet import <the file the admin app hands you>`, or
36
+ `keyban wallet import --wallet-id <id>` after `keyban admin login`.
37
+ `keyban admin new-wallet` creates the wallet and keeps it in one go.
38
+ 4. **Then** install: the server needs no environment.
38
39
 
39
40
  An [agent skill](https://docs.keyban.io/.well-known/agent-skills/keyban-agent-wallet/SKILL.md)
40
41
  walks an AI agent through the same steps, then through operating the wallet.
41
42
 
42
43
  ## Install
43
44
 
44
- Once you have the credentials from step 3:
45
+ Once the wallet is kept, step 3:
45
46
 
46
47
  ```bash
47
48
  npx -y @keyban/cli@latest mcp
@@ -62,25 +63,24 @@ keyban wallet --help
62
63
  With Claude Code:
63
64
 
64
65
  ```bash
65
- claude mcp add agent-wallet \
66
- -e KEYBAN_API_KEY=… \
67
- -e KEYBAN_APP_ID=… \
68
- -e KEYBAN_INVITE_KEY=0x… \
69
- -e KEYBAN_WALLET_ADDRESS=0x… \
70
- -e KEYBAN_NETWORK=… \
71
- -- npx -y @keyban/cli@latest mcp
66
+ claude mcp add agent-wallet -- npx -y @keyban/cli@latest mcp
72
67
  ```
73
68
 
74
- On first boot the server runs a key generation, keeps its share in the wallet
75
- file (`KEYBAN_WALLET_PATH`, else `$XDG_CONFIG_HOME/keyban/wallet.json`), and registers itself on chain as a signer of that wallet using the
69
+ On first boot the server runs a key generation, keeps its share in the wallet's
70
+ file, and registers itself on chain as a signer of that wallet using the
76
71
  invite key. That happens once per machine; the invite key is spent by it.
77
72
 
78
73
  ## Configuration
79
74
 
80
- The five required values all come from step 2 — none of them is something you
81
- can pick yourself.
75
+ Each wallet is one file, `$XDG_CONFIG_HOME/keyban/wallets/<wallet id>.json`;
76
+ `$XDG_CONFIG_HOME/keyban/wallet.json`, `{"current": "<wallet id>"}`, names the
77
+ one the server drives, and `keyban wallet use <name|id>` changes it. The server
78
+ reads no other wallet entry from its environment than through `KEYBAN_WALLET_PATH` and `KEYBAN_CONFIG`, in the table below; the other variables there tune logging and telemetry. The one exception is `KEYBAN_BASE_URL`: when set in the environment, it also picks the API the relayed admin tools talk to (the wallet itself keeps using its own entry).
82
79
 
83
- | Variable | Required | What it is |
80
+ A wallet's file holds these entries, all from step 2 — none of them is
81
+ something you can pick yourself.
82
+
83
+ | Entry | Required | What it is |
84
84
  |---|---|---|
85
85
  | `KEYBAN_API_KEY` | yes | API key of the application the wallet belongs to. Never exposed to the model. |
86
86
  | `KEYBAN_APP_ID` | yes | Identifier of the Keyban application. |
@@ -88,11 +88,19 @@ can pick yourself.
88
88
  | `KEYBAN_WALLET_ADDRESS` | yes | Address of the account this server drives. |
89
89
  | `KEYBAN_NETWORK` | yes | Network the wallet operates on: `BaseMainnet`, `BaseSepolia`, `XdcMainnet` or `XdcApothem`. |
90
90
  | `KEYBAN_BASE_URL` | no | Backend base URL, or one of `dev`, `testing`, `staging`, `prod`, `sandbox`. Defaults to `https://api.prod.keyban.io`. |
91
- | `KEYBAN_DKG_BLOB` | no | Pre-generated signer share, base64 JSON. For runtimes whose disk does not last; it does not replace the invite key. |
92
- | `KEYBAN_WALLET_PATH` | no | The wallet file, holding these variables and the share. Defaults to `$XDG_CONFIG_HOME/keyban/wallet.json`. |
93
- | `KEYBAN_CONFIG` | no | All the variables above as one base64 JSON object, for runtimes like AgentCore where each variable is a chore to add. A variable set on its own wins. |
94
- | `MCP_LOG_FILE` | no | Path the server writes its log to. |
95
- | `MCP_LOG_LEVEL` | no | `debug`, `info`, `warn` or `error`. Defaults to `info` for `keyban mcp`, `warn` for `keyban wallet`. |
91
+ | `KEYBAN_DKG_BLOB` | no | The signer share, base64 JSON, written by the first key generation or handed by the admin. |
92
+ | `KEYBAN_WALLET_ID`, `KEYBAN_WALLET_NAME` | yes | The wallet's id, which names its file, and its label, which `keyban wallet use` takes. |
93
+
94
+ | Variable | What it is |
95
+ |---|---|
96
+ | `KEYBAN_WALLET_PATH` | The one wallet file to drive, as a cloud agent mounts it; no `current`, no `wallets/`. |
97
+ | `KEYBAN_CONFIG` | A whole wallet file as one base64 JSON value, for runtimes like AgentCore that have nothing but their environment. Without its client share (a Claude Desktop `.mcpb`), the first start writes it to the wallet's own file, by its id, and keeps the share there. |
98
+ | `MCP_LOG_FILE` | Path the server writes its log to. |
99
+ | `MCP_LOG_LEVEL` | `debug`, `info`, `warn` or `error`. Defaults to `info` for `keyban mcp`, `warn` for `keyban wallet`. |
100
+ | `KEYBAN_TELEMETRY_DISABLED` | `1`, `true`, `yes` or `on` turns [telemetry](#telemetry) off. |
101
+ | `KEYBAN_TELEMETRY_DEBUG` | `1`, `true`, `yes` or `on` prints each telemetry event on stderr instead of sending it. |
102
+ | `KEYBAN_TELEMETRY_URL` | Send telemetry to this URL instead of Keyban's. For testing a collector. |
103
+ | `DO_NOT_TRACK` | `1`, `true`, `yes` or `on` turns telemetry off, like `KEYBAN_TELEMETRY_DISABLED`. |
96
104
 
97
105
  `keyban mcp --http` serves stateless streamable-HTTP on `0.0.0.0:8000`,
98
106
  `POST /mcp`, for Amazon Bedrock AgentCore. It has no authentication of its own:
@@ -102,13 +110,16 @@ open wallet endpoint, so use it on AgentCore only.
102
110
  ## Tools
103
111
 
104
112
  Each tool is also a `keyban wallet` subcommand, its name in kebab-case
105
- (`x402_pay` → `keyban wallet x402-pay`) and its arguments as options.
113
+ (`x402_pay` → `keyban wallet x402-pay`) and its arguments as options, but
114
+ `list_my_wallets` and `use_wallet`: `keyban wallet list` and
115
+ `keyban wallet use <name|id>`.
106
116
 
107
117
  Read-only:
108
118
 
109
119
  | Tool | What it does |
110
120
  |---|---|
111
- | `get_instructions` | Read the agent wallet guide (the `keyban-agent-wallet` skill) |
121
+ | `list_my_wallets` | List the wallets kept on this machine, and which one is current |
122
+ | `get_wallet_instructions` | Read the agent wallet guide (the `keyban-agent-wallet` skill) |
112
123
  | `api_status` | Check Keyban API status |
113
124
  | `get_account_info` | Get wallet account info |
114
125
  | `balance` | Check wallet balance |
@@ -127,6 +138,7 @@ Writing:
127
138
 
128
139
  | Tool | What it does |
129
140
  |---|---|
141
+ | `use_wallet` | Drive another kept wallet: `keyban mcp` reloads its tools for it, in this server only unless `global`, which also makes it current; `keyban wallet use` always makes it current. Refused for an incomplete wallet, while a payment waits, or when `KEYBAN_WALLET_PATH` or `KEYBAN_CONFIG` names the wallet |
130
142
  | `sign_message` | Sign a message |
131
143
  | `cancel_intent` | Cancel a pending payment intent |
132
144
  | `transfer_usdc` | Transfer USDC — moves funds |
@@ -186,6 +198,72 @@ to the wallet, set it up, then delete the old signer. Deleting it removes its
186
198
  key from the wallet on chain and revokes its API key, so the leaked pair can
187
199
  no longer sign nor reach the API. The wallet address does not change.
188
200
 
201
+ ## Telemetry
202
+
203
+ The CLI sends a small number of diagnostic events to Keyban, so that we can see
204
+ where an installation fails. They carry no secret, but they are not anonymous:
205
+ each one names your installation and, when known, your wallet (see below).
206
+ Telemetry is sent only when the command talks to Keyban's production or testing
207
+ API; a custom API URL or a local stack sends nothing, unless you set
208
+ `KEYBAN_TELEMETRY_URL`. Events go to the API the command talks to: the wallet's
209
+ `KEYBAN_BASE_URL` for `keyban mcp` and `keyban wallet <tool>`; `--api`, then
210
+ the `KEYBAN_BASE_URL` environment variable, then production for
211
+ `keyban admin`, `wallet import` and `wallet use`.
212
+
213
+ **What is sent**, on every event: the CLI version, the OS, the CPU architecture,
214
+ the Node.js version, a random installation id (created on first run, kept in
215
+ `$XDG_CONFIG_HOME/keyban/telemetry.json`), and the wallet's application id and
216
+ address whenever its configuration holds them, even an incomplete one (neither
217
+ is a secret; a value that is not a well-formed id or `0x` address, or that
218
+ holds a secret, is left out). Then, per event:
219
+
220
+ | Event | When | Attributes |
221
+ |---|---|---|
222
+ | `cli.started` | `keyban mcp` starts | `transport` (`stdio` or `http`), `configured`, `config.problems` (names of the faulty entries, never their values), `funding` |
223
+ | `mcp.client_connected` | the MCP client finished its handshake | `mcp.client.name`, `mcp.client.version` (`unknown` when not a short plain name) |
224
+ | `wallet.init_succeeded` | `keyban mcp` initialised the wallet (a `keyban wallet <tool>` command never sends it) | `signer.already_registered` |
225
+ | `wallet.init_failed` | initialisation failed | `step` (`config`, `metadata`, `dkg`, `store_share`, `register_signer` or `rpc`), `error.kind`, `error.message`, `http.status` |
226
+ | `tool.failed` | an MCP tool returned an error | `tool.name`, `error.kind`, `error.message`, `http.status` (a relayed tool, such as missions or admin, sends no message: only the name, kind, status and, if any, its `policy/<code>` reason) |
227
+ | `command.failed` | a `keyban wallet …` or `keyban admin …` command failed | `command` (its name, no arguments), `error.kind`, `error.message`, `http.status` |
228
+ | `cli.fatal` | an error ended the process | `error.kind`, `error.message`, `http.status` |
229
+
230
+ `error.kind` is one of `config`, `network`, `http`, `wasm`,
231
+ `filesystem`, `policy` or `unknown`; `http.status` is present only for an HTTP
232
+ error. Successful tool calls are not sent.
233
+
234
+ **What is never sent**: your API key, invite key, key share, `KEYBAN_CONFIG` or
235
+ admin session token; tool and command arguments, amounts and recipients; the
236
+ URLs `x402_pay` and `x402_info` call (beyond the origin, scheme and host, an
237
+ error message may mention); HTTP response bodies; what an x402 seller says; the free-text message of a relayed tool.
238
+ `error.message` is the only free text, and it is cleaned before it leaves your
239
+ machine: only the first line of the message and of each cause is kept, cut
240
+ right after the HTTP status (`(403)`, `failed: 403`…); a JSON or HTML body is
241
+ cut; a seller's refusal keeps only `seller rejected the request`; values the
242
+ CLI holds as secrets become `<redacted>`; quoted values become `"<value>"`;
243
+ amounts such as `12.50 USDC` or `€5` become `<amount>`; e-mail addresses become `<email>` and UUIDs `<uuid>`; a `policy/<code>` refusal reason is kept; URLs are reduced to their
244
+ origin, query strings to `?<query>`, Keyban API paths to their first segment
245
+ (`/v1/missions/<path>`); long hexadecimal strings become `<hex>`; JSON excerpts
246
+ become `<json>`; unquoted file paths inside your home directory are shortened
247
+ to `~` (other unquoted paths are kept); and the message is capped at 300
248
+ characters.
249
+
250
+ **Inspect it**: `KEYBAN_TELEMETRY_DEBUG=1` prints every event on stderr, as it
251
+ would be sent, and sends nothing. It writes no file.
252
+
253
+ **Turn it off**: set `KEYBAN_TELEMETRY_DISABLED=1` (`true`, `yes` and `on` work too), or the
254
+ standard `DO_NOT_TRACK=1`. Either one wins over everything else, including
255
+ `KEYBAN_TELEMETRY_DEBUG`. Nothing is initialised and nothing is sent.
256
+
257
+ On the very first run, the CLI prints one line on stderr announcing the
258
+ telemetry and this switch; it never writes to stdout, which carries the MCP
259
+ protocol. If the installation id cannot be saved (read-only directory,
260
+ container), the line is printed on every run. The same event is sent at most
261
+ once per process. An unhandled crash of a long-running `keyban mcp` and
262
+ command-line usage errors (unknown option, missing argument) are not reported. A command that succeeds does not wait for telemetry. A command that
263
+ fails, or `keyban mcp` when it stops, waits at most about one second for its
264
+ events to leave, retries included. A failure to send is silent: it never breaks
265
+ a command nor changes its exit code.
266
+
189
267
  ## Documentation
190
268
 
191
269
  <https://docs.keyban.io/>
package/SKILL.md CHANGED
@@ -12,6 +12,9 @@ destination rules, and a threshold above which a human must approve. The key is
12
12
  a threshold key: one share stays on the machine that runs the agent, the other at
13
13
  Keyban, and neither side can sign alone.
14
14
 
15
+ Daily and weekly budgets exist per wallet only. The budgets shared above a wallet,
16
+ by its application or its organization, are monthly envelopes.
17
+
15
18
  ## Two MCP servers, two roles
16
19
 
17
20
  | | Keyban admin MCP | Agent wallet MCP |
@@ -21,7 +24,7 @@ Keyban, and neither side can sign alone.
21
24
  | Default server name | `keyban` | `agent-wallet` |
22
25
  | Does | organization, applications, agent wallets, destination rules, x402 catalogue, quotas, billing | balance, spending, USDC transfers, x402 payments, approval waits, missions |
23
26
  | Does not | spend, install the wallet's signer, approve payments, edit an existing wallet's spending caps | create or configure wallets, approve its own payments |
24
- | Guide | `keyban:get_instructions`, the `keyban-admin` skill | `agent-wallet:get_instructions`, this skill |
27
+ | Guide | `keyban:get_instructions`, the `keyban-admin` skill | `agent-wallet:get_wallet_instructions`, this skill |
25
28
 
26
29
  Tools are written `server:tool` with the default server names. If the user gave
27
30
  the servers other names, use theirs.
@@ -360,7 +363,9 @@ that payment.
360
363
  |---|---|---|
361
364
  | `policy/amount-exceeded` | above the per-payment cap | raise the cap on the wallet page |
362
365
  | `policy/budget-day-exceeded`, `-week-`, `-month-` | the period's budget is used | wait, or raise the budget on the wallet page |
363
- | `policy/budget-application-…-exceeded`, `policy/budget-organization-…-exceeded` | the budget shared by every wallet of the application (or of the whole organization) is used for the period, not this wallet's own | wait for the next period, or ask an owner or admin to raise it in Settings → Policies of the application or organization; never split the payment |
366
+ | `policy/budget-application-month-exceeded`, `policy/budget-organization-month-exceeded` | the monthly envelope of the application (or of the whole organization) is used up: every wallet below it spends from it together, not only this one | wait for the next month, or ask an owner or admin to raise it: the application envelope on the Budget page of the application, the organization one by an owner only; never split the payment |
367
+ | `policy/budget-application-free-share-exceeded`, `policy/budget-organization-free-share-exceeded` | this wallet has no envelope of its own and shares what the application (or the organization) keeps unallocated, the free share. Other wallets' reservations are untouchable, so it can run out while the envelope above still has room | tell the user the free share is used; do not retry or try another wallet to get round it. The user gives this wallet an envelope of its own (wallet page, Spending rules → Edit → Monthly budget) or asks for a larger one, which may need an owner to raise the organization; never split the payment |
368
+ | `policy/budget-currency-mismatch` | the wallet policy is in another currency than its organization's budget envelopes, so they cannot be compared: no payment goes through until that is fixed | do not retry; tell the user an owner or admin must put the wallet policy in the organization currency (wallet page, Spending rules → Edit) |
364
369
  | `policy/recipient-…`, `policy/domain-…` | destination not allowed at some scope | change a destination rule, through the admin MCP only if the user asks |
365
370
  | `policy/mission-required` | this wallet only pays inside a mission run, and the payment named none | pay inside a run of the mission this task belongs to: start one with `agent-wallet:start_mission_run` if none is active, or ask the user which mission it is; never start a run of an unrelated mission to get the payment through; do not retry without a run |
366
371
  | `policy/mission-run-not-found` | the run id is unknown, belongs to another wallet, or missions are not available | check the id with `agent-wallet:list_mission_runs`; do not guess another |
@@ -377,6 +382,7 @@ that payment.
377
382
  | `policy/x402-…` | the seller's x402 offer cannot be paid (unreachable, malformed, invalid recipient, wrong asset or chain, above `maxAmount`) | pick another provider |
378
383
  | `policy/prepaid-balance-insufficient` | the prepaid credit of the organization does not cover the payment; even a fraction of a cent short refuses | tell the user an admin must buy a pack in Billing → Prepaid credit; never retry or split the payment |
379
384
  | `policy/prepaid-payer-unavailable`, `policy/prepaid-suspended` | Keyban cannot pay prepaid payments for now | report it; do not retry |
385
+ | `policy/terms-not-accepted` | the organization has not accepted Keyban's terms yet; the welcome offer can't pay until then | ask the user to accept the terms in the Keyban dashboard (the welcome flow shows them), then retry; do not suggest funding the wallet for this |
380
386
 
381
387
  A destination refused with `mission` as scope is the mission's list; with
382
388
  `wallet`, `application` or `organization`, it is that rule.