metadata
title: Spend Analyzer MCP
emoji: ⚡
colorFrom: yellow
colorTo: pink
sdk: gradio
sdk_version: 5.33.0
app_file: app.py
pinned: false
license: apache-2.0
short_description: Finance MCP to Analyze Finance Statement (Email, PDF)
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Spend Analyzer MCP
A comprehensive financial analysis tool that processes bank statements from emails or uploaded PDFs, analyzes spending patterns, and provides AI-powered financial insights through a Model Context Protocol (MCP) interface.
Features
- 📧 Email Processing: Automatically fetch and process bank statements from your email
- 📄 PDF Upload: Direct upload and analysis of bank statement PDFs
- 📊 Analysis Dashboard: Interactive charts and financial summaries
- 🤖 AI Financial Advisor: Chat with Claude for personalized financial advice
- ⚙️ Settings & Configuration: Customize budgets, email settings, and export options
- 🔐 Security: Password-protected PDF support and secure email connections
Architecture
The project consists of several key components:
gradio_interface.py
- Main web interface built with Gradiospend_analyzer.py
- Core financial analysis engineemail_processor.py
- Email and PDF processing functionalitymodal_deployment.py
- Modal.com cloud deployment configurationmcp_server.py
- Model Context Protocol server implementation
Installation
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
# Create .env file
ANTHROPIC_API_KEY=your_claude_api_key
[email protected]
EMAIL_PASS=your_app_password
IMAP_SERVER=imap.gmail.com
- For Modal deployment (optional):
modal token new
modal deploy modal_deployment.py
Usage
Local Development
Run the Gradio interface locally:
python gradio_interface.py
The interface will be available at http://localhost:7860
Features Overview
Email Processing Tab
- Connect to Gmail, Outlook, or Yahoo email
- Automatically scan for bank statement PDFs
- Handle password-protected documents
- Process statements from the last 7-90 days
PDF Upload Tab
- Direct upload of bank statement PDFs
- Support for multiple files
- Password protection handling
- Instant analysis and processing
Analysis Dashboard
- Financial summary cards (income, expenses, cash flow)
- Interactive spending category charts
- Monthly trend analysis
- Budget alerts and recommendations
- Detailed transaction tables
AI Financial Advisor
- Chat with Claude about your spending patterns
- Quick question buttons for common queries
- Contextual responses based on your data
- Personalized financial recommendations
Settings
- Budget Settings: Set monthly limits by category
- Email Settings: Configure email providers and auto-processing
- Export Settings: Choose data export formats (JSON, CSV, Excel)
MCP Integration
This project implements the Model Context Protocol (MCP) for integration with Claude and other AI systems:
- Tools: Process statements, analyze PDFs, get AI insights
- Resources: Access financial data and analysis results
- Server: Full MCP server implementation for external integrations
Security Considerations
- Email passwords should use app-specific passwords
- PDF passwords are handled securely in memory
- No financial data is stored permanently by default
- All processing can be done locally or in secure cloud environments
Development
Project Structure
spend-analyzer-mcp/
├── gradio_interface.py # Main web interface
├── spend_analyzer.py # Financial analysis engine
├── email_processor.py # Email/PDF processing
├── modal_deployment.py # Cloud deployment
├── mcp_server.py # MCP protocol server
├── requirements.txt # Dependencies
└── README.md # This file
Key Classes
SpendAnalyzerInterface
: Main Gradio interface controllerSpendAnalyzer
: Core financial analysis and insightsEmailProcessor
: Email connection and PDF extractionPDFProcessor
: Bank statement PDF parsingMCPServer
: Model Context Protocol implementation
Extending the System
- Add New Banks: Extend parsing patterns in
PDFProcessor
- Custom Categories: Modify categorization logic in
SpendAnalyzer
- New Charts: Add visualization functions to the dashboard
- AI Prompts: Enhance Claude integration in
modal_deployment.py
Deployment Options
Local Deployment
- Run directly with Python
- All processing happens locally
- Suitable for development and testing
Modal.com Deployment
- Serverless cloud deployment
- Scalable processing
- Integrated with Claude API
- Production-ready
Docker Deployment
FROM python:3.11-slim
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 7860
CMD ["python", "gradio_interface.py"]
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is open source. Please ensure you comply with your bank's terms of service when processing financial data.
Support
For issues and questions:
- Check the existing issues
- Create a new issue with detailed information
- Include error logs and system information
Roadmap
- Support for more bank formats
- Real-time transaction monitoring
- Mobile app interface
- Advanced ML-based categorization
- Integration with financial planning tools
- Multi-currency support
- Automated bill tracking