finance_mcp_server

j1c4b/finance_mcp_server

3.2

If you are the rightful owner of finance_mcp_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A comprehensive Model Context Protocol (MCP) server for financial data analysis, portfolio management, and automated trading recommendations.

Tools
8
Resources
0
Prompts
0

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

  1. 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
  2. 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
  3. email_report_script.py - Email automation

    • Sends analysis results via email
    • Attaches charts and detailed reports
    • Saves buy recommendations for tracking
  4. 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.json
  • analyze_portfolio - Detailed analysis of specific portfolio
  • portfolio_performance - Performance metrics over time
  • get_stock_info - Comprehensive stock information
  • get_earnings_calendar - Upcoming earnings announcements
  • get_analyst_changes - Recent analyst upgrades/downgrades
  • generate_macd_chart - MACD technical analysis charts
  • get_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.