Skip to main content
Glama
simoneb

ibkr-risk-mcp

by simoneb

whatif_order

Idempotent

Simulate a hypothetical order's margin impact and commissions using IB's what-if engine, without sending any order to market.

Instructions

IB's own margin impact for a hypothetical structure. Nothing reaches the market.

Each order carries whatIf=True, which IB evaluates in its margin engine and discards: it is never routed, never acknowledged as live, never appears in the order book. The tool is still gated behind IBKR_ENABLE_WHATIF=true because it is the only thing in this server that touches the order path at all; with the gate closed it sends nothing and returns blocked: true.

Returns initMargin, maintMargin and equityWithLoan before/after/change, plus commission and any warningText, in two views:

  • perLeg — each leg evaluated on its own.

  • cumulative — legs 1..k as a combo, for every k, so you can see where the offset appears.

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 offset.spanOffset. IB's what-if on arbitrary multi-leg combos is unreliable and will sometimes return nothing; that is reported per step and does not mean the structure is invalid.

If every call fails with no margin figures, check whether TWS has "Read-Only API" enabled — that setting blocks what-if orders too.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
legsYesThe structure to evaluate. Each leg is a conid, or symbol+secType+expiry+strike+right, with action BUY/SELL and a quantity.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the annotations, the description discloses crucial behavioral traits: orders are never routed, never acknowledged as live, never appear in the order book, and return blocked when the gate is closed. It also surfaces a reliability caveat about multi-leg combos sometimes returning nothing, plus the Read-Only API failure mode — rich transparency beyond structured hints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is longer than average, but every section earns its place: purpose, safety, return fields, view breakdown, interpretation warning, and troubleshooting. Bolded key takeaways and a clean bullet list make it scannable without padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with complex margin semantics, the description explains return values (initMargin, maintMargin, equityWithLoan, commission, warningText), two output views, SPAN offset behavior, failure modes, and environment prerequisites. The output schema exists, but the description goes beyond it to give operational context, making it highly complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides full description coverage: legs are explained as conid or descriptive fields with action and quantity. The tool description adds interpretive guidance ('Read the combined figure, not the sum of the legs') but does not meaningfully expand parameter semantics beyond the excellent schema documentation, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description immediately states a specific purpose: 'IB's own margin impact for a hypothetical structure.' It adds a strong differentiator with '**Nothing reaches the market.**' and explains that each order carries whatIf=True, clearly distinguishing it from live-order or simple read-only siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use this tool — for hypothetical structures needing margin impact without market exposure — and includes practical caveats like the IBKR_ENABLE_WHATIF gate and the TWS Read-Only API check. It does not explicitly name an alternative tool or state when not to use it, but the context is clear enough.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/simoneb/ibkr-risk-mcp'

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