Aegis Risk
A multi-agent financial portfolio risk analyzer that provides MCP tools for fetching market news and storing compliance-reviewed assessment reports in a local database.
README
🛡️ Aegis Risk: Multi-Agent Financial Portfolio Risk Analyzer

A real-world production-grade AI portfolio project demonstrating Agentic AI, Model Context Protocol (MCP), LangGraph orchestration, State Management, and GCP Cloud Run deployment with Vertex AI.
This project simulates a financial advisory system where multiple specialized AI agents collaborate to analyze market news, calculate portfolio exposure, assess compliance risks, and generate detailed assessment reports stored in a local database.
🏗️ Architecture Overview
The system utilizes a client-server architecture separating the Model Orchestration Client (LangGraph) from the Data & Tools Server (MCP Protocol) to achieve secure, modular data integration.
graph TD
User([User Web Interface]) <-->|SSE / REST API| FastAPI[FastAPI Backend Server]
subgraph Client Application
FastAPI <-->|Orchestrates| LG[LangGraph Engine]
LG <-->|State Checkpoint| Mem[MemorySaver Checkpointer]
subgraph Multi-Agent System
LG --> Agent1[Researcher Agent]
LG --> Agent2[Portfolio Analyst Agent]
LG --> Agent3[Risk Manager Agent]
LG --> Agent4[Compliance Auditor Agent]
end
end
subgraph Custom MCP Server
MCP_Client[MCP Client stdio] <-->|JSON-RPC| MCP_Server[MCP Server subprocess]
Agent1 <-->|Call tools| MCP_Client
Agent3 <-->|Call tools| MCP_Client
MCP_Server <-->|Scrape & Fetch| Web[Mock Financial News API]
MCP_Server <-->|Read/Write| DB[(SQLite Database)]
end
subgraph Google Cloud Platform
FastAPI -.->|IAM Auth| Vertex[GCP Vertex AI / Gemini 1.5 Flash]
end
classDef primary fill:#8b5cf6,stroke:#333,stroke-width:2px,color:#fff;
classDef secondary fill:#06b6d4,stroke:#333,stroke-width:2px,color:#fff;
class LG,Agent1,Agent2,Agent3,Agent4 primary;
class MCP_Server,DB secondary;
🤝 The Multi-Agent Loop
- Market News Researcher: Discovers if the stock is currently held in the user's holdings and pulls the latest headlines using custom MCP tools.
- Portfolio Analyst: Correlates news catalysts with the current portfolio exposure (shares, average cost basis) and performs quantitative calculations.
- Risk Manager: Drafts a detailed Markdown report and classifies risk (Low, Medium, High). Invokes the database tool to save the assessment.
- Compliance Auditor: Reviews the drafted report. If compliance rules are met, it approves the report. If not, it issues feedback and routes back to the Risk Manager for revision.
🛠️ Tech Stack & Key Concepts
- LangGraph: Orchestrates the multi-agent execution DAG with a defined state schema, custom routing edges, and checking loops.
- Model Context Protocol (MCP): Establishes a standard protocol connection via
stdioto run a localized database and scraping toolkit. - FastAPI: Manages lifespan connections for the MCP subprocess and serves Server-Sent Events (SSE) to deliver real-time agent console logs to the UI.
- Tailored UI Aesthetics: Premium glassmorphic design utilizing rich dark palettes, dynamic SVG indicators, pulsing loaders, and a live pipeline visualizer.
- GCP Vertex AI: Connects to the Gemini models natively via GCP Service Accounts (IAM roles) avoiding manual API key management in production.
🚀 Local Quickstart
Prerequisites
- Python 3.12+
- Git
- An API Key (Google Gemini API key) OR authenticated Google Cloud SDK.
1. Clone & Set Up Environment
# Clone the repository
git clone <your-repo-url>
cd multiagent-mcp-gcp-portfolio
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
2. Configure Environment Variables
Create a .env file in the project root:
# For local testing fallback (Standard Gemini API)
GOOGLE_API_KEY=your_gemini_api_key_here
# For GCP Vertex AI (set to false for local testing with API key)
USE_VERTEX_AI=false
3. Run Verification Tests
Before starting the web server, run the automated integration test to verify the LangGraph-MCP connection:
python test_agents.py
This script will launch the MCP server in a background subprocess, run the agentic workflow, save a report to the SQLite DB, and verify the database entry.
4. Start the Web App
python app.py
Open your browser and navigate to http://localhost:8000.
☁️ GCP Deployment (Cloud Run + Vertex AI)
The production architecture deploys the container to Google Cloud Run, which calls Gemini via Vertex AI. Authentication is managed entirely through GCP Service Accounts.
Prerequisites
- Installed and authenticated Google Cloud SDK (
gcloud auth login). - A GCP project with billing enabled.
Automated Deployment
We provide an automated bash script to configure permissions and deploy:
chmod +x deploy.sh
./deploy.sh
What this script does under the hood:
- Enables GCP APIs: Cloud Run, Artifact Registry, Vertex AI, Cloud Build.
- Creates a Service Account (
agentic-portfolio-sa). - Binds the
roles/aiplatform.user(Vertex AI User) role to the Service Account, granting permission to call Gemini. - Builds the Docker image locally and pushes it to Google Artifact Registry.
- Deploys the service to GCP Cloud Run using the Service Account.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。