# MCP Agent: Portfolio Analytics

Comprehensive portfolio analytics agent orchestrating 5 MCP-FastAPI backend servers via n8n workflow. Combines QuantStats analysis, AI technical analysis, security performance reports, and Yahoo Finance data in a single chat interface.

## Links
- App: https://rbicc.net/mcp-quantstats-agent
- Docs: https://tigzig.com/app-documentation/mcp-quantstats-agent.html
- GitHub (Frontend): https://github.com/amararun/shared-portfolio-analysis-react

## Tags
mcp-servers, portfolio-analysis, n8n, quantstats, technical-analysis

## Architecture

```
React Chat UI → n8n Webhook → MCP Agent Nodes → 5 Backend Servers
├── QuantStats MCP (quantstats.hosting.tigzig.com/mcp)
├── Technical Analysis MCP
├── SPR/FFN MCP (ffn.hosting.tigzig.com/mcp)
├── Yahoo Finance MCP (yfin.hosting.tigzig.com/mcp)
└── ReportLab PDF Server
```

This is the orchestration layer that ties together the individual MCP servers. The React frontend sends requests to an n8n webhook, which routes to the appropriate MCP server based on the analysis type requested.

### Analysis Capabilities

**QuantStats Analysis** - Single symbol vs benchmark. Risk-return ratios (CAGR, Sharpe, Sortino). Uses quantstats-lumi package.

**AI Technical Analysis** - Technical indicators via Finta package. Charts via Matplotlib analyzed by Gemini Vision API. PDF and HTML reports.

**Security Performance Report (SPR)** - Multi-symbol portfolio analysis. Custom calculations + FFN library. Interactive daily returns charts with risk metrics.

**Yahoo Finance Data** - Financial statements, historical prices, company profiles for any Yahoo Finance symbol.

### Example Queries
- "Compare AAPL against QQQ from January 2020 to March 2023"
- "Analyze MSFT with RSI, MACD and Bollinger Bands for the past 6 months"
- "Generate SPR for AAPL,MSFT,GOOG from 2020-01-01 to 2023-12-31"

## Setup

Frontend: Same as Quants Agent (shared-portfolio-analysis-react). Backend: Deploy all 5 MCP servers independently, configure n8n workflow with MCP client nodes pointing to each `/mcp` endpoint.

### Backend Server Repos
- QuantStats: https://github.com/amararun/shared-quantstats
- Technical Analysis: https://github.com/amararun/shared-fastapi-mcp-technical-analysis
- SPR/FFN: https://github.com/amararun/shared-fastapi-mcp-ffn
- Yahoo Finance: https://github.com/amararun/shared-yfin-coolify
- ReportLab PDF: https://github.com/amararun/shared-reportlab-md-to-pdf

### Environment
```
IS_LOCAL_DEVELOPMENT=1
BASE_URL_FOR_REPORTS=https://your-domain.com/
VITE_N8N_WEBHOOK_URL=your_n8n_webhook_url
```
