@keyban/cli 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2026 Keyban
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,162 @@
1
- # Temporary Holding Version
1
+ # @keyban/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Give an AI agent its own blockchain wallet: balances, USDC transfers and
4
+ [x402](https://x402.org) payments, under a spending policy the agent cannot
5
+ change.
6
+
7
+ The `keyban` command serves the wallet's tools two ways: `keyban mcp` as an MCP
8
+ server, and `keyban wallet <tool>` as one subcommand per tool, for scripts and
9
+ humans.
10
+
11
+ Registry name: `io.keyban.mcp/agent-wallet`.
12
+
13
+ `keyban mcp` runs locally over stdio, next to your MCP client. It holds one share
14
+ of a FROST threshold key in your OS keyring; Keyban holds the other. No single
15
+ side can move funds alone, and the model never sees either share or your API
16
+ key.
17
+
18
+ ## You need a Keyban wallet first
19
+
20
+ **This server drives a wallet Keyban provisions. It does not create one, and it
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`,
23
+ which point back here. The
24
+ threshold key is the reason: one share lives here, the other lives with us, so
25
+ there is a Keyban side to every wallet by construction and no configuration can
26
+ replace it.
27
+
28
+ So the order is:
29
+
30
+ 1. **Get a Keyban account** at <https://keyban.io>.
31
+ 2. **Create an agent wallet** in the admin app, or from your assistant with the
32
+ Keyban admin MCP (`https://mcp.keyban.io/mcp`). It provisions the wallet, its
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.
38
+
39
+ An [agent skill](https://docs.keyban.io/.well-known/agent-skills/keyban-agent-wallet/SKILL.md)
40
+ walks an AI agent through the same steps, then through operating the wallet.
41
+
42
+ ## Install
43
+
44
+ Once you have the credentials from step 3:
45
+
46
+ ```bash
47
+ npx -y @keyban/cli@latest mcp
48
+ ```
49
+
50
+ Keep the `@latest`: without a version, npx reuses the copy it cached on first
51
+ run, and a restart never picks up a new release.
52
+
53
+ Or install the command once and call the tools directly:
54
+
55
+ ```bash
56
+ npm install -g @keyban/cli
57
+ keyban wallet balance
58
+ keyban wallet x402-pay --url https://example.com/paid --max-amount 0.01
59
+ keyban wallet --help
60
+ ```
61
+
62
+ With Claude Code:
63
+
64
+ ```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
72
+ ```
73
+
74
+ On first boot the server runs a key generation, keeps its share in your OS
75
+ keyring, and registers itself on chain as a signer of that wallet using the
76
+ invite key. That happens once per machine; the invite key is spent by it.
77
+
78
+ ## Configuration
79
+
80
+ The five required values all come from step 2 — none of them is something you
81
+ can pick yourself.
82
+
83
+ | Variable | Required | What it is |
84
+ |---|---|---|
85
+ | `KEYBAN_API_KEY` | yes | API key of the application the wallet belongs to. Never exposed to the model. |
86
+ | `KEYBAN_APP_ID` | yes | Identifier of the Keyban application. |
87
+ | `KEYBAN_INVITE_KEY` | yes | One-shot ECDSA private key authorizing this client's first-boot registration as a signer. |
88
+ | `KEYBAN_WALLET_ADDRESS` | yes | Address of the account this server drives. |
89
+ | `KEYBAN_NETWORK` | yes | Network the wallet operates on: `BaseMainnet`, `BaseSepolia`, `XdcMainnet` or `XdcApothem`. |
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 with no OS keyring; it does not replace the invite key. |
92
+ | `MCP_LOG_FILE` | no | Path the server writes its log to. |
93
+ | `MCP_LOG_LEVEL` | no | `debug`, `info`, `warn` or `error`. Defaults to `info` for `keyban mcp`, `warn` for `keyban wallet`. |
94
+
95
+ `keyban mcp --http` serves stateless streamable-HTTP on `0.0.0.0:8000`,
96
+ `POST /mcp`, for Amazon Bedrock AgentCore. It has no authentication of its own:
97
+ AgentCore authenticates callers before they reach it. Anywhere else it is an
98
+ open wallet endpoint, so use it on AgentCore only.
99
+
100
+ ## Tools
101
+
102
+ Each tool is also a `keyban wallet` subcommand, its name in kebab-case
103
+ (`x402_pay` → `keyban wallet x402-pay`) and its arguments as options.
104
+
105
+ Read-only:
106
+
107
+ | Tool | What it does |
108
+ |---|---|
109
+ | `get_instructions` | Read the agent wallet guide (the `keyban-agent-wallet` skill) |
110
+ | `api_status` | Check Keyban API status |
111
+ | `get_account_info` | Get wallet account info |
112
+ | `balance` | Check wallet balance |
113
+ | `list_expense_transactions` | List wallet transactions |
114
+ | `expense_stats` | Get spending statistics |
115
+ | `wait_for_intent` | Wait for approval decisions |
116
+ | `x402_info` | Inspect the x402 price of a URL |
117
+ | `discover_x402_services` | Search the x402 service directory |
118
+
119
+ Writing:
120
+
121
+ | Tool | What it does |
122
+ |---|---|
123
+ | `sign_message` | Sign a message |
124
+ | `cancel_intent` | Cancel a pending payment intent |
125
+ | `transfer_usdc` | Transfer USDC — moves funds |
126
+ | `x402_pay` | Pay for an x402 resource — moves funds |
127
+
128
+ Every tool carries a `title` and the applicable `readOnlyHint` or
129
+ `destructiveHint`, so a client can tell the two groups apart before calling
130
+ anything.
131
+
132
+ ## Spending policy
133
+
134
+ Transfers and x402 payments are checked against the wallet's policy on the
135
+ Keyban side. A call the policy will not clear on its own does not fail
136
+ silently: it comes back naming a payment intent that needs a human decision.
137
+ `wait_for_intent` blocks until the owner approves or declines, and the agent
138
+ retries once it is approved. The policy lives with the wallet, not with this
139
+ process, so editing this server's configuration cannot widen it.
140
+
141
+ ## Trust boundary
142
+
143
+ The share and the API key are protected by your user account, nothing finer.
144
+ On Linux (Secret Service) and Windows (Credential Manager) the OS keyring
145
+ grants no per-program access: any program running as you can read them, and
146
+ can run `keyban` too. What bounds such a program is the same thing that bounds
147
+ the agent: Keyban co-signs every signature and applies the wallet's policy
148
+ first. Treat the machine account that holds the share like one that holds an
149
+ SSH key.
150
+
151
+ If you suspect the share or the API key leaked, rotate them: add a new signer
152
+ to the wallet, set it up, then delete the old signer. Deleting it removes its
153
+ key from the wallet on chain and revokes its API key, so the leaked pair can
154
+ no longer sign nor reach the API. The wallet address does not change.
155
+
156
+ ## Documentation
157
+
158
+ <https://docs.keyban.io/>
159
+
160
+ ## License
161
+
162
+ Apache-2.0. See [LICENSE](./LICENSE).
package/SKILL.md ADDED
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: keyban-agent-wallet
3
+ description: Operate a Keyban Agent Wallet, an AI agent's own USDC wallet whose spending policy is enforced server-side, through the local agent wallet MCP. Use when the user wants an agent to pay x402 APIs, transfer USDC, check its balance or spending, or when a payment waits for a human or is refused by the policy. Creating and configuring the wallet is the keyban-admin skill.
4
+ ---
5
+
6
+ # Keyban Agent Wallet
7
+
8
+ A Keyban Agent Wallet is a smart account owned by one AI agent. It holds USDC and
9
+ pays x402 APIs or addresses. Keyban checks every spend at signature time against
10
+ the policy the user set: per-payment cap, daily, weekly and monthly budgets,
11
+ destination rules, and a threshold above which a human must approve. The key is
12
+ a threshold key: one share stays on the machine that runs the agent, the other at
13
+ Keyban, and neither side can sign alone.
14
+
15
+ ## Two MCP servers, two roles
16
+
17
+ | | Keyban admin MCP | Agent wallet MCP |
18
+ |---|---|---|
19
+ | Acts as | the signed-in user (OAuth) | the agent, through one wallet |
20
+ | Runs | remote, `https://mcp.keyban.io/mcp` | local, `npx -y @keyban/cli@latest mcp` |
21
+ | Default server name | `keyban` | `agent-wallet` |
22
+ | Does | organization, applications, agent wallets, destination rules, x402 catalogue, quotas, billing | balance, spending, USDC transfers, x402 payments, approval waits |
23
+ | 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 |
25
+
26
+ Tools are written `server:tool` with the default server names. If the user gave
27
+ the servers other names, use theirs.
28
+
29
+ The policy is the user's decision. Never use the admin MCP to get around a
30
+ refusal from the agent wallet MCP.
31
+
32
+ ## Before the wallet exists
33
+
34
+ The wallet is created and configured through the Keyban admin MCP, and its MCP
35
+ configuration is installed from the dashboard. That part of the journey, from
36
+ the account to this server installed, is the `keyban-admin` skill.
37
+
38
+ 1. The user needs a Keyban account (there is a free plan at
39
+ https://www.keyban.io/en/pricing/agent-wallet/) and the admin MCP connected
40
+ to the client: https://docs.keyban.io/reference/set-up-mcp-server
41
+ 2. Then call `keyban:get_instructions` and follow it. It ends with this server
42
+ installed and `agent-wallet:get_account_info` answering.
43
+
44
+ If this server lists `setup_instructions`, it has no wallet to drive yet: call
45
+ it, and send the user to the dashboard for the configuration. Never ask for that
46
+ configuration or any of its values in the conversation: it holds the wallet's
47
+ API key and a one-shot invite key.
48
+
49
+ ## Fund the wallet — human
50
+
51
+ Not needed for a payment the Keyban welcome offer covers (see below).
52
+
53
+ USDC on the wallet's network, sent to the address from
54
+ `agent-wallet:get_account_info`. The wallet page in the dashboard also offers a
55
+ card top-up (Base mainnet only, 5 to 999 EUR per purchase) and a top-up request
56
+ to a teammate. Test USDC: https://faucet.circle.com/
57
+
58
+ ## Operate the wallet
59
+
60
+ - Read: `agent-wallet:balance` (report the fiat value first),
61
+ `agent-wallet:expense_stats`, `agent-wallet:list_expense_transactions`.
62
+ - A new organization's first payments may be covered by the Keyban welcome
63
+ offer, shown by `agent-wallet:balance` and `agent-wallet:get_account_info`.
64
+ On first use, report it with the balance, and do not say the wallet needs
65
+ funding while the offer has an amount left that covers the payment. The
66
+ offer pays a payment only when its whole price fits in what is left, so a
67
+ wallet holding 0 USDC can still pay that much; a costlier payment is paid
68
+ entirely from the wallet, never split. When the offer can no longer cover a
69
+ payment, `agent-wallet:x402_pay` pays from the wallet on its own; nothing to
70
+ do.
71
+ - Pay an x402 API:
72
+ 1. find a service with `agent-wallet:discover_x402_services`;
73
+ 2. check its price **and its parameters** with `agent-wallet:x402_info`,
74
+ using the HTTP method the service serves; for a variable price, probe
75
+ with the same method, query and body you will pay with;
76
+ 3. pay and fetch with `agent-wallet:x402_pay`, same URL, method and body.
77
+
78
+ Skip a provider that discovery marks `payable: no` or whose `x402_info`
79
+ prints `⚠ Not payable`: its offer is one this wallet cannot settle.
80
+
81
+ Replace each `{…}` segment of a URL with a real value before probing or
82
+ paying.
83
+
84
+ A service listed "via" a gateway (e.g. Orthogonal) is paid the same way: the
85
+ gateway collects the payment and calls the provider for you.
86
+ - Send USDC: `agent-wallet:transfer_usdc`, amount in USDC (`"1.5"`), not in
87
+ base units.
88
+
89
+ The policy is the user's authorization: do not ask the user to confirm a payment
90
+ the policy allows.
91
+
92
+ ## When a human must approve
93
+
94
+ A payment above the approval threshold is held, and the tool fails with an
95
+ `intentId`.
96
+
97
+ 1. Tell the user the amount, the recipient and the deadline, with the link
98
+ `https://admin.keyban.io/app/<applicationId>/inbox?intent=<intentId>`.
99
+ Approval needs the user's own session: no tool can approve.
100
+ 2. In the same turn, call `agent-wallet:wait_for_intent`, and call it again
101
+ each time it comes back still waiting, until the intent is decided or expires.
102
+ 3. Once approved, retry the same call with that `intentId`. Never start a new
103
+ payment for the same purchase: it creates a second intent.
104
+ 4. To withdraw a pending request, call `agent-wallet:cancel_intent`.
105
+
106
+ ## When the policy refuses
107
+
108
+ A refusal carries `policy/…` reasons. Report the reason in plain words and drop
109
+ that payment.
110
+
111
+ | Reason | Meaning | What the user can do |
112
+ |---|---|---|
113
+ | `policy/amount-exceeded` | above the per-payment cap | raise the cap on the wallet page |
114
+ | `policy/budget-day-exceeded`, `-week-`, `-month-` | the period's budget is used | wait, or raise the budget on the wallet page |
115
+ | `policy/recipient-…`, `policy/domain-…` | destination not allowed at some scope | change a destination rule, through the admin MCP only if the user asks |
116
+ | `policy/intent-in-flight` | an earlier transfer is still pending | wait for it, or cancel it with `agent-wallet:cancel_intent` |
117
+ | `policy/emergency-stop` | the wallet is paused | resume it on the wallet page |
118
+ | `policy/transaction-quota-reached` | the organization's monthly transaction quota (its plan) is used up — for every wallet of the organization, until the 1st of next month (UTC) | do not retry; ask an organization admin to upgrade the plan or allow billed overage in Billing → Usage |
119
+ | `policy/missing` | the wallet has no policy (403 at signing) | ask the user to open the wallet page; do not retry |
120
+ | `policy/x402-no-exact-accept` | the seller only offers an x402 payment scheme the wallet cannot settle yet (e.g. `upto`) — a current limit of the wallet, not a budget problem | do not retry; pick another provider and tell the user |
121
+ | `policy/x402-…` | the seller's x402 offer cannot be paid (unreachable, malformed, wrong asset or chain, above `maxAmount`) | pick another provider |
122
+
123
+ Never split a payment into smaller ones to stay under a cap or the approval
124
+ threshold, and never route a payment around a destination rule.
125
+
126
+ ## Troubleshooting
127
+
128
+ - The agent wallet MCP shows `setup_instructions`: it is not configured. Call
129
+ it, then go back to the admin skill's installation step.
130
+ - `KEYBAN_NETWORK` accepts `BaseMainnet`, `BaseSepolia`, `XdcMainnet` and
131
+ `XdcApothem`, case-sensitive.
132
+ - `agent-wallet:api_status` checks that the Keyban API answers.
133
+ - Running the agent wallet MCP on Amazon Bedrock AgentCore: see the package
134
+ README.
135
+ - The signer's share or API key may have leaked: any program running as the
136
+ user can read them. Rotate with the admin MCP: add a new signer, set it up,
137
+ then delete the old one; that revokes both, and the address stays.
138
+
139
+ ## Links
140
+
141
+ - Admin MCP guide: https://docs.keyban.io/.well-known/agent-skills/keyban-admin/SKILL.md
142
+ - Agent wallet overview: https://docs.keyban.io/solutions/agent-wallet/introduction
143
+ - Security model: https://docs.keyban.io/solutions/agent-wallet/security
144
+ - Connect an assistant to the admin MCP: https://docs.keyban.io/reference/set-up-mcp-server
145
+ - Admin MCP tools: https://docs.keyban.io/reference/mcp-tools
146
+ - Pricing: https://www.keyban.io/en/pricing/agent-wallet/
147
+ - Agent wallet MCP package: https://www.npmjs.com/package/@keyban/cli