@coinbase/cdp-cli is a CLI and MCP server for the CDP API. It handles authentication, provides inline documentation for every endpoint, and exposes the full API surface as typed tools for AI agents.
Auth-transparent
Configure credentials once per environment. The CLI handles JWT signing for every request.
AI-native
Doubles as an MCP server with bundled agent skills. New API features become available the moment the CLI updates.
Inline schema discovery
Every command has built-in help with fields, types, and examples.
Zero dependencies
A single ESM bundle on Node.js 22+. Zero runtime dependencies.
Get started
The fastest way to get started is to point your AI agent at the setup instructions. Copy this into Claude Code, Cursor, Codex, or any coding agent:The skill file is a machine-readable guide that teaches agents how to install, authenticate, and use the CLI. It covers every command and common workflows.
Manual install
If you prefer to set things up yourself:1. Install the CLI
Node.js 22 or later is required.
2. Create a CDP API key
- Go to API Keys in the CDP Portal. Sign in (a project is auto-created on first sign-in).
- Click Create API Key → download the JSON key file. The key secret is only shown at creation time.
3. Configure the environment
{"accounts":[]}. This is expected.
4. Add a wallet secret
The wallet secret is a separate credential required for any operation that touches private keys (creating accounts, signing, sending). Generate one in the Non-custodial Wallet section of the Portal. Look for Generate Wallet Secret, then download the file.5. Create an account and send a transaction
transactionHash appears in the response. Your first on-chain transaction is complete.
What’s available
Runcdp to see the current resources and commands.
EVM Accounts and Solana Accounts: create accounts, sign messages and transactions, send using the encode-sign-send pipeline, manage smart accounts (ERC-4337), and execute token swaps.
Onchain Data: token balances, SQL queries against indexed chain data, and webhook subscriptions for on-chain event monitoring.
Policy Engine: accept/reject rules by value, address, or network, attachable to any account.
End User Accounts, Onramp, and x402: self-custodial wallets for end users, fiat-to-crypto onramp via Coinbase, and payments over the x402 protocol.
Client-side utilities: transaction encoding and decoding, ABI encoding, and key encryption. These run locally with no network calls.
Already using the CDP SDK?
The CLI complements the SDK for workflows where a command is faster than writing code:- Ad-hoc operations: create an account, check a balance, or fund a testnet wallet without opening an editor
- Debugging: decode a raw transaction with
cdp util tx-decode, inspect request and response headers withcdp api -v - Exploration: browse every endpoint with
cdp api, preview request shapes with--template, iterate with--edit - AI agents: the MCP server exposes every CDP operation as a typed tool
cdp evm --help to see all actions, or cdp evm accounts create --help to see fields and examples for a specific action.
Commands
Every resource action (cdp <resource> <action>) follows the same workflow.
Discover
Compose
Preview
Send and filter
Reuse
The CLI saves the last successful request body per environment and action. On the next run, omit unchanged fields:cdp history:
Global flags
These flags work on any command:| Flag | What it does | When to use |
|---|---|---|
--help | Show fields, types, response shape, and examples | Before your first call to any command |
--template | Print the expected request body without sending | Discover field names and shapes |
--dry-run | Assemble the full request and print it without sending | Before any write operation to verify what will be sent |
--jq <expr> | Filter the JSON response with a jq expression | Extract specific fields: --jq '.address', --jq '.accounts[].currency' |
--edit | Open the request body in $EDITOR | Complex requests or iterative editing |
--paginate | Auto-follow nextPageToken | Retrieve all results for list operations |
-e <env> | Override the active environment | Switch between configured environments |
Field syntax
| Syntax | Meaning | Example |
|---|---|---|
key=value | String body field | name=my-wallet |
key:=value | Raw JSON (arrays, numbers, booleans) | 'owners:=["0x..."]' |
key==value | Query parameter | product_type==SPOT |
a.b.c=value | Nested body field | config.network=base-sepolia |
@file.json | Load body from a JSON file | @body.json |
- | Body from stdin | echo '{"name":"w"}' | cdp evm accounts create - |
Header:value | Custom HTTP header | X-Custom-Header:value |
How it works
Auth and environments
The CLI uses two credentials, each serving a different purpose:| Credential | What it does | Where to get it |
|---|---|---|
| API key (key ID + secret) | Authenticates all requests to the CDP API | Portal → API Keys |
| Wallet secret | Authorizes account operations: creating accounts, signing, and sending transactions | Portal → Non-custodial Wallet → Security |
Environments
An environment is a named credential set. The built-inlive environment has the CDP API URL pre-configured. Only keys need to be supplied.
live with any name to create additional environments that inherit live’s URL:
live require --url:
Headless / environment variable configuration
As an alternative tocdp env, the CLI can be configured entirely through environment variables. This is useful when secrets are managed externally (Vault, AWS Secrets Manager, etc.) or in headless environments without an OS keyring:
| Variable | Purpose |
|---|---|
CDP_ENV | Active environment name |
CDP_KEY_ID | API key ID |
CDP_KEY_SECRET | API key secret |
CDP_WALLET_SECRET | Wallet secret |
CDP_URL | Base URL override |
CDP_NO_HISTORY | Set to 1 to disable request history |
CDP_CONFIG_DIR | Config directory (default: ~/.config/cdp, %APPDATA%\cdp on Windows) |
The encode-sign-send pipeline
Sending a transaction is a three-step process: encode an unsigned transaction locally, sign it with the account’s private key in the Trusted Execution Environment (TEE), and send it to the network.EVM
abi-encode to build the calldata:
Solana
Smart accounts
Smart accounts (ERC-4337) use user operations instead of the encode-sign-send pipeline:cdp api
Browse the embedded API spec or make raw authenticated requests:
Header:value for custom HTTP headers.
Client-side utilities
cdp util commands run locally. See cdp util <command> -h for full options.
| Command | What it does |
|---|---|
tx-encode | Build an unsigned EVM or Solana transaction. Auto-fetches nonce/gas/blockhash when --from is provided. Supports --value 0.001ether and --value 0.5sol unit syntax. |
tx-decode | Decode a raw transaction (hex for EVM, base64 for Solana) to inspect its contents. |
abi-encode | ABI-encode function calls ("transfer(address,uint256)" 0x... 1000) or raw value tuples. |
encrypt-key | Encrypt a private key for account import using CDP’s RSA public key. Accepts --file or stdin. |
Agent skills
Bundled skills teach AI agents complete workflows. Install them withcdp skills add.
MCP server
Thecdp mcp command starts an MCP (Model Context Protocol) server that exposes every CDP API operation as a typed tool. Any MCP-compatible agent can call these tools directly, with no manual API wiring needed.
Tools are generated dynamically from the embedded OpenAPI spec, so new endpoints appear automatically whenever the CLI updates. All tool names are prefixed with cdp_ and mirror the nested resource structure using underscores (e.g. cdp_evm_accounts_create, cdp_evm_accounts_sign_message).
In addition to API tools, bundled skills walk agents through complete workflows like account creation, the encode-sign-send pipeline, and token swaps. Install them with cdp skills add.
Setup
Claude Code
With the CLI installed globally:npx):
When using both the CLI and MCP, install globally so they share the same version and spec.
Project-scoped setup
To enable the MCP server for a single project, add it to the project’s.mcp.json:
Other MCP-compatible agents
Add the server to the agent’s MCP configuration (format varies by agent):Available tools
| Tool | Purpose |
|---|---|
cdp_env | Show active and configured environments |
cdp_set_env | Switch the active environment |
cdp_help | Usage help for a resource or action |
cdp_template | Request body template with examples |
cdp_<resource>_<action> | Execute an API operation |
Permissions
By default, Claude Code prompts before calling any MCP tool. To auto-approve read operations while requiring confirmation for writes, add the following to.claude/settings.json:
cdp_env, cdp_help, cdp_template, list, and get operations. All mutating operations (create, update, delete, sign, send) still require confirmation.
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
Must use a CDP Entity scoped API key | Using a legacy key | Create a new API key in the Portal |
Wallet authentication error | Wallet secret missing or incorrect | Re-add with cdp env live --wallet-secret-file |
forbidden | API key permissions issue | Check key permissions in the Portal |
cdp: command not found | CLI not on PATH | Run npm install -g @coinbase/cdp-cli again; on Windows, add %APPDATA%\npm to PATH |