Skip to main content

CLI Reference

The legend-cli binary is a Rust-based tool for managing Legend accounts, signing transactions, and running a local MCP server. It handles P256 key management, OAuth login, and direct API access.

Installation

On macOS, the Homebrew install is recommended — it includes a code-signed .app bundle that enables iCloud Keychain sync for your signing keys.

Authentication

Opens your browser for Google SSO. On success, saves a JWT (valid for 30 days) to your profile at ~/.legend/prod/profiles/default.json. No manual key management needed.

Query Key

Or pass it per-command:
Or set the environment variable:
Auth resolution order: --key flag > LEGEND_QUERY_KEY env > profile file.

Global Flags

Commands

login

Authenticate via Google SSO and save the token to your profile.

whoami

Show current authentication info.

accounts

accounts list

List all sub-accounts.

accounts get <account_id>

Get details of a specific sub-account.

accounts create

Create a new sub-account.
With --keygen, the CLI:
  1. Generates a P256 key in your Mac’s Keychain (or on disk with --use-file-key)
  2. Sends the public key to Legend to create a Turnkey-backed sub-account
  3. Saves account details and key reference to your profile

plan

Create execution plans. Add --execute to automatically sign and execute in one step.
Available plan types: earn, swap, withdraw, transfer, borrow, repay.

plan execute

Execute a previously created plan with a signature.

sign

Sign an EIP-712 digest using the profile’s P256 key via Turnkey.

folio

View an account’s portfolio.

activities

View transaction history.

networks

List supported networks.

assets

List supported assets.

keygen

Generate a P256 keypair without creating an account.

keys

Manage local signing keys. Lists keys from all sources (iCloud Keychain and file).

keys list

List all keys for the current environment.

keys create <name>

Create a new key in the iCloud Keychain.

keys sign <name> <digest>

Sign a hex digest with a local key (no Turnkey round-trip).

keys delete <name>

Delete a key from the Keychain.

config set

Set a configuration value.

mcp serve

Run a local MCP server via stdio. See MCP Setup for details.

Profile Storage

Profiles are stored at ~/.legend/prod/profiles/<name>.json and contain:
  • Authentication token (query key or JWT)
  • P256 key reference (Keychain label or file path)
  • Associated account and Turnkey sub-org IDs

Key Storage

On macOS, P256 keys are stored in the iCloud-synced Data Protection Keychain by default. This means your signing keys are available on all Apple devices signed into the same iCloud account. File-based keys (when using --use-file-key) are stored at ~/.legend/prod/keys/<name>.key with chmod 600. These are local-only and do not sync. Use legend-cli keys list to see all keys available on the current machine.

Output Modes

  • TTY (human): Formatted tables
  • Piped / --json: Raw JSON (default when stdout is not a terminal)
  • --quiet: Just the primary identifier (account_id, plan_id, signature)
JSON-by-default-when-piped means agents can pipe output to jq without extra flags: