Skip to main content
The Coinbase CLI gives you headless access to Coinbase Advanced Trade. Install once, authenticate with a CDP API key, and trade crypto with JSON output, order preview, and a built-in MCP server.

Trade from the terminal

Market and limit orders, portfolio management, and USDC/USD conversions from the command line.

AI-native

JSON output by default, an MCP server for agent tool-calling, and a bundled skill file for agent self-onboarding.

Preview before you execute

Every write operation supports --dry-run and order preview. See fees, slippage, and estimated fill price before committing.

Zero dependencies

A single ESM bundle on Node.js 22+. No 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:
Your agent will install the CLI, walk you through API key creation, and verify the connection.
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.
nvm/fnm users: Each Node version has its own global packages. If you upgrade Node, reinstall the CLI in a new terminal:
Linux only: install keyring support to keep secrets out of plaintext:

2. Create a CDP API key

  1. Go to API Keys in the CDP Portal (a project is auto-created on first sign-in)
  2. Click Create API Key and give it a name (e.g., my-trading-agent)
  3. Under API restrictions, enable Trade and Transfer (View is enabled by default)
  4. Under Advanced settings, change the key type to ECDSA
  5. Click Create & Download and save the JSON key file
The key secret is only shown at creation time. The brokerage API requires ECDSA keys. Ed25519 keys return HTTP 401.

3. Configure and verify

4. Check a price and place a trade

client_order_id makes the order idempotent. If your connection drops and you retry with the same ID, the API returns the existing order instead of creating a duplicate. Always include one.

Commands

Market data

Orders

Market order: executes immediately at the best available price.
Limit order: executes at the specified price or better.
Market buys use quote_size (the amount to spend in USD). Market sells use base_size (the amount of the asset to sell). When switching between buy and sell, explicitly clear the other field (e.g., add quote_size= to clear a stale value).

Portfolios and balances

Conversions

Info and session


Global flags

These flags work on any command:

Field syntax


MCP server

The CLI includes an MCP server that exposes every command as a typed tool. When your agent needs to check prices, preview orders, or manage portfolios, it calls the corresponding tool. The CLI handles auth, request formatting, and JSON parsing. Claude Code:
Other MCP clients (Cursor, Windsurf, etc.), add to your MCP config:
Without a global install, use npx:
The MCP server runs on stdio (no network ports opened) and uses the same credentials configured with coinbase env.

Troubleshooting