Give your AI agent headless access to Coinbase. Trade crypto, manage portfolios, and check prices from the terminal or an MCP server.
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.
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:
Follow https://docs.cdp.coinbase.com/coinbase-cli/skill.md to install and configure the Coinbase CLI.
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.
# Get the current BTC pricecoinbase products get BTC-USD --jq '.price'# Preview a $10 market buy (shows fees + estimated fill price, does not execute)coinbase orders preview product_id=BTC-USD side=BUY type=market quote_size=10# Execute the trade with an idempotent order IDcoinbase orders create product_id=BTC-USD side=BUY type=market \ quote_size=10 client_order_id=$(uuidgen)# Check the ordercoinbase orders get <order_id>
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.
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).
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:
claude mcp add --scope user --transport stdio coinbase -- coinbase mcp
Other MCP clients (Cursor, Windsurf, etc.), add to your MCP config: