home / mcp / ib analytics mcp server

IB Analytics MCP Server

Provides an MCP server to run IB Analytics analyses, supporting multi-account portfolio analytics, data retrieval, risk/cost/tax analysis, and automated reporting.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "knishioka-ib-sec-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "ib-sec-mcp[mcp] @ git+https://github.com/knishioka/ib-sec-mcp",
        "ib-sec-mcp"
      ],
      "env": {
        "TOKEN": "your_token_here",
        "QUERY_ID": "your_query_id"
      }
    }
  }
}

IB Analytics provides an MCP server integration that enables Claude Desktop and Claude Code to communicate with the IB Analytics analysis engine. You can run a local MCP server, configure it in your Claude clients, and perform automated, multi-account portfolio analysis, tax and cost analytics, and advanced reporting workflows using predefined prompts and tools.

How to use

You will connect a Claude client to the MCP server using a local MCP configuration. The MCP server exposes a set of tools and resources that let you perform portfolio analysis, market data lookups, tax and cost analyses, and automated reporting. Start the MCP server on your machine, then configure Claude Desktop or Claude Code to point to the local MCP process. Once connected, you can issue natural language prompts or scripted tool compositions to analyze accounts, compare performance, or generate reports.

How to install

Prerequisites: you need Python 3.12+ and an environment where you can install Python packages. You also need an IB Flex Query account to supply credentials when you fetch data.

Step by step install flow if you are using the MCP-enabled Python package setup shown in the source configuration:

pip install -e .
pip install -e ".[mcp]"
pip install -e ".[dev]"
pip install -e ".[dev,mcp,visualization,reporting]"

Additional setup notes

Configure your IB Flex Query credentials in your environment or in a local .env file. You will typically set QUERY_ID and TOKEN to enable data fetches. You can run the MCP server in a development or production-like environment depending on your needs.

MCP server configuration and usage

Two concrete MCP setup options are provided for integrating with Claude clients. Use the configuration that matches your workflow.

Configuration examples

Option 1 configures Claude Desktop to launch the MCP server via uvx with a packaged MCP module from GitHub. This does not require cloning a local repository.

Security and credentials

Do not expose your credentials. Use environment variables or secret management to store QUERY_ID and TOKEN, and avoid committing them to version control. Enable debug mode only in non-production troubleshooting. Use restricted permissions for the MCP server process and limit network exposure to trusted clients.

Troubleshooting

If you encounter connection issues, verify that QUERY_ID and TOKEN are correctly set in your environment, check that the MCP server process is running, and ensure Claude client configuration points to the correct local process. Review logs for authentication or data fetch errors and validate that your IB Flex Query settings return data as expected.

Note on tools and capabilities

The MCP server exposes a range of portfolio analysis, market data, tax and cost analytics, and reporting tools. These tools enable you to analyze performance, review risk metrics, fetch stock and options data, and generate comprehensive reports inside Claude workflows.

Examples of typical workflows

1) Investor workflow: fetch data from IB Flex Query, run portfolio and performance analysis, and generate a console or HTML report for a given account.

2) Developer workflow: compose a sequence of analyses and create an automated report generation step that can be run as part of a broader data science pipeline.

Available tools

analyze_performance

Analyze overall trading performance and generate performance metrics.

analyze_risk

Assess risk scenarios including market and interest rate risk.

get_portfolio_summary

Provide a high-level summary of portfolio holdings and metrics.

get_stock_analysis

Fetch and analyze stock data for a given symbol.

get_current_price

Retrieve the latest price for a symbol.

get_stock_info

Return detailed information about a stock.

get_options_chain

Obtain options chain data for a symbol.

calculate_greeks

Compute option Greeks for strategies.

calculate_iv_metrics

Calculate implied volatility metrics for options.

analyze_tax

Compute tax implications and liabilities.

analyze_costs

Analyze commissions and trading costs.

calculate_tax_loss_harvesting

Evaluate tax loss harvesting opportunities.

get_position_history

Time series data for a symbol over a date range.

get_portfolio_snapshot

Snapshot of all positions on a specific date.

compare_portfolio_snapshots

Compare portfolio snapshots across dates.

get_position_statistics

Aggregate statistics over time for positions.

get_available_snapshot_dates

List dates that have available position snapshots.

IB Analytics MCP Server - knishioka/ib-sec-mcp