Skip to main content
Glama
aiordanescu

ib-gateway-mcp

by aiordanescu

Position P&L

get_position_pnl
Read-only

Get live P&L for one position: daily, unrealized, realized, and market value. Pass the contract's con_id or contract details to retrieve exact numbers.

Instructions

Return the live P&L of one position: daily, unrealized, realized and market value.

Pass the position's con_id (from get_positions) for an exact match. Waits a few
seconds at most for IBKR's first update. Errors: not_found when the account has no
position and no P&L today in that contract; ambiguous_contract lists candidates;
invalid_request for a combo (BAG: ask per leg); request_timeout when IBKR sends nothing
for a position the account holds (retry once).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountNoIBKR account id, e.g. DU1234567. Omit to use the default account; list_accounts shows which accounts are allowed.
contractYesThe instrument. A con_id alone is unambiguous; otherwise give symbol and sec_type, plus expiry, strike and right for options.
model_codeNoFinancial-advisor model code, to scope the result to one model portfolio. Omit for the whole account (normal for non-advisor accounts).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
as_ofYesWhen this server read the values (UTC); IBKR refreshes P&L about every second.
accountYes
contractYes
positionNoQuantity held; 0 if closed today.
daily_pnlNoP&L since the start of today's session.
model_codeNo
market_valueNoCurrent market value of the position.
realized_pnlNo
unrealized_pnlNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

Beyond the readOnlyHint annotation, the description discloses latency ('waits a few seconds at most for IBKR's first update') and enumerates concrete error modes and recovery guidance (retry once on request_timeout). This significantly exceeds what annotations alone convey.

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?

Three sentences with no filler: purpose first, then input guidance, then error behavior. Every sentence adds operational value, and the structure makes it easy to scan.

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?

With a rich output schema, readOnlyHint, and a clear error contract, the description covers everything an agent needs: purpose, exact-match input source, latency expectation, failure modes, and retry behavior. Nothing critical is missing.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3. The description adds practical meaning by telling the agent to source con_id from get_positions and clarifying that combos are invalid, which helps disambiguate how the contract parameter should be used.

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 opens with a specific verb and resource: 'Return the live P&L of one position: daily, unrealized, realized and market value.' The phrase 'one position' clearly distinguishes it from siblings like get_pnl, which covers account-level P&L, and from get_positions, which lists positions.

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?

It gives clear context: pass con_id from get_positions for an exact match, and it states an explicit exclusion for combos (BAG) with direction to ask per leg. It does not explicitly name alternative tools for account-level P&L or when to prefer get_pnl, but the 'one position' scoping and error guidance communicate when to use this tool.

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