Financial Data MCP Server
Provides real-time stock data analysis, portfolio management, technical analysis with EMA/MACD indicators, and automated trading recommendations with confidence levels using Yahoo Finance API.
README
Financial Data MCP Server
A comprehensive Model Context Protocol (MCP) server for financial data analysis, portfolio management, and automated trading recommendations.
Features
- 📊 Real-time Stock Data - Uses free yfinance (Yahoo Finance) API - no API keys required
- 💼 Portfolio Management - Track multiple portfolios with automated analysis
- 📈 Technical Analysis - EMA-based trend detection and MACD charts
- 🎯 Trading Signals - Automated buy/sell recommendations with confidence levels
- 📧 Email Reports - Automated batch analysis reports with chart attachments
- 📉 Performance Tracking - Daily monitoring of recommendation performance
- 🤖 MCP Integration - Full integration with Claude Code and other MCP clients
Architecture
Core Components
-
financial_mcp_server.py - Main MCP server
- Provides MCP tools and resources for financial analysis
- Integrates with Claude Code
- Real-time stock data via yfinance
-
batch_fin_mcp_server.py - Batch analysis engine
- Analyzes all portfolios at once
- Generates comprehensive reports and charts
- Implements 4 trading scenarios based on EMA analysis
-
email_report_script.py - Email automation
- Sends analysis results via email
- Attaches charts and detailed reports
- Saves buy recommendations for tracking
-
daily_tracking_script.py - Performance tracking
- Monitors buy recommendation performance
- Creates tracking charts
- Generates daily performance reports
Installation
1. Clone the repository
git clone https://github.com/j1c4b/finance_mcp_server.git
cd finance_mcp_server
2. Create and activate virtual environment
python3 -m venv mcp_fin_server_venv
source mcp_fin_server_venv/bin/activate # On Windows: mcp_fin_server_venv\Scripts\activate
3. Install dependencies
pip install -r clean_requirements.txt
Configuration
Portfolio Setup
Edit portfolio.json to add your portfolios:
{
"tech_stocks": {
"portfolio": "Technology Giants",
"stock_list": ["AAPL", "GOOGL", "MSFT", "AMZN", "META"]
},
"dividend_portfolio": {
"portfolio": "Dividend Champions",
"stock_list": ["JNJ", "PG", "KO", "PEP", "MMM"]
}
}
Email Configuration (Optional)
For email reports, create email_config.json:
{
"smtp_server": "smtp.gmail.com",
"smtp_port": 587,
"sender_email": "your_email@gmail.com",
"sender_password": "your_app_password",
"recipient_emails": ["recipient@example.com"],
"subject_prefix": "📊 Financial Analysis Report",
"max_attachment_size_mb": 25
}
Usage
Running the MCP Server
source mcp_fin_server_venv/bin/activate
python3 financial_mcp_server.py
Batch Analysis
Analyze all portfolios and generate reports:
python3 batch_fin_mcp_server.py
Results are saved to batch_financial_charts/
Send Email Reports
python3 email_report_script.py
Track Recommendations
python3 daily_tracking_script.py
Results are saved to tracking_charts/
MCP Tools
The server provides these tools for Claude Code integration:
load_portfolio- Load portfolio data from portfolio.jsonanalyze_portfolio- Detailed analysis of specific portfolioportfolio_performance- Performance metrics over timeget_stock_info- Comprehensive stock informationget_earnings_calendar- Upcoming earnings announcementsget_analyst_changes- Recent analyst upgrades/downgradesgenerate_macd_chart- MACD technical analysis chartsget_market_overview- Major market indices status
Trading Scenarios
The batch analyzer identifies 4 key trading scenarios:
- Scenario A: Price >10% above 50 EMA → SELL signal
- Scenario B: Price above 50 EMA, touched recently → BUY signal
- Scenario C: Price >5% below 50 EMA, decreasing 3+ days, above 200 EMA → BUY signal
- Scenario D: Price below 50 EMA, touched 200 EMA recently → BUY signal
Technical Analysis
- Trend Detection: Golden Cross / Death Cross analysis
- EMAs: 50-day and 200-day exponential moving averages
- MACD: Moving Average Convergence Divergence charts
- Volume Analysis: Trading volume patterns
- Confidence Scores: Each recommendation includes confidence level
Project Structure
finance_mcp_server/
├── financial_mcp_server.py # Main MCP server
├── batch_fin_mcp_server.py # Batch analysis engine
├── email_report_script.py # Email automation
├── daily_tracking_script.py # Performance tracking
├── portfolio.json # Portfolio configuration
├── requirements.txt # Python dependencies
├── clean_requirements.txt # Cleaned dependencies
├── CLAUDE.md # AI assistant guidance
├── mcp-http-bridge/ # HTTP bridge for MCP
├── batch_financial_charts/ # Generated analysis charts
└── tracking_charts/ # Performance tracking charts
Requirements
- Python 3.8+
- yfinance (free Yahoo Finance API)
- pandas, numpy, matplotlib
- MCP SDK (mcp>=1.0.0)
Disclaimer
⚠️ This software is for informational purposes only. It does not constitute financial advice. Always do your own research before making investment decisions.
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions, please open an issue on GitHub.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.