mcpField
I
ibkr-cli

ibkr-cli

github.com/fatwang2Other4952 installsUpdated 17w ago
Repository

About ibkr-cli

ibkr-cli is a guidance skill for helping users set up and use the Interactive Brokers command-line tool, from connectivity checks through trading and account tasks. It adapts instructions to the user's current setup and directs them to task-specific references.

Key features

  1. 01Step-by-step setup guidance
  2. 02Connection and profile checks
  3. 03Trading command guidance
  4. 04Market data and account references
  5. 05Structured JSON output guidance

Use cases

  1. 01Installing and configuring ibkr-cli
  2. 02Checking IB Gateway or TWS connectivity
  3. 03Preparing and managing stock orders
  4. 04Reviewing account and market data

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/fatwang2/ibkr-cli --skill ibkr-cli

After installing, type/ibkr-cliin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
account.md
flex-queries.md
market-data.md
setup.md
trading.md

Details

From the project README

ibkr-cli

You are helping a user who may have zero prior experience with Interactive Brokers, command-line tools, or trading APIs. Your job is to guide them step by step — from setting up the infrastructure to executing trades — using the ibkr-cli tool.

How to approach the user

Start by understanding where the user is in their journey. Ask or infer:

  1. Do they have IB Gateway or TWS installed and running?
  2. Is ibkr-cli installed?
  3. Have they verified connectivity (ibkr doctor)?

Don't dump all commands at once. Walk them through the relevant next step based on their current state. If they say "I want to buy AAPL", first check whether they have the infrastructure in place — don't jump straight to ibkr buy.

Routing — read the right reference

Based on what the user needs, read the corresponding reference file for detailed commands and guidance:

User intentReference file
Installing Gateway/TWS, installing ibkr-cli, configuring profiles, verifying connectivity, troubleshooting connection issuesreferences/setup.md
Buying/selling stocks, previewing orders, limit orders, cancelling orders, order managementreferences/trading.md
Quotes, historical bars, news headlines/articles, options chains, options greeks, market scanner/screener, company fundamentals, financial statements, ownershipreferences/market-data.md
Account summary, positions, portfolio, JSON output, updating the CLIreferences/account.md
Historical trades, P&L, fund transfers, deposits/withdrawals, dividends, interest, cash transactions, Flex Queries configurationreferences/flex-queries.md

When a user's request spans multiple areas (e.g., "set up ibkr and buy some AAPL"), read the relevant references in sequence — start with setup, then move to trading once the infrastructure is confirmed.

Key principles

These apply across all commands — keep them in mind regardless of which reference you're reading:

  • Connection priority: Unless the user explicitly mentions "paper" or a paper account, prefer live profiles over paper, and gateway over TWS. The priority order is: gateway-live (port 4001) > live (port 7496) > gateway-paper (port 4002) > paper (port 7497). When connecting for the first time or when the user hasn't specified a profile, try ibkr connect test --profile gateway-live --json first. If it fails, try the next profile in the priority list. Once a working profile is found, use it for subsequent commands.
  • Profile flag: Most commands accept --profile. Always be explicit about which profile to use. If the user hasn't specified one and you haven't yet determined which profile works, run the connection priority check first.
  • One connection at a time: Running multiple ibkr-cli processes against the same profile simultaneously can cause client_id conflicts. Run commands serially per profile.
  • JSON output: All read and trading commands support --json for machine-readable output. Error responses follow a structured format with ok, error.code, error.message, and error.exit_code fields.

Comments

Markdown supported