Skip to main content
Glama
enpalco

MCP Portfolio Server

by enpalco
README.md
# MCP Portfolio Server

A lightweight MCP server with standalone functions to fetch and normalize **investment** portfolio data from **eToro** and **Interactive Brokers (IBKR)** that saves time consuming effort of importing and extracting portfolio data in spreadsheets.

## Overview

This project provides three reusable Python files:

- `etoro_portfolio.py` — fetches and normalizes eToro portfolio data
- `ibkr_portfolio.py` — fetches and normalizes IBKR portfolio data
- `portfolio_mcp_server.py` — runs as an MCP server

The files themselves **do not** automatically aggregate positions across brokers. Instead, their outputs are designed to be easily consolidated and visualized using any agent such as Claude, Gemini, or ChatGPT.

## MCP Server

The `portfolio_mcp_server.py` exposes the eToro and IBKR portfolio functions as **MCP tools**. When running, it allows AI agents (such as Claude, Gemini, or ChatGPT with MCP support) to:

- Call `get_etoro_portfolio` to retrieve normalized eToro holdings
- Call `get_ibkr_portfolio` to retrieve normalized IBKR holdings

These tools return structured portfolio data (symbol, quantity, market value, unrealized P&L, asset class) that the agent can then use to:

- Merge and deduplicate positions across brokers
- Calculate portfolio-level aggregates (total market value, cost basis, P&L, % allocation)
- Classify assets and generate allocation breakdowns
- Create consolidated tables and visualizations (e.g., donut charts, bar charts)

Because the server only provides the raw normalized data, any further data consolidation, aggregation, or visualisation  is performed by the agent using the tool outputs.

## Installation

```bash
git clone https://github.com/<username>/mcp-portfolio-server.git
cd mcp-portfolio-server
uv sync
```

## Usage

### eToro
```python
from etoro_portfolio import get_etoro_portfolio
portfolio = get_etoro_portfolio()
```

### IBKR
```python
from ibkr_portfolio import get_ibkr_portfolio
portfolio = get_ibkr_portfolio()
```

### MCP Server
```bash
mcp dev portfolio_mcp_server.py
```

## Configuration

Store credentials in a `.env` file (excluded from the repository):

```env
ETORO_PUBLIC_KEY=your_public_key
ETORO_PRIVATE_KEY=your_private_key
IBKR_TOKEN=your_flex_token
QUERY_ID=your_query_id
```

## License

MIT License

## Disclaimer

This project is for personal/educational use and is not affiliated with eToro or Interactive Brokers.