ibkr-risk-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| IBKR_HOST | No | Where TWS listens. A remote host must also be in the API's Trusted IPs | 127.0.0.1 |
| IBKR_PORT | No | 7496/7497 TWS live/paper, 4001/4002 Gateway live/paper | 7496 |
| IBKR_ACCOUNT | No | **Required** on a multi-account login. Without it every position/account tool refuses rather than combining accounts | |
| IBKR_CLIENT_ID | No | Must differ from every other script on this TWS. **Never 0** — TWS reserves that for orders placed by hand | 17 |
| IBKR_ENABLE_WHATIF | No | The gate on `whatif_order`. Also decides whether the connection itself is opened read-only | false |
| IBKR_GREEKS_TIMEOUT | No | Seconds to wait for greeks on one contract. Short by design — IB answers fast or never, and explicit refusals cut the wait short anyway | 4 |
| IBKR_RISK_FREE_RATE | No | Used to discount and to carry spot to the forward in the local repricing | 0.04 |
| IBKR_WHATIF_TIMEOUT | No | Seconds to wait for a what-if reply. IB sometimes never sends one | 5 |
| IBKR_CONNECT_TIMEOUT | No | Seconds for the API handshake | 6 |
| IBKR_MARKET_DATA_TYPE | No | 1 live, 2 frozen, 3 delayed, 4 delayed-frozen. 3 works and does carry greeks | 1 |
| IBKR_MAX_MKT_DATA_LINES | No | Concurrent market data subscriptions. IB allows about 50 | 40 |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| check_connectionA | Check whether TWS or IB Gateway is reachable and an account is logged in. Call this first whenever another tool fails. It separates the four situations that all present as "cannot connect" and need different fixes:
|
| get_margin_summaryA | Margin and liquidity, split by segment. Returns NetLiquidation, EquityWithLoanValue, FullInitMarginReq,
FullMaintMarginReq, AvailableFunds, ExcessLiquidity, TotalCashValue,
BuyingPower and Leverage — each as the account total and, where IB reports
it, separately for the securities ( The segments are the point. Futures margin must be met in the commodities segment; IB covers a shortfall there by sweeping cash out of the securities segment. An account whose total excess liquidity looks healthy can still be one bad day away from a forced liquidation if the shortfall lands in commodities while securities is also falling. Report the segment figures, not only the totals, whenever futures are involved. |
| get_position_greeksA | IB's model greeks for every option position — its numbers, not ones implied locally. Returns per position: conid, symbol, secType, right, strike, lastTradeDate, settlementDate, daysToExpiry, position, multiplier, undPrice, impliedVol, delta, gamma, vega, theta, optPrice and pvDividend. Things to know about the values:
|
| get_vol_surfaceA | IB's implied volatility surface for an underlying: a grid of (expiry, strike) with impliedVol, delta, optPrice, undPrice and daysToExpiry. This is the input that makes local repricing deterministic. With IB's own volatilities in hand, a constant-volatility scenario needs no proprietary model — only Black-76 arithmetic on top of numbers IB published. Do not collapse the surface to one number. Volatility has a term structure: ES at 139 days can sit near 15% at the money while the front month prints 12%. Using the front month for a longer tenor understates a long-dated position badly. Read the tenor you need, and interpolate between tenors in total variance if you must.
Strikes with no published volatility come back under Check which instrument you got. A bare root is ambiguous: |
| stress_portfolioA | Reprice the whole portfolio — options, equities, futures — across underlying shocks and return the P&L curve and its trough. The trough is the primary output: the worst point of the curve and the
shock at which it sits. The model, returned with every result in
Check Risk Navigator's own volatility shock model is not published. |
| stress_whatifA | The same stress run, with hypothetical legs added — three curves and three troughs: the portfolio as it stands, the portfolio plus the legs, and the difference. This is what replaces reading Risk Navigator's What-If by hand: "if I add N puts at strike K expiring E, where does the trough move to?" Read all three troughs. The trough of the difference is not the difference of the troughs — adding protection moves where the worst point sits as well as how deep it is, and comparing only the depths hides the move. A structure that lifts the bottom by very little may still have pushed it from −8% out to −15%, which is the part that matters. Hypothetical options are priced off IB's current model greeks for those
exact contracts, so both curves start from the same volatilities and the
difference is the structure alone. A leg that cannot be resolved or priced
is reported in Nothing is sent to IB's order path here — this is pure local repricing. For what the structure costs in margin, use whatif_order. |
| whatif_orderA | IB's own margin impact for a hypothetical structure. Nothing reaches the market. Each order carries Returns initMargin, maintMargin and equityWithLoan before/after/change, plus commission and any warningText, in two views:
Read the combined figure, not the sum of the legs. SPAN offsets the legs
against each other and against what the account already holds, so the two
differ — the difference is reported as If every call fails with no margin figures, check whether TWS has "Read-Only API" enabled — that setting blocks what-if orders too. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/simoneb/ibkr-risk-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server