Skip to main content
Glama
zionto

ibkr-mcp

by zionto

flex_analyze_portfolio_history

Analyze portfolio NAV changes over time and compute returns using time-weighted (TWR) or money-weighted (MWR) methods from Interactive Brokers Flex XML data.

Instructions

Show how the portfolio NAV changed over time and compute a return figure.

Return methods

twr (default) — Time-Weighted Return via daily chain-linking. Eliminates the timing/size effect of external cash flows. Use this to evaluate the strategy independent of cash-flow decisions.

mwr — Money-Weighted Return via Modified Dietz. Reflects the investor's actual experience: large deposits before a rally boost the return; large withdrawals before a rally reduce it. Use this to evaluate overall portfolio performance.

Args: xml_content: Raw Flex XML string. metric: Which equity component to track — "total", "cash", "stock", "options", "futures", "bonds" (default "total"). return_method: "twr" (default) or "mwr".

Returns JSON with a time-series, annualised and period returns, and the total net external cash flow over the period.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricNototal
xml_contentYes
return_methodNotwr

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Without annotations, the description carries the full burden of behavioral disclosure. It explains the computation logic (daily chain-linking, Modified Dietz), what the result includes (time-series, annualised and period returns, total net external cash flow), and the effect of cash flows on each method. It does not explicitly state that the operation is read-only, but the 'analyze' verb and the nature of the tool make that a safe inference. Overall, it provides strong behavioral context without contradiction.

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 well-structured with clear sections: a one-sentence purpose, a 'Return methods' section, and an 'Args' section. Every sentence earns its place, providing necessary detail without fluff. The markdown formatting (headings, bullets) improves scannability. It is appropriately sized for the complexity of the tool.

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?

The description covers all essential aspects: purpose, return methods, parameters, and return value. Since an output schema exists, the exact JSON structure need not be spelled out, but the description summarizes the output contents. Given the moderate complexity (3 parameters, no nested objects), this is complete enough for an agent to select and correctly invoke the tool.

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

Parameters5/5

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

The schema provides no descriptions (0% coverage), so the description must explain each parameter. It does so thoroughly: xml_content is described as 'Raw Flex XML string'; metric lists valid values ('total', 'cash', 'stock', 'options', 'futures', 'bonds') and its default; return_method is explained with each option and its default. This fully compensates for the bare schema and adds meaningful semantic context.

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, action-oriented statement: 'Show how the portfolio NAV changed over time and compute a return figure.' This clearly identifies the resource (portfolio NAV history) and the action (analyze/return), making it easy to distinguish from sibling analysis tools like flex_analyze_pnl or flex_analyze_dividends. The additional method details (TWR vs MWR) further reinforce a unique purpose.

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 provides clear guidance on when to use each return method: 'Use this to evaluate the *strategy* independent of cash-flow decisions' for TWR and 'Use this to evaluate overall portfolio performance' for MWR. This helps the agent choose the correct option. However, it does not explicitly compare against sibling tools (e.g., 'use flex_analyze_pnl when...'), leaving tool selection somewhat implied rather than explicit.

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

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