CLI
The Context CLI wraps the SDK into 35+ commands with dual-mode output — human-readable tables in terminals, JSON when piped. Built for both human traders and AI agents.35+ commands
Markets, orders, portfolio, and account management
JSON output
Structured output for parsing, piping, and automation
Dual mode
Tables in TTY, JSON when piped to other tools
Gasless onboarding
Setup and deposit without ETH for gas
Install
Quick start
Existing user
If you already have credentials saved in~/.config/context/config.env, the CLI picks them up automatically:
New user
Agent workflow quickstart
For non-interactive agent and script workflows, use--output json and --save to skip prompts and persist credentials:
Setup wizard
context setup walks through account creation and onboarding. The wizard is resumable — it detects existing state and picks up where you left off.
- Resumes from config: If
~/.config/context/config.envalready exists, the wizard loads saved credentials and skips completed steps. - Checks approval status: If contracts are already approved, that step is skipped automatically.
- Balance checks with retry: Shows your ETH and USDC balances, with retry loops so you can fund your wallet mid-setup without restarting.
--saveflag: Persists the generated wallet and API key to~/.config/context/config.envwithout prompting. Useful for agents and CI environments.--output jsonsupport: Emits structured JSON at each step for agent consumption.
Shared config
The CLI and MCP server share a single credential store at:chmod 600 (owner read/write only) and stores your API key and private key. Any tool that reads this file — the CLI, the MCP server, or your own scripts — gets the same credentials without duplicating secrets.
Credential loading order
Credentials are resolved in the following priority order:- CLI flags — e.g.
--api-key,--private-key - Environment variables — e.g.
CONTEXT_API_KEY,CONTEXT_PRIVATE_KEY - Config file —
~/.config/context/config.env(chmod 600)
JSON output
Use the--output json flag or pipe to automatically get JSON:
Global options
| Flag | Env var | Description |
|---|---|---|
--api-key <key> | CONTEXT_API_KEY | API key for authentication |
--private-key <key> | CONTEXT_PRIVATE_KEY | Private key for signing orders |
--chain <chain> | CONTEXT_CHAIN | Select chain: mainnet (default) or testnet |
--rpc-url <url> | CONTEXT_RPC_URL | Custom RPC endpoint (defaults based on selected chain) |
--base-url <url> | CONTEXT_BASE_URL | Override API base URL |
--output <format> | — | Output format: table (default in TTY) or json (default when piped) |
~/.config/context/config.env).
Command reference
Full reference for all 35+ commands
Agent workflows
End-to-end scripting patterns for agents