@coinbase/coinbase-cli
Coinbase for agents — CLI and MCP server for the Coinbase platform. Authenticate once, access every API from your terminal or AI agent.
Zero runtime dependencies — just Node.js 22+.
Install
npm install -g @coinbase/coinbase-cli
Quick start
# 1. Set up your API key (get one at coinbase.com/settings/api)
coinbase env live --key-id <id> --key-secret <secret>
# 2. Make a request
coinbase products list
# 3. Explore available commands
coinbase --help
Commands
coinbase env — Manage API keys
Configure API keys once; all subsequent commands authenticate automatically.
coinbase env # list environments
coinbase env live --key-id <id> --key-secret <secret> # configure inline
coinbase env live --remove # remove an environment
Multiple API keys — prefix live to inherit its URL with a different key:
coinbase env live-team-a --key-id <id> --key-secret <secret> # inherits live URL
coinbase env live # switch back to live
coinbase products list -e live-team-a # one-off override
Custom environment names that don't start with live require --url:
coinbase env custom --key-id <id> --key-secret <secret> --url https://api.coinbase.com
coinbase <resource> <action> — API operations
Commands are generated from the API spec. Run coinbase --help to see available resources and actions.
coinbase products list
coinbase products get product_id=BTC-USD
coinbase orders list
coinbase orders create product_id=BTC-USD side=BUY ...
coinbase balance
coinbase products ticker BTC-USDC \
--until "price BTC-USDC >= 65000" # block on a live stream until true, then exit 0
Use --template to see the expected request shape before writing, and --dry-run to preview without sending:
coinbase orders create --template # print request body template
coinbase orders create --dry-run # preview the assembled request
Field syntax:
| Syntax | Meaning |
|---|---|
key=value | String body field |
key:=value | Raw JSON body field |
key==value | Query parameter |
a.b.c=value | Nested body field |
@file.json | Body from file |
- | Body from stdin |
Header:value | Custom HTTP header |
Resource flags:
| Flag | Behavior |
|---|---|
--template | Print request body template as JSON |
--dry-run | Print request without sending |
--edit | Open request body in $EDITOR |
--jq <expr> | Filter JSON response (requires jq) |
--paginate | Auto-follow pagination for full results |
--watch | Render a live terminal surface fed by a WebSocket stream |
--until <predicate> | Block on a live stream until the predicate is true, then exit |
--until-timeout <seconds> | Cap how long --until waits before giving up |
-e <env> | Use a specific environment |
Streaming (--watch / --until)
Read commands like products ticker, products book, and orders list can subscribe to a live WebSocket feed instead of making a one-shot request.
--watch renders a live terminal surface. --until blocks until a predicate becomes true, prints the matching event as JSON, and exits — composable with &&:
# Live ticker surface
coinbase products ticker BTC-USDC ETH-USDC --watch
# Block until BTC crosses 65k, then place an order
coinbase products ticker BTC-USDC --until "price BTC-USDC >= 65000" --until-timeout 3600 \
&& coinbase orders create product_id=BTC-USDC side=SELL ...
# Wait for an order to fill
coinbase orders list --until "status == FILLED"
Exit codes: 0 predicate matched, 124 timed out, 2 permanent stream failure.
coinbase history — Request history
View and manage a log of recent API requests made through the CLI.
coinbase history # show recent requests
coinbase history clear # clear request history
coinbase skills — Workflow skills
Manage reusable workflow skills (prompt templates) that extend the MCP server.
coinbase skills list # list available skills
coinbase skills add # install/update all bundled skills
coinbase skills add --dir <path> # install to a specific directory
coinbase skills remove # remove all installed skills
Claude Code / MCP
coinbase mcp starts an MCP server that gives AI agents typed tool access to every Coinbase API endpoint. Tools are generated from the spec — new endpoints appear automatically when the CLI updates.
In addition to API tools, the MCP server exposes meta-tools for environment and workflow management:
| Tool | Purpose |
|---|---|
coinbase_set_env | Switch the active API environment |
coinbase_env | Show current environment and key info |
coinbase_help | Get usage help for CLI commands |
If you installed the CLI globally:
claude mcp add --scope user --transport stdio coinbase -- coinbase mcp
MCP only (no global install needed — runs via npx):
claude mcp add --scope user --transport stdio coinbase -- npx -y @coinbase/coinbase-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": {
"coinbase": { "transport": "stdio", "command": "coinbase", "args": ["mcp"] }
}
}
Auto-approve read operations in .claude/settings.json:
{
"permissions": {
"allow": [
"mcp__coinbase__coinbase_env",
"mcp__coinbase__coinbase_help",
"mcp__coinbase__coinbase_*_list",
"mcp__coinbase__coinbase_*_get"
]
}
}
Configuration
Environment variables override config file values:
| Variable | Purpose |
|---|---|
COINBASE_ENV | Active environment name |
COINBASE_KEY_ID | API key ID |
COINBASE_KEY_SECRET | API key secret |
COINBASE_URL | Base URL override |
COINBASE_NO_HISTORY | Set to 1 to disable request history |
COINBASE_CONFIG_DIR | Config directory (default: ~/.config/coinbase, %APPDATA%\coinbase on Windows) |
Keys and state are stored in config.json within the config directory.
Contributing
See CONTRIBUTING.md.
Security
See SECURITY.md.