# Portfolio CSV Analyzer MCP

> Portfolio CSV Analyzer processes massive financial exports from brokers like DEGIRO or XTB without crashing your AI client. This MCP streams data locally, preventing context window overload. It reliably extracts the full column schema and provides sample records, giving your agent a clean, safe dataset to analyze complex portfolio performance metrics.

## Overview
- **Category:** data-analytics
- **Price:** Free
- **Tags:** csv-parsing, data-streaming, financial-data, data-processing, large-file-handling

## Description

When you download a year's worth of trades from any major broker, the resulting CSV file is huge. If you try to upload that massive dump into your AI client, it will choke—the context window fills up, and the analysis becomes unreliable or just crashes entirely. This MCP changes that. It acts like a local data pre-processor for your agent.

It uses a high-speed streaming parser to read your financial history line by line, all on your machine. Instead of dumping every single row into the chat, it intelligently extracts two things: the exact column headers and a small sample of the data. This gives your AI client the precise schema it needs—like knowing 'Action' or 'Value' exists—without ever overwhelming its memory. You can then safely ask your agent to write aggregation scripts or calculate complex metrics based only on the verified structure. Because Vinkius hosts this MCP, you connect once and get access to reliable data handling for financial reporting.

This process lets you treat multi-gigabyte broker exports like a structured database query, giving you accurate insights instead of context window errors.

## Tools

### parse_portfolio_csv
Reads massive CSV exports from brokers (DEGIRO, XTB, Trading212) locally to return the column schema and a data sample for safe AI analysis.

## Prompt Examples

**Prompt:** 
```
Parse my DEGIRO_export.csv and tell me what data columns I have available to calculate my total dividends.
```

**Response:** 
```
Based on the CSV schema, you have the following columns: Date, Product, ISIN, Description, and Amount. The 'Description' column labels your dividends.
```

**Prompt:** 
```
Look at the schema of this broker export and write a Python script for me that sums up all my buy orders.
```

**Response:** 
```
Here is a Python script using pandas that targets the 'Action' and 'Value' columns we just discovered in your CSV file.
```

**Prompt:** 
```
How many total rows are in this trading history CSV?
```

**Response:** 
```
The streaming parser counted exactly 4,521 rows of transaction data.
```

## Capabilities

### Determine available columns
You get an immediate list of every column header in your CSV file (e.g., Date, Product, ISIN) so your agent knows exactly what data points exist for analysis.

### Generate aggregation scripts
Your AI client can write Python or R code that sums up metrics (like total buys or dividends) using the defined column structure.

### Count transaction rows
The MCP counts and reports the exact number of data rows in your entire trading history file, giving you a reliable dataset size metric.

### Analyze P&L structure
You can ask the agent to analyze column relationships to calculate profit and loss across multiple trades based on the schema provided.

## Use Cases

### Calculating Total Dividend Income
A PM downloads a 10-year trade history CSV. Instead of uploading the whole file and hoping it doesn't crash, they run parse_portfolio_csv first. The agent gets the schema and sees 'Description' is the dividend column, allowing it to write the exact summing script needed.

### Validating a New Broker Export
A Data Engineer receives an export from a new broker they haven't seen before. They use parse_portfolio_csv to immediately check for all available columns and confirm if the required 'Action' column is present, saving hours of manual data cleaning.

### Auditing Transaction Counts
A Quant needs to know the exact total row count for a regulatory report. They run parse_portfolio_csv, and the tool immediately reports the precise number of transaction rows (e.g., 4,521), providing an auditable metric instantly.

### Comparing Multiple Broker Exports
A PM has three different CSVs from different years/brokers. They run parse_portfolio_csv on each one to get a consistent schema for all of them, allowing the agent to compare performance metrics across disparate data sources safely.

## Benefits

- Avoids LLM crashes. Instead of uploading a massive file that exhausts your agent's memory, this MCP streams the data locally and only sends the necessary schema.
- Guaranteed accurate structure. It automatically detects column headers and data types from complex broker exports, so you don't have to manually map fields for your AI client.
- Works with huge files. The streaming parser handles CSVs of any size, making it reliable even when dealing with decades of trading history.
- Safe analysis environment. By providing only the schema and a sample, you ensure that your agent is basing its calculations on verified data structure, not hallucinated context.
- Directly applicable. Once you run the parse_portfolio_csv tool, your AI client can immediately guide you to write specific aggregation scripts for P&L or total dividends.

## How It Works

The bottom line is you get structured metadata about huge files, allowing your agent to work with massive financial datasets without running into context window limits.

1. Provide the absolute file path pointing to your massive CSV export from a broker (like XTB or DEGIRO).
2. The MCP runs a local, high-speed stream parse on the entire file, reading it line by line without sending everything to the chat.
3. You receive back a clean summary: the full column schema and representative sample data that your AI client can use for safe analysis.

## Frequently Asked Questions

**Does Portfolio CSV Analyzer handle all broker exports?**
Yes. This MCP is designed to take massive, messy CSV files from any major brokerage (like DEGIRO or XTB) and process them reliably.

**How does parse_portfolio_csv prevent context window issues?**
It uses local streaming technology. Instead of sending the entire file content to your AI client, it reads it line by line on your computer and only sends the clean schema and a sample.

**Can I use this MCP for non-broker CSV files?**
The tool is optimized for financial exports. While it handles general CSV structures, its primary strength lies in reliably parsing complex trading history data.

**What information do I get back after running parse_portfolio_csv?**
You receive two key things: the complete list of column headers (the schema) and a small, representative sample of the actual data rows. This gives your AI client everything it needs to start.

**Is this MCP secure for private financial data?**
Yes, because the core parsing is done locally on your machine; only the structured schema and a small sample are passed to your agent, keeping the bulk of your raw data protected.