Skip to main content
Glama
pedrobraiti

mcp-ibkr-agent

by pedrobraiti

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
IBKR_ACCOUNT_IDYesIBKR account ID (e.g., DU1234567 for paper)
MAX_ORDER_VALUENoMaximum order value in USD100.0
TRADING_DRY_RUNNoIf 'true', validates orders but does not send themtrue
IBKR_API_BASE_URLNoEndpoint of the IBKR Client Portal Gatewayhttps://localhost:5000/v1/api
IBKR_TRADING_MODENoTrading mode: 'paper' or 'live'paper
TRADING_ALLOW_LIVENoSet to 'true' to allow live trading (hard safety lock)false

Capabilities

Features and capabilities supported by this server

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}
experimental
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
session_statusA

Trading posture — "am I safe to trade right now?" — plus which account is live.

Identity: authenticated/connected/competing, account_id, account_type ("LIVE"/"PAPER", the ground truth from IBKR's isPaper, NOT the IBKR_TRADING_MODE label) and is_paper. A LIVE account includes a warning.

Posture (so an unattended caller can self-gate): dry_run, allowlist_active, daily_cap_configured, remaining_daily_budget (when a cap is set), unresolved_orders (dispatched-but-unconfirmed orders that must be reconciled before resending), trade_stops (active reasons NOT to trade — a competing session, or unresolved in-flight orders) and an advisory safe_to_trade. When live trading is armed with no cap, a daily_cap_warning.

reconcile_pendingA

Reconcile dispatched-but-unconfirmed orders against IBKR's open orders.

After a timeout/crash an order may have landed without its outcome journaled, so the safety layer BLOCKS an identical resend until it is reconciled. This clears that block: orders found resting on IBKR are marked resolved; ones not found stay blocked (they may have filled — resending blind would double them). Set resolve_missing=true to also clear the not-found ones AFTER you've verified via positions/trade_history that they didn't fill.

market_statusA

Indicates whether the US market is open (RTH) right now.

get_quoteA

Current quote (last/bid/ask) for a US stock symbol.

get_quotesA

Quotes for several US stock symbols at once (one snapshot — cheaper for a watchlist).

account_summaryB

Account summary: available funds, net liquidation, buying power.

positionsC

Open positions in the account.

portfolioA

Combined snapshot: account summary + open positions + total unrealized P&L.

buyA

Buy. Provide cash_amount (US$, fractional via cashQty) OR quantity (shares).

Omit limit_price for a market order. Pass limit_price for a LIMIT order — LIMIT requires quantity (cashQty is market-only). A limit order may surface a confirmation IBKR hasn't mapped yet; if so it is blocked (safe) until allow-listed.

A cash_amount buy comes back with is_cash_quantity: true. Its fill is reported in SHARES in filled_quantity and in US$ in filled_cash (IBKR itself reports both in the same field — see order_status); size any protective stop from the SHARE count.

sellA

Sell by quantity (shares, fractional ok). Omit limit_price for market, pass it for LIMIT.

IBKR does NOT accept selling by US$ value (cashQty is buy-only). To exit 100% of a position use close_position; to sell a dollar amount, compute the quantity via get_quote.

close_positionA

Closes 100% of a symbol's position, trading the exact fractional quantity.

Reads the exact position size and sends the opposite order. Note: IBKR's portfolio is eventually-consistent — right after a recent BUY the position may not appear yet (and the close will return closed=False). In that case, wait a few seconds and try again, or sell the exact quantity via sell.

stop_orderA

Place a STOP order (e.g. a stop-loss). Triggers a market order when stop_price is hit.

side is "BUY" or "SELL" (a stop-loss on a long position is a SELL). Pass limit_price to make it a STOP-LIMIT (becomes a limit order on trigger instead of a market order). Sized by quantity (shares).

trailing_stopB

Place a TRAILING stop — a stop that follows the price (locks in gains as it moves).

The trigger trails the market by trail_amount (US$) or trail_percent (%). side is "BUY" or "SELL" (a trailing stop-loss on a long position is a SELL). Sized by quantity (shares).

bracket_orderA

Place an entry order with attached take-profit and stop-loss exits (OCO).

The entry buys (or sells) quantity shares — market by default, or a limit if entry_limit_price is set. Once it fills, two exits go live: a limit at take_profit and a stop at stop_loss; when one fills the other is cancelled. Returns one result per leg (labelled entry / take_profit / stop_loss in message).

preview_orderA

Preview an order's impact (margin, estimated commission, warnings) WITHOUT sending it.

Uses IBKR's whatif so the agent can reason about cost/margin before committing. side is "BUY" or "SELL"; size is cash_amount (USD) or quantity (shares). Pass limit_price to preview a LIMIT order (needs quantity).

order_statusA

Status of a placed order by its order_id: state, filled quantity, average price.

Use this after buy/sell to confirm whether the order actually filled — positions is eventually-consistent and lags right after a trade.

Units: filled_quantity is ALWAYS in SHARES, filled_cash is the US$ spent (set only on a cash_amount order). If quantity_is_estimate is true the share count was derived from a partial cash fill — do NOT size an exit from it; read positions for the exact size.

wait_for_fillA

Poll an order until it reaches a terminal state (filled/cancelled/rejected/inactive), or the timeout elapses.

Closes the confirm-the-fill loop so the agent doesn't have to orchestrate the retry itself. Returns the latest status with timed_out true if it was still working when time ran out. timeout_seconds is capped at 120. Note: an inactive result usually means the order was rejected/killed, but IBKR also uses it for an order parked until the market opens — so confirm intent before assuming it's dead.

Same unit contract as order_status: filled_quantity in SHARES, filled_cash in US$, and quantity_is_estimate true when the share count was derived from a partial cash fill.

cancel_orderA

Cancels an open order by its order_id.

open_ordersB

Lists the active orders (live orders) in the account.

Same unit contract as order_status: filled_quantity in SHARES, filled_cash in US$.

trade_historyA

Audit log of the agent's recent order attempts (buys, sells, dry-runs, blocks).

Reads the local trade journal — answers "what did my agent do?". Does not hit IBKR.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pedrobraiti/agentic-trading-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server