@coinbase/cdp-cli 0.0.0 → 2.0.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Coinbase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # \@coinbase/cdp-cli
2
+
3
+ Command-line interface for the [Coinbase Developer Platform](https://docs.cdp.coinbase.com/). Authenticate once, access every API from your terminal or AI agent.
4
+
5
+ Zero runtime dependencies — just Node.js 22+.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g @coinbase/cdp-cli
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```bash
16
+ # 1. Set up your API key (get one at portal.cdp.coinbase.com)
17
+ cdp env live --key-file ./cdp-api-key.json
18
+
19
+ # 2. Make a request
20
+ cdp evm accounts list
21
+
22
+ # 3. Explore the API
23
+ cdp api
24
+ ```
25
+
26
+ ## Commands
27
+
28
+ ### `cdp env` — Manage API keys
29
+
30
+ Configure API keys once; all subsequent commands authenticate automatically.
31
+
32
+ ```bash
33
+ cdp env # list environments
34
+ cdp env live --key-file ./cdp-api-key.json # import key file from Portal
35
+ cdp env live --key-id <id> --key-secret <secret> # configure inline
36
+ cdp env live --remove # remove an environment
37
+ ```
38
+
39
+ Multiple API keys — prefix `live` to inherit its URL with a different key:
40
+
41
+ ```bash
42
+ cdp env live-team-a --key-id <id> --key-secret <secret> # inherits live URL, switches to live-team-a
43
+ cdp env live # switch back to live
44
+ cdp evm accounts list -e live-team-a # one-off override without switching
45
+ ```
46
+
47
+ #### Wallet secret
48
+
49
+ Account write operations (create, sign, send) require a wallet secret. Generate one at [portal.cdp.coinbase.com/products/server-wallet/accounts](https://portal.cdp.coinbase.com/products/server-wallet/accounts), then add it to your environment:
50
+
51
+ ```bash
52
+ cdp env live --wallet-secret <secret>
53
+ # or, load from file
54
+ cdp env live --wallet-secret-file ./cdp_wallet_secret.txt
55
+ cdp evm accounts create name=my-wallet # now works
56
+ ```
57
+
58
+ The wallet secret is stored in your OS keyring alongside the API key. Manage it independently:
59
+
60
+ ```bash
61
+ cdp env live --wallet-secret-file secret.txt # add or update
62
+ cdp env live --remove-wallet-secret # remove (keeps API key)
63
+ cdp env # shows (wallet) indicator
64
+ ```
65
+
66
+ For one-off use without persisting (e.g., testing with a key from a secrets manager):
67
+
68
+ ```bash
69
+ CDP_WALLET_SECRET=$(cat secret.txt) cdp evm accounts create name=my-wallet
70
+ ```
71
+
72
+ Custom environment names that don't start with `live` require `--url`:
73
+
74
+ ```bash
75
+ cdp env custom --key-id <id> --key-secret <secret> --url https://api.cdp.coinbase.com/platform/v2
76
+ ```
77
+
78
+ ### `cdp <resource> <action>` — API operations
79
+
80
+ Commands are generated from the CDP OpenAPI spec. Run `cdp api` to browse available endpoints.
81
+
82
+ ```bash
83
+ cdp evm accounts list
84
+ cdp evm accounts create name=my-wallet
85
+ cdp evm faucet address=0x... network=base-sepolia token=eth
86
+ cdp data evm token-balances base 0x...
87
+ ```
88
+
89
+ Use `--template` to see the expected request shape before writing, and `--dry-run` to preview without sending:
90
+
91
+ ```bash
92
+ cdp evm accounts create --template # print request body template
93
+ cdp evm accounts create --dry-run # preview the assembled request
94
+ ```
95
+
96
+ **Field syntax** (shared with `cdp api`):
97
+
98
+ | Syntax | Meaning |
99
+ |---|---|
100
+ | `key=value` | String body field |
101
+ | `key:=value` | Raw JSON body field |
102
+ | `key==value` | Query parameter |
103
+ | `a.b.c=value` | Nested body field |
104
+ | `@file.json` | Body from file |
105
+ | `-` | Body from stdin |
106
+ | `Header:value` | Custom HTTP header |
107
+
108
+ **Resource flags:**
109
+
110
+ | Flag | Behavior |
111
+ |---|---|
112
+ | `--template` | Print request body template as JSON |
113
+ | `--dry-run` | Print request without sending |
114
+ | `--edit` | Open request body in `$EDITOR` |
115
+ | `--jq <expr>` | Filter JSON response (requires [jq](https://jqlang.github.io/jq/)) |
116
+ | `--paginate` | Auto-follow `nextPageToken` for full results |
117
+ | `-e <env>` | Use a specific environment |
118
+
119
+ ### `cdp api` — Raw HTTP
120
+
121
+ Lower-level access for endpoints or methods not covered by resource commands. Auth is handled automatically.
122
+
123
+ ```bash
124
+ cdp api /evm/accounts
125
+ cdp api -X POST /evm/accounts name=my-wallet
126
+ cdp api -X POST /evm/accounts @body.json # full body from file
127
+ echo '{"name":"my-wallet"}' | cdp api -X POST /evm/accounts -
128
+ cdp api /evm/accounts --jq '.accounts[].address' # requires jq
129
+ cdp api /evm/accounts --paginate # auto-follow nextPageToken
130
+ cdp api /evm/accounts -v # show request + response headers
131
+ ```
132
+
133
+ ### `cdp api` — Browse the API
134
+
135
+ Running `cdp api` with no arguments opens an interactive browser for the embedded OpenAPI spec.
136
+
137
+ ```bash
138
+ cdp api # list all API groups
139
+ cdp api /evm # endpoints in a group
140
+ cdp api /evm/accounts --help # full detail for one endpoint
141
+ ```
142
+
143
+ ### `cdp util` — Encoding and key utilities
144
+
145
+ Helper commands for transaction encoding, ABI encoding, and key management.
146
+
147
+ ```bash
148
+ cdp util tx-encode --to 0x... --value 1000000 # encode a transaction
149
+ cdp util tx-decode 0x... # decode a raw transaction
150
+ cdp util abi-encode 'transfer(address,uint256)' 0x... 1000 # ABI-encode calldata
151
+ cdp util encrypt-key # encrypt a private key for import
152
+ ```
153
+
154
+ ### `cdp skills` — Workflow skills
155
+
156
+ Manage reusable workflow skills (prompt templates) that extend the MCP server.
157
+
158
+ ```bash
159
+ cdp skills list # list available skills
160
+ cdp skills add # install/update all bundled skills
161
+ cdp skills add --dir <path> # install to a specific directory
162
+ cdp skills remove # remove all installed skills
163
+ ```
164
+
165
+ ### `cdp history` — Request history
166
+
167
+ View and manage a log of recent API requests made through the CLI.
168
+
169
+ ```bash
170
+ cdp history # show recent requests
171
+ cdp history clear # clear request history
172
+ ```
173
+
174
+ ## Claude Code / MCP
175
+
176
+ `cdp mcp` starts an [MCP](https://modelcontextprotocol.io) server that gives Claude typed tool access to every CDP API endpoint. Tools are generated from the spec — new endpoints appear automatically when the CLI updates. Tool names mirror the nested subresource structure (e.g. `evm_accounts_create`, `evm_accounts_sign_message`).
177
+
178
+ In addition to API tools, the MCP server exposes meta-tools for environment and workflow management:
179
+
180
+ | Tool | Purpose |
181
+ |---|---|
182
+ | `cdp_set_env` | Switch the active API environment |
183
+ | `cdp_env` | Show current environment and key info |
184
+ | `cdp_help` | Get usage help for CLI commands |
185
+ | `cdp_template` | Retrieve request body templates for endpoints |
186
+
187
+ **If you installed the CLI globally:**
188
+
189
+ ```bash
190
+ claude mcp add --scope user --transport stdio cdp -- cdp mcp
191
+ ```
192
+
193
+ **MCP only** (no global install needed — runs via `npx`):
194
+
195
+ ```bash
196
+ claude mcp add --scope user --transport stdio cdp -- npx -y @coinbase/cdp-cli mcp
197
+ ```
198
+
199
+ > If you use both the CLI and MCP, install globally so they share the same version and spec.
200
+
201
+ Or add to your project's `.mcp.json`:
202
+
203
+ ```json
204
+ {
205
+ "mcpServers": {
206
+ "cdp": { "transport": "stdio", "command": "cdp", "args": ["mcp"] }
207
+ }
208
+ }
209
+ ```
210
+
211
+ **Auto-approve read operations** in `.claude/settings.json`:
212
+
213
+ ```json
214
+ {
215
+ "permissions": {
216
+ "allow": [
217
+ "mcp__cdp__cdp_env",
218
+ "mcp__cdp__cdp_help",
219
+ "mcp__cdp__cdp_template",
220
+ "mcp__cdp__cdp_*_list",
221
+ "mcp__cdp__cdp_*_get"
222
+ ]
223
+ }
224
+ }
225
+ ```
226
+
227
+ ## Configuration
228
+
229
+ Environment variables override config file values:
230
+
231
+ | Variable | Purpose |
232
+ |---|---|
233
+ | `CDP_ENV` | Active environment name |
234
+ | `CDP_KEY_ID` | API key ID |
235
+ | `CDP_KEY_SECRET` | API key secret |
236
+ | `CDP_URL` | Base URL override |
237
+ | `CDP_WALLET_SECRET` | Wallet secret (alternative to `--wallet-secret`) |
238
+ | `CDP_NO_HISTORY` | Set to `1` to disable request history |
239
+ | `CDP_CONFIG_DIR` | Config directory (default: `~/.config/cdp`, `%APPDATA%\cdp` on Windows) |
240
+
241
+ Keys and state are stored in `config.json` within the config directory.
242
+
243
+ ## Contributing
244
+
245
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
246
+
247
+ ## Security
248
+
249
+ See [SECURITY.md](SECURITY.md).
250
+
251
+ ## License
252
+
253
+ [MIT](LICENSE)