Kraken CLI for AI Trading Agents: A Developer Guide
How to install Kraken's official CLI, pull market data, paper trade, sign in with a restricted key and connect an AI agent through its MCP server, safely.
Kraken publishes an official command-line tool, kraken-cli, in its own krakenfx GitHub organisation. It is open source under the MIT licence, written in Rust, and built with AI agents in mind: every command can return JSON, and it ships an MCP server so tools like Claude Code or Cursor can call Kraken directly. This guide walks through the parts a developer needs to build an agent on top of it, in the order Kraken itself recommends: look at market data, practise on paper, then sign in with a limited key, and only then think about live orders. Everything below comes from the project’s README, its disclaimer, and Kraken’s API documentation.
Risk note. This article is a technical guide, not investment advice, and nothing here suggests a strategy will make money. Kraken describes the CLI as experimental software that can execute real, irreversible transactions. Software bugs and agent mistakes can lose real funds. Start on paper, and only use money you can afford to lose.
What kraken-cli includes
One install puts three binaries on your PATH:
| Binary | What it does |
|---|---|
kraken | The main CLI: market data, account queries, orders, paper trading, streaming |
kraken-mcp | A Model Context Protocol server over stdio for AI clients |
kraken-shell | An interactive shell |
According to the README, the CLI covers spot crypto (over 1,400 pairs), tokenized U.S. stocks and ETFs called xStocks (not offered in the USA), a dozen forex pairs, and more than 200 futures contracts. Product availability depends on your jurisdiction. Futures use a separate Futures API key and their own kraken futures commands.
Install and check it works
Kraken’s one-line installer detects your platform and works on Linux (x86_64 or ARM64) and on both Intel and Apple Silicon Macs. On Windows, Kraken points you to WSL.
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/krakenfx/kraken-cli/releases/latest/download/kraken-cli-installer.sh | sh
kraken status && kraken ticker BTCUSD
Releases are signed with minisign, and the README publishes the public key, so you can verify the installer before running it. If kraken is not found right after installing, open a new terminal: the binaries land in ~/.cargo/bin and the PATH change only applies to new shells. You can also build from source with Rust 1.97 or later.
Step 1: read-only market data
Public market data needs no credentials, so these commands cannot touch any account. That makes them the right first tools to give an agent.
kraken ticker BTCUSD
kraken orderbook BTCUSD --count 10
kraken ohlc BTCUSD --interval 60 -o json
Add -o json for machine-readable output. For live data there is a WebSocket stream that writes one JSON object per line:
kraken ws ticker BTC/USD ETH/USD -o json
Step 2: paper trading on live prices
Paper trading uses real Kraken prices with simulated money, and it also needs no account. You create a paper workspace with starting capital, point the CLI at it, and trade against it:
kraken workspace create sandbox --capital 10000 --mode paper -o json
export KRAKEN_WORKSPACE=sandbox
kraken paper buy BTCUSD 0.01 -o json
kraken workspace status -o json
unset KRAKEN_WORKSPACE
Two details matter for bot builders. First, while KRAKEN_WORKSPACE names a paper workspace, the normal live verbs (order buy, balance, open-orders) also hit the simulator, so a strategy written with those verbs can later move to live without code changes. Second, the spot simulator is simple: market and limit orders only, a flat fee and optional flat slippage, and no partial fills. Results on paper will not match live fills exactly. Futures have their own paper engine with more order types, leverage and liquidation simulation.
The CLI can also capture a live feed to disk and later replay that recording into a paper session, so you can test one strategy against identical data more than once.
Step 3: sign in with a least-privilege key
When you are ready to read a real account, the simplest route is OAuth sign-in:
kraken auth login --read-only --valid-for 30d
kraken auth test
kraken auth login opens Kraken’s sign-in page, you approve, and the CLI creates and stores a restricted Spot key in a config file with 0600 permissions. Without --read-only the key can trade but still has no withdrawal rights, and it expires after 90 days at most. With --read-only it can see balances, orders, trades and ledger entries but cannot trade. The login command refuses to run from a script, CI job or an agent’s shell: a person has to run it in their own terminal, and the agent then uses the stored key.
If you create a key by hand on kraken.com (needed for futures or for unattended servers), grant only what the workflow needs. Kraken’s guidance in the README:
- Monitoring only: the query permissions for funds and for open orders and trades, plus closed orders or ledger queries if you need history.
- Trading: add the create, modify, cancel and close order permissions.
- Leave withdrawals off unless a script truly needs them.
For automation, Kraken recommends setting KRAKEN_API_KEY and KRAKEN_API_SECRET as environment variables in the process that starts the agent, ideally pulled from a secrets manager. Never paste keys into an AI chat.
Step 4: validate before any real order
Kraken can check an order without placing it:
kraken order buy BTCUSD 0.0005 --type limit --price 75000 --validate -o json
Drop --validate and the order is real, with no confirmation prompt. The order receipt includes a mode field reading paper or live, which is the reliable way for code to tell the two apart. Futures orders have no --validate, so rehearse them on futures paper trading instead.
How an AI agent calls it
There are two integration routes.
Shell commands. The agent runs commands and parses JSON from stdout:
kraken <command> [args...] -o json 2>/dev/null
An exit code of 0 means the call worked; 1 signals a runtime or API problem, and 2 means the command itself was malformed. Failures return a JSON error envelope with a stable error field, and the repo includes an error catalog with retry guidance plus a tool catalog of 188 commands, each flagged for whether it is dangerous. An AGENTS.md file in the repo is the full integration contract. This is the same pattern covered in our explainer on function calling vs tool use.
MCP server. kraken-mcp exposes the CLI as MCP tools. By default it loads market, account, paper, workspace and feedback services; live trading is opt-in with -s. For Claude Code, a conservative setup with no account access looks like this:
claude mcp add kraken -- "$HOME/.cargo/bin/kraken-mcp" -s market,paper,feedback
In its default guarded mode, the server marks dangerous tools and, on clients that support MCP elicitation, asks you to approve each such call; an unanswered prompt fails after 300 seconds. On clients without elicitation, the only checks are the model setting acknowledged=true and your client’s own tool-approval prompt, so keep that prompt switched on. The --allow-dangerous flag removes approval entirely. Kraken also warns that the server is meant for your own machine: anything connected to it shares the same account and key, so do not expose or tunnel it.
Kraken ships 59 agent skills as SKILL.md packages, covering workflows such as setup, spot execution with confirmation gates, dollar cost averaging, grid trading and promoting a paper strategy to live. They are a useful reference for how Kraken expects an agent to sequence steps, not proof that any of these strategies works.
Safety checklist for a live bot
Kraken’s README sets out rules for agents trading real money. In short:
- Confirm pair, side, size and estimated cost with a human before any dangerous command.
- Run the order with
--validatefirst, then get approval between validation and the real order. - Check the destination: is
KRAKEN_WORKSPACEset, and does the receipt saypaperorlive? - Give each order a fresh client order ID (
--cl-ord-id) and, after a network error, look the order up before resubmitting so you never double-place it. - For unattended sessions, arm the dead man’s switch.
The dead man’s switch is a Kraken API feature, documented on Kraken’s developer site, that cancels all your open orders if your client stops checking in:
kraken order cancel-after 60
Kraken suggests a 60-second timeout refreshed every 15 to 30 seconds, and cancel-after 0 turns it off. Kraken also recommends disabling it before scheduled engine maintenance, or all orders are cancelled when trading resumes.
Where this fits
kraken-cli handles execution and data; the decision logic is yours. If you want an agent that researches and backtests strategy ideas with explicit overfitting checks, AgentQuant is one open-source harness in our directory. For more tools in this space, browse developer tools and security and privacy.
Kraken’s disclaimer is worth reading in full before connecting an agent to a funded account. It states the tool gives no financial advice, that neither the CLI nor the agent judges whether a trade is sound, and that you are responsible for every action an agent takes with your credentials.
Written by AI Agents Directory
Editorial team
Facts in this guide are checked against official documentation and repositories, which are linked in the article.