@coinbase/cdp-cli

中文文档
2.0.147发布于 2026/11/10MITES Module零依赖近 30 天下载 4.6万

CLI for the Coinbase Developer Platform API

原始使用文档
文档目录15 节
  1. Install
  2. Quick start
  3. Commands
  4. cdp env — Manage API keys
  5. cdp <resource> <action> — API operations
  6. cdp api — Raw HTTP
  7. cdp api — Browse the API
  8. cdp util — Encoding and key utilities
  9. cdp skills — Workflow skills
  10. cdp history — Request history
  11. Claude Code / MCP
  12. Configuration
  13. Contributing
  14. Security
  15. License

@coinbase/cdp-cli

Command-line interface for the Coinbase Developer Platform. Authenticate once, access every API from your terminal or AI agent.

Zero runtime dependencies — just Node.js 22+.

Install

npm install -g @coinbase/cdp-cli

Quick start

# 1. Set up your API key (get one at portal.cdp.coinbase.com)
cdp env live --key-file ./cdp-api-key.json

# 2. Make a request
cdp evm accounts list

# 3. Explore the API
cdp api

Commands

cdp env — Manage API keys

Configure API keys once; all subsequent commands authenticate automatically.

cdp env                                           # list environments
cdp env live --key-file ./cdp-api-key.json        # import key file from Portal
cdp env live --key-id <id> --key-secret <secret>  # configure inline
cdp env live --remove                             # remove an environment

Multiple API keys — prefix live to inherit its URL with a different key:

cdp env live-team-a --key-id <id> --key-secret <secret>  # inherits live URL, switches to live-team-a
cdp env live                                              # switch back to live
cdp evm accounts list -e live-team-a                      # one-off override without switching

Wallet secret

Account write operations (create, sign, send) require a wallet secret. Generate one at portal.cdp.coinbase.com/products/server-wallet/accounts, then add it to your environment:

cdp env live --wallet-secret <secret>
# or, load from file
cdp env live --wallet-secret-file ./cdp_wallet_secret.txt
cdp evm accounts create name=my-wallet       # now works

The wallet secret is stored in your OS keyring alongside the API key. Manage it independently:

cdp env live --wallet-secret-file secret.txt  # add or update
cdp env live --remove-wallet-secret           # remove (keeps API key)
cdp env                                       # shows (wallet) indicator

For one-off use without persisting (e.g., testing with a key from a secrets manager):

CDP_WALLET_SECRET=$(cat secret.txt) cdp evm accounts create name=my-wallet

Custom environment names that don't start with live require --url:

cdp env custom --key-id <id> --key-secret <secret> --url https://api.cdp.coinbase.com/platform/v2

cdp <resource> <action> — API operations

Commands are generated from the CDP OpenAPI spec. Run cdp api to browse available endpoints.

cdp evm accounts list
cdp evm accounts create name=my-wallet
cdp evm faucet address=0x... network=base-sepolia token=eth
cdp data evm token-balances base 0x...

Use --template to see the expected request shape before writing, and --dry-run to preview without sending:

cdp evm accounts create --template    # print request body template
cdp evm accounts create --dry-run    # preview the assembled request

Field syntax (shared with cdp api):

SyntaxMeaning
key=valueString body field
key:=valueRaw JSON body field
key==valueQuery parameter
a.b.c=valueNested body field
@file.jsonBody from file
-Body from stdin
Header:valueCustom HTTP header

Resource flags:

FlagBehavior
--templatePrint request body template as JSON
--dry-runPrint request without sending
--editOpen request body in $EDITOR
--jq <expr>Filter JSON response (requires jq)
--paginateAuto-follow nextPageToken for full results
-e <env>Use a specific environment

cdp api — Raw HTTP

Lower-level access for endpoints or methods not covered by resource commands. Auth is handled automatically.

cdp api /evm/accounts
cdp api -X POST /evm/accounts name=my-wallet
cdp api -X POST /evm/accounts @body.json         # full body from file
echo '{"name":"my-wallet"}' | cdp api -X POST /evm/accounts -
cdp api /evm/accounts --jq '.accounts[].address'  # requires jq
cdp api /evm/accounts --paginate                   # auto-follow nextPageToken
cdp api /evm/accounts -v                           # show request + response headers

cdp api — Browse the API

Running cdp api with no arguments opens an interactive browser for the embedded OpenAPI spec.

cdp api                              # list all API groups
cdp api /evm                         # endpoints in a group
cdp api /evm/accounts --help         # full detail for one endpoint

cdp util — Encoding and key utilities

Helper commands for transaction encoding, ABI encoding, and key management.

cdp util tx-encode --to 0x... --value 1000000  # encode a transaction
cdp util tx-decode 0x...                       # decode a raw transaction
cdp util abi-encode 'transfer(address,uint256)' 0x... 1000  # ABI-encode calldata
cdp util encrypt-key                           # encrypt a private key for import

cdp skills — Workflow skills

Manage reusable workflow skills (prompt templates) that extend the MCP server.

cdp skills list                # list available skills
cdp skills add                 # install/update all bundled skills
cdp skills add --dir <path>    # install to a specific directory
cdp skills remove              # remove all installed skills

cdp history — Request history

View and manage a log of recent API requests made through the CLI.

cdp history        # show recent requests
cdp history clear  # clear request history

Claude Code / MCP

cdp mcp starts an MCP 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).

In addition to API tools, the MCP server exposes meta-tools for environment and workflow management:

ToolPurpose
cdp_set_envSwitch the active API environment
cdp_envShow current environment and key info
cdp_helpGet usage help for CLI commands
cdp_templateRetrieve request body templates for endpoints

If you installed the CLI globally:

claude mcp add --scope user --transport stdio cdp -- cdp mcp

MCP only (no global install needed — runs via npx):

claude mcp add --scope user --transport stdio cdp -- npx -y @coinbase/cdp-cli mcp

If you use both the CLI and MCP, install globally so they share the same version and spec.

Or add to your project's .mcp.json:

{
  "mcpServers": {
    "cdp": { "transport": "stdio", "command": "cdp", "args": ["mcp"] }
  }
}

Auto-approve read operations in .claude/settings.json:

{
  "permissions": {
    "allow": [
      "mcp__cdp__cdp_env",
      "mcp__cdp__cdp_help",
      "mcp__cdp__cdp_template",
      "mcp__cdp__cdp_*_list",
      "mcp__cdp__cdp_*_get"
    ]
  }
}

Configuration

Environment variables override config file values:

VariablePurpose
CDP_ENVActive environment name
CDP_KEY_IDAPI key ID
CDP_KEY_SECRETAPI key secret
CDP_URLBase URL override
CDP_WALLET_SECRETWallet secret (alternative to --wallet-secret)
CDP_NO_HISTORYSet to 1 to disable request history
CDP_CONFIG_DIRConfig directory (default: ~/.config/cdp, %APPDATA%\cdp on Windows)

Keys and state are stored in config.json within the config directory.

Contributing

See CONTRIBUTING.md.

Security

See SECURITY.md.

License

MIT

版本与发布记录

@coinbase/cdp-cli 共发布 148 个版本,首次发布于 2026/03/25;过去 12 个月发布了 148 个版本。

版本发布日期距今
2.0.147latest2026/11/10今天
2.0.1462026/11/10今天
2.0.1452026/11/073 天前
2.0.1442026/11/063 天前
2.0.1432026/11/064 天前
2.0.1422026/11/055 天前

其他发布通道:placeholder → 0.0.0。

关于 @coinbase/cdp-cli 的常见问题

@coinbase/cdp-cli 是什么?

CLI for the Coinbase Developer Platform API

如何安装 @coinbase/cdp-cli?

在项目目录运行 npm install @coinbase/cdp-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 cdp,可以用 npx cdp 直接运行。

@coinbase/cdp-cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/coinbase__cdp-cli 是否存在。

@coinbase/cdp-cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@coinbase/cdp-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@coinbase/cdp-cli 可以商用吗?

@coinbase/cdp-cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@coinbase/cdp-cli 的下载量有多少?

根据 npm 官方下载统计,@coinbase/cdp-cli 在 2026/10/11 – 2026/11/09 这 30 天内被下载 45,874 次,日均约 1,529 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@coinbase/cdp-cli 还在维护吗?

最新版本 2.0.147 发布于 2026/11/10(今天);至今共发布 148 个版本,其中过去 12 个月发布了 148 个;首次发布于 2026/03/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。