A comprehensive AI-powered financial analysis system that provides intelligent insights into your spending patterns, budget tracking, and financial recommendations using advanced MCP (Model Context Protocol) integration and Google Gemini AI.
This project has evolved from a basic financial chatbot to a comprehensive AI-powered financial analysis platform with enhanced MCP integration. The system processes real transaction data, provides intelligent insights, and generates professional visualizations.
- π€ AI-Powered Analysis - Google Gemini Pro integration for natural language processing
- π 7 Comprehensive Tools - Complete financial analysis toolkit
- π Professional Charts - 4 types of financial visualizations
- πΎ Real Transaction Data - 95 realistic financial transactions
- π― Smart Recommendations - AI-powered financial advice
- π± Interactive Interface - Natural language chatbot interface
mcp_ai_chatbot/
βββ π **CORE SYSTEM** (Current - Enhanced)
β βββ financial_mcp_server.py # π Enhanced MCP server (29KB, 659 lines)
β βββ enhanced_financial_client.py # π AI-powered client (19KB, 402 lines)
β βββ daily_transactions.csv # π Transaction dataset (8KB, 95 transactions)
β βββ demo_financial_analysis.py # π Comprehensive demo (10KB, 257 lines)
β
βββ π **TESTING & DEBUG** (Current - New)
β βββ test_chart_generation.py # π Chart testing (2.3KB)
β βββ debug_chart_generation.py # π Debug script (2.7KB)
β βββ show_charts.py # π Chart status (3.1KB)
β
βββ π **DOCUMENTATION** (Current - Enhanced)
β βββ ENHANCED_README.md # π Comprehensive guide (13KB)
β βββ IMPLEMENTATION_SUMMARY.md # π Implementation details (10KB)
β βββ QUICK_START.md # π Quick start guide (5KB)
β
βββ π **GENERATED ASSETS** (Current - Auto-generated)
β βββ charts/ # π Financial charts
β βββ category_breakdown.png # π Spending categories (180KB)
β βββ spending_trend.png # π Daily trends (202KB)
β βββ budget_vs_actual.png # π Budget comparison (145KB)
β βββ merchant_analysis.png # π Merchant analysis (113KB)
β
βββ π **CONFIGURATION** (Current - Shared)
β βββ config.json # β
API configuration (138B)
β βββ requirements.txt # β
Dependencies (337B)
β βββ venv/ # β
Virtual environment
β
βββ π **LEGACY SYSTEM** (Old - Deprecated)
βββ api_server.py # β Old FastAPI server (16KB)
βββ client/ # β Old client directory
βββ financial_data.json # β Old sample data (5.4KB)
βββ [other deprecated files...] # β Old documentation & tests
- Python 3.8 or higher
- Google Gemini API key
- Required Python packages (see
requirements.txt)
- Clone the repository
git clone <repository-url>
cd mcp_ai_chatbot- Install dependencies
pip3 install -r requirements.txt- Configure API key
# Edit config.json with your Google Gemini API key
{
"GOOGLE_API_KEY": "your-gemini-api-key-here"
}python3 enhanced_financial_client.pyExample Interaction:
π€ Enhanced Financial Wellness AI Chatbot
Loaded 95 transactions from daily_transactions.csv
Ask me anything about your finances! Examples:
β’ 'How much did I spend this month?'
β’ 'Show me my spending by category'
β’ 'Am I over budget in any categories?'
β’ 'Give me spending recommendations'
β’ 'What are my top merchants?'
β’ 'Generate a spending trend chart'
β’ Type 'quit' to exit
You: Show me my spending by category
Assistant: Analyzing your financial data...
I found 95 transactions totaling $14,515.99.
**Top 5 Transactions:**
1. Employer Inc - $2500.00 (Income) - 2024-01-01
2. Property Management - $1200.00 (Rent) - 2024-01-08
3. Internal Transfer - $500.00 (Savings) - 2024-01-05
4. Micro Center - $500.00 (Shopping) - 2024-01-28
5. Best Buy - $450.00 (Shopping) - 2024-01-24
python3 demo_financial_analysis.pyfrom financial_mcp_server import FinancialMCPServer
server = FinancialMCPServer()
result = server.get_spending_analysis()
print(result)- Size: 29KB (659 lines)
- Purpose: Core financial analysis engine
- Features:
- 7 comprehensive analysis tools
- Real-time transaction processing
- Professional chart generation
- Budget tracking and analysis
- Advanced filtering capabilities
- Size: 19KB (402 lines)
- Purpose: AI-powered interactive interface
- Features:
- Natural language query processing
- Google Gemini AI integration
- Smart date extraction and filtering
- Conversation memory
- Intelligent response formatting
- Size: 8KB (95 transactions)
- Features:
- 95 realistic financial transactions
- 10 spending categories
- 50+ unique merchants
- 31 days of transaction data
- Multiple transaction types
| Tool | Description | Example Query |
|---|---|---|
get_transactions() |
Filter and retrieve transactions | "Show me all grocery transactions" |
get_spending_analysis() |
Comprehensive spending breakdown | "How much did I spend this month?" |
get_budget_analysis() |
Budget vs actual comparison | "Am I over budget?" |
get_spending_recommendations() |
AI-powered financial advice | "Give me spending recommendations" |
get_merchant_analysis() |
Merchant spending patterns | "What are my top merchants?" |
get_trend_analysis() |
Time-based trend analysis | "Show me spending trends" |
generate_chart() |
Professional chart generation | "Generate a spending trend chart" |
- Category Breakdown - Pie chart of spending categories
- Spending Trend - Line chart of daily spending trends
- Budget vs Actual - Bar chart comparing budget to actual spending
- Merchant Analysis - Bar chart of top merchants by spending
CSV Data β Pandas DataFrame β Filtering/Analysis β JSON Response β Chart Generation β File Storage
User Query β Query Analysis β Tool Selection β MCP Tool Call β Response Formatting β AI Enhancement β Final Response
Chart Request β Data Filtering β Visualization Creation β File Saving β Path Return
The system automatically generates 4 types of professional financial charts:
- File:
charts/category_breakdown.png - Type: Pie chart
- Purpose: Shows spending distribution across categories
- File:
charts/spending_trend.png - Type: Line chart with markers
- Purpose: Displays daily spending patterns over time
- Features:
- Date range: January 1 - February 1, 2024
- Y-axis: Amount ($) from 0 to 1400
- Shows spending volatility and trends
- File:
charts/budget_vs_actual.png - Type: Bar chart
- Purpose: Compares budgeted vs actual spending
- File:
charts/merchant_analysis.png - Type: Bar chart
- Purpose: Shows top merchants by spending amount
# Test chart generation
python3 test_chart_generation.py
# Debug chart issues
python3 debug_chart_generation.py
# Show chart status
python3 show_charts.py-
ModuleNotFoundError: No module named 'plotly'
pip3 install plotly
-
API Key Issues
- Ensure
config.jsoncontains valid Google Gemini API key - Check API key permissions and quotas
- Ensure
-
Chart Generation Failures
- Verify
charts/directory exists - Check write permissions
- Ensure matplotlib/seaborn are installed
- Verify
- July 29, 2024: Original basic system
- July 31, 2024: Major enhancement with MCP server and AI client
- August 1, 2024: Chart generation fixes and testing tools
- Data Processing: CSV dataset vs JSON sample data
- Analysis Tools: 7 comprehensive tools vs basic operations
- User Interface: Natural language processing vs structured queries
- Visualization: 4 professional chart types vs basic graphs
- Documentation: Comprehensive guides vs basic setup instructions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip3 install -r requirements.txt
# Run tests
python3 test_chart_generation.pyThis project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini AI - For natural language processing capabilities
- MCP Protocol - For standardized tool interface
- Pandas & Matplotlib - For data processing and visualization
- FastAPI & Uvicorn - For web server capabilities
For questions, issues, or contributions:
- Create an issue on GitHub
- Check the documentation in
ENHANCED_README.md - Review
IMPLEMENTATION_SUMMARY.mdfor technical details
π Ready to transform your financial analysis with AI-powered insights!