nile) outputs structured JSON by default, making it a natural subprocess tool for AI agents. With 30+ commands covering reads, writes, and simulations, agents can drive the full protocol lifecycle through shell invocations.
Install
JSON Output
All commands output JSON by default. You can also set the format explicitly:jq for field extraction:
Command Groups
| Group | Key Commands | Description |
|---|---|---|
| pool | state, deposit, withdraw, transactions | Liquidity pool metrics and LP operations |
| position | list, get, search, open, close | Position lifecycle and queries |
| account | balance, deposit, withdraw | Margin account management |
| oracle | state, price | Spot and forward price feeds |
| protocol | mode | Operating mode (NORMAL, DEGRADED, REDUCE_ONLY, PAUSED) |
| simulate | open | Preview margin, fees, and entry strike before trading |
| stats | daily | Volume, fees, and position activity over time |
| fees | list | Fee event breakdown by category |
| token | balance, allowance, approve, mint | ERC-20 balance checks and approvals |
| config | show, set-rpc, set-subgraph, set-wallet | CLI configuration management |
Agent Workflow Example
A typical agent-driven trade flow chains CLI commands as subprocess calls:Execute the trade
Open the position. The CLI builds the transaction, delegates signing to OWS, and broadcasts.
OWS Wallet Signing
Read commands work immediately after install. Write commands (open/close positions, deposit/withdraw) require an OWS-compatible wallet for transaction signing.ows sign tx. Wallet setup (key import, passphrase configuration) happens entirely outside the Nile workflow.
Configuration
The CLI works zero-config for Sepolia. For advanced use cases, override settings persistently or per-command.Persistent Config
Stored in~/.nile/config.json:
Environment Variables
| Variable | Description |
|---|---|
NILE_RPC_URL | RPC URL override |
NILE_SUBGRAPH_URL | Subgraph URL override |
NILE_NETWORK | Target network (default: sepolia) |
NILE_WALLET | Wallet name |
NILE_FORMAT | Output format: json or table (default: json) |
NILE_FROM | Sender address override (read-only/simulate commands) |
Resolution Order
For all configurable values: CLI flag > environment variable >~/.nile/config.json > embedded default.
CLI vs MCP
Both surfaces expose the same protocol operations. Choose based on your agent’s architecture.| Aspect | CLI | MCP |
|---|---|---|
| Integration | Subprocess / shell | HTTP server |
| Signing | Built-in via OWS | Returns unsigned calldata |
| Auth | None (local binary) | None (M2 testnet) |
| Output | JSON or table | JSON tool responses |
| Best for | Local agents, automation scripts, CI pipelines | Cloud agents, multi-turn chat, hosted services |