Agent AI Personal Financial Advisor
An example personal financial advisor application to demonstrate the use of Agentic AI protocols such as MCP, A2A and ACP
Ask AI about Agent AI Personal Financial Advisor
Powered by Claude ยท Grounded in docs
I know everything about Agent AI Personal Financial Advisor. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
๐ฆ AI Personal Financial Advisor
An educational Agentic AI application that provides personalized financial advice using Google's Agent Development Kit (ADK). This application demonstrates multi-agent collaboration, MCP (Model Context Protocol) integration, and modern AI-powered financial analysis.
๐ฏ Purpose
This application was built for an Agentic AI class to demonstrate:
- Multi-agent systems using Google ADK
- MCP integration for database operations
- Agent-to-agent collaboration through built-in ADK mechanisms
- Real-world AI application in financial advisory
๐ Current Implementation Status
โ Fully Implemented & Functional:
- ADK Web Agent System - 6 specialized agents working in both Streamlit and ADK Web
- Sequential Multi-Agent Analysis - Full analysis using SequencerAgent with step-by-step coordination
- MCP database server with 8 tools for MySQL operations and JSON-RPC 2.0 protocol
- Comprehensive Streamlit UI with 4 main tabs and real-time data
- Real database integration - All UI components use live MySQL data
- Dynamic customer selection from database
- Comprehensive test suite with 6 test files and 128 test methods covering all components
- Production-ready framework with robust error handling and logging
โ Database Integration Complete:
- Customer profiles loaded dynamically from database
- Real transaction data with 6-table schema (customers, transactions, goals, advice, interactions, categories)
- Live financial goals and progress tracking
- Advice history from AI agents
- Savings trend charts with real monthly data
- Multi-customer support with seamless switching
โ AI Agent System Complete:
- ADK Web Agents - 6 specialized agents working in both Streamlit and ADK Web
- Sequential Multi-Agent Analysis - Full analysis using SequencerAgent with step-by-step coordination
- Direct ADK Integration - Streamlit UI uses ADK Web agents directly without modification
- LLM Integration - Gemini 2.0 Flash API fully connected and working
- Event-Driven Architecture - Proper ADK Event creation and handling
- Session State Management - Data sharing between agents via ADK session state
- MCP Tool Integration - Agents use database tools via MCP protocol
๐ค AI Agents
The application uses 6 specialized ADK Web agents that work in both Streamlit and ADK Web environments:
StandaloneAgent
- Pure MCP-only financial advisor
- Provides quick financial analysis without orchestration
- Direct database access via MCP tools
- Ideal for simple, fast analysis requests
SequencerAgent
- Step-by-step multi-agent coordination
- Orchestrates Spending Analyzer โ Goal Planner โ Advisor
- Sequential workflow for comprehensive analysis
- Used for full financial analysis in Streamlit UI
OrchestratorAgent
- Intelligent LLM-driven coordination
- Advanced multi-agent orchestration
- Dynamic agent selection and coordination
- Handles complex analysis workflows
SpendingAnalyzerAgent
- Analyzes customer spending habits and patterns
- Categorizes expenses (fixed vs variable costs)
- Identifies spending trends and anomalies
- Provides spending optimization insights
GoalPlannerAgent
- Evaluates financial goal feasibility
- Creates realistic savings/investment plans
- Tracks progress toward goals
- Suggests goal prioritization and adjustments
AdvisorAgent
- Synthesizes insights from other agents
- Generates comprehensive financial recommendations
- Prioritizes advice based on urgency and impact
- Provides clear explanations and action steps
๐ Technology Stack
- AI Framework: Google Agent Development Kit (ADK) โฅ1.13.0
- Language: Python 3.11
- LLM: Gemini 2.0 Flash Experimental (cost-effective, supports tool calling)
- Database: MySQL with MCP toolset integration
- UI: Streamlit โฅ1.49.0
- Agent Communication: Built-in ADK multi-agent capabilities
- Data Visualization: Plotly โฅ6.3.0
๐ Architecture
Unified ADK Agent System
The application uses a unified architecture where the same ADK Web agents work in both Streamlit and ADK Web environments:
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Streamlit UI โ โ ADK Web Agents โ โ MCP Database โ
โ โ โ (Unified) โ โ Server โ
โ - Dashboard โโโโโบโ โโโโโบโ โ
โ - Transactions โ โ โโโโโโโโโโโโโโโโ โ โ - MySQL Tools โ
โ - Goals โ โ โ Sequencer โ โ โ - JSON-RPC 2.0 โ
โ - Recommendationsโ โ โ Agent โ โ โ - CRUD Ops โ
โโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโ
โ โโโโโโโโโโโโโโโโ โ
โ โ Standalone โ โ
โ โ Agent โ โ
โ โโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ Orchestrator โ โ
โ โ Agent โ โ
โ โโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ Spending โ โ
โ โ Analyzer โ โ
โ โโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ Goal โ โ
โ โ Planner โ โ
โ โโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ Advisor โ โ
โ โ Agent โ โ
โ โโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโ
๐ Prerequisites
- Python 3.11 (specific version required)
- MySQL Server (local or remote)
- Google AI Studio API Key (for Gemini model access)
โก Quick Start
Option 1: Streamlit UI (Educational Focus)
# 1. Setup environment
python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 2. Configure .env file
# Make sure your .env file has valid GOOGLE_API_KEY and DB credentials
# 3. Setup database (if using MySQL)
# Create database and run schema.sql
# 4. Run Streamlit UI
streamlit run streamlit_app.py
# Access at http://localhost:8501
Option 2: ADK Web (Multi-Agent Focus)
# 1. Setup environment (same as above)
python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 2. Configure .env file (same as above)
# 3. Setup database (same as above)
# 4. Run ADK Web
adk web agents
# Access at http://localhost:8080
# Select an agent and start chatting!
Option 3: Both (Recommended for Learning)
# Terminal 1: Streamlit UI
source venv/bin/activate
streamlit run streamlit_app.py
# Terminal 2: ADK Web
source venv/bin/activate
adk web agents
# Access both:
# Streamlit: http://localhost:8501
# ADK Web: http://localhost:8080
๐ Detailed Installation & Setup
1. Clone and Setup Environment
# Clone the repository
git clone <repository-url>
cd agent-ai-personal-financial-advisor
# Create Python 3.11 virtual environment
python3.11 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
2. Database Setup
# Start MySQL server
# Create database
mysql -u root -p
CREATE DATABASE financial_advisor;
USE financial_advisor;
# Run schema creation
mysql -u root -p financial_advisor < database/schema.sql
# Load sample data (optional)
mysql -u root -p financial_advisor < database/sample_data.sql
3. Environment Configuration
The .env file should contain:
# Google AI Configuration
GOOGLE_API_KEY=your_google_ai_studio_api_key
# MySQL Database Configuration
DB_HOST=localhost
DB_PORT=3306
DB_NAME=financial_advisor
DB_USER=root
DB_PASSWORD=your_mysql_password
# Application Configuration
APP_DEBUG=True
APP_LOG_LEVEL=INFO
4. Test MCP Database Server
# Test the MCP server
python mcp_server/database_server.py
๐ฎ Running the Application
Option 1: Streamlit UI (Educational Focus)
Start the Streamlit Application
# Make sure virtual environment is activated
source venv/bin/activate
# Run the Streamlit application
streamlit run streamlit_app.py
The application will be available at http://localhost:8501
Option 2: ADK Web (Advanced Multi-Agent)
Start ADK Web for Multi-Agent Interactions
# Make sure virtual environment is activated
source venv/bin/activate
# Start ADK Web with the agents directory
adk web agents
ADK Web will be available at http://localhost:8080
Available ADK Web Agents:
- Standalone - Pure MCP-only financial analysis in one step with direct database access
- Orchestrator - Intelligent LLM-driven coordination of specialized agents
- Sequencer - Step-by-step sequential execution of all specialized agents
- Spending Analyzer - Specialized spending pattern analysis and optimization
- Goal Planner - Specialized financial goal planning and feasibility analysis
- Advisor - Financial advice synthesis and recommendation generation
Using ADK Web:
- Navigate to
http://localhost:8080 - Select an agent from the dropdown
- Start a conversation with the agent
- Agents will use MCP tools to access the database
- Experience real multi-agent interactions and orchestration
Using the Application
Streamlit UI (Educational Focus)
- Select a Customer from the sidebar (dynamically loaded from database)
- Explore Financial Data across 4 main tabs:
- ๐ Profile & Overview: Financial health score, savings trends, spending analysis
- ๐ฐ Transactions: Add, view, and filter financial transactions
- ๐ฏ Goals: Set, track, and update financial goals with progress bars
- ๐ค AI Recommendations: View advice history and run AI analysis
- Run AI Analysis using the analysis button:
- ๐ Full Analysis: Complete financial analysis with real AI agents
- Real-time Data: All data is loaded live from MySQL database
- Multi-Customer Support: Switch between different customer profiles seamlessly
ADK Web (Advanced Multi-Agent)
- Choose Your Agent from the dropdown:
- Financial Advisor: Direct conversation with comprehensive financial advisor
- Procedural Orchestrator: Watch step-by-step multi-agent coordination
- Intelligent Orchestrator: Experience AI-driven dynamic orchestration
- Start Conversations: Chat directly with agents using natural language
- Multi-Agent Interactions: See agents collaborate and delegate tasks
- Real Database Access: Agents use MCP tools to query and update data
- Advanced Orchestration: Experience different orchestration patterns
๐ฏ Choosing Your Approach
Use Streamlit UI when:
- Learning about financial data visualization
- Understanding database integration patterns
- Exploring UI/UX design with real data
- Educational demonstrations and presentations
Use ADK Web when:
- Learning about multi-agent systems
- Understanding agent orchestration patterns
- Exploring conversational AI interfaces
- Advanced multi-agent interactions and coordination
๐งช Testing the Application
System Status Check
The Streamlit app includes a system status checker in the sidebar that verifies:
- โ Database connection
- โ MCP server file availability
- โ Agent system status
Testing Both Approaches
Test Streamlit UI:
# Start Streamlit
source venv/bin/activate
streamlit run streamlit_app.py
# Test analysis buttons
# 1. Navigate to http://localhost:8501
# 2. Select a customer
# 3. Go to "AI Recommendations" tab
# 4. Click "Full Analysis"
# 5. Verify agents execute and provide real recommendations
Test ADK Web:
# Start ADK Web
source venv/bin/activate
adk web agents
# Test multi-agent interactions
# 1. Navigate to http://localhost:8080
# 2. Select "Procedural Orchestrator" from dropdown
# 3. Ask: "Analyze customer 1's spending patterns"
# 4. Watch agents collaborate and use MCP tools
# 5. Try "Intelligent Orchestrator" for dynamic coordination
Manual Testing
-
Test Database Connection:
source venv/bin/activate python -c "from utils.database import test_database_connection; print('โ Success' if test_database_connection() else 'โ Failed')" -
Test MCP Server:
python mcp_server/database_server.py -
Test ADK Web Agents:
from agents.standalone.agent import agent as standalone_agent from agents.sequencer.agent import agent as sequencer_agent from agents.orchestrator.agent import agent as orchestrator_agent # Test agent creation mcp_path = "mcp_server/database_server_stdio.py" # Agents are already configured and ready to use -
Test ADK Agent Manager:
from utils.adk_agent_manager import ADKAgentManager manager = ADKAgentManager(mcp_server_path="mcp_server/database_server_stdio.py") status = manager.get_agent_status()
Automated Tests
# Run unit tests
python -m pytest tests/ -v
# Run specific test files
python -m pytest tests/test_streamlit_integration.py -v
๐ Features Demonstrated
ADK Concepts
- โ LlmAgent: Core intelligent agents with Gemini 2.0 Flash Experimental
- โ SequentialAgent: Built-in ADK orchestration for step-by-step execution
- โ MCPToolset: Database operations via MCP protocol
- โ AgentTool: Agent-to-agent delegation
- โ Session State: Data sharing between agents
- โ Multi-agent Coordination: Hierarchical agent structure
Financial Features
- โ Spending Analysis: Pattern recognition and optimization with real transaction data
- โ Goal Planning: Feasibility analysis and savings plans with live progress tracking
- โ Comprehensive Advice: Prioritized recommendations from AI agents
- โ Progress Tracking: Real-time goal and savings monitoring
- โ Data Visualization: Interactive charts and dashboards with live data
- โ Multi-Customer Support: Seamless switching between different customer profiles
- โ Dynamic Data Loading: All financial data loaded from MySQL database in real-time
Technical Features
- โ MCP Integration: Enterprise-grade database access via FastMCP
- โ Modern UI: Responsive Streamlit interface with real-time data
- โ Error Handling: Comprehensive error management and user feedback
- โ Logging: Detailed application logging with configurable levels
- โ Type Safety: Pydantic models and Python type hints throughout
- โ Database Client: Direct database access for UI components
- โ Data Persistence: Full CRUD operations for all financial data
- โ Real-time Updates: Live data refresh and dynamic UI updates
๐ Project Structure
agent-ai-personal-financial-advisor/
โโโ .env # Environment variables
โโโ requirements.txt # Python dependencies
โโโ streamlit_app.py # Main Streamlit application
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ database/
โ โโโ schema.sql # Database schema with all tables
โ โโโ sample_data.sql # Sample data for testing
โโโ mcp_server/ # MCP Database Server
โ โโโ database_server.py # FastMCP server
โ โโโ database_server_stdio.py # STDIO server with JSON-RPC 2.0
โ โโโ shared/ # DRY shared components
โ โ โโโ __init__.py
โ โ โโโ business_logic.py # Business logic functions
โ โ โโโ config.py # Configuration management
โ โ โโโ database_manager.py # Database operations
โ โ โโโ models.py # Data models
โ โโโ README.md # MCP server documentation
โโโ agents/ # ADK Web Agent System
โ โโโ standalone/ # Standalone financial advisor agent
โ โโโ sequencer/ # Sequential multi-agent orchestrator
โ โโโ orchestrator/ # Intelligent multi-agent orchestrator
โ โโโ spending_analyzer/ # Spending analysis specialist
โ โโโ goal_planner/ # Financial goal planning specialist
โ โโโ advisor/ # Financial advice synthesis specialist
โ โโโ README.md # ADK Web documentation
โโโ ui/
โ โโโ components/ # UI components
โ โโโ customer_profile.py # Customer profile & financial overview
โ โโโ transaction_entry.py # Transaction management
โ โโโ goal_management.py # Goal setting & tracking
โ โโโ recommendations.py # AI recommendations & analysis
โโโ utils/
โ โโโ database.py # Database connection utilities
โ โโโ database_client.py # Direct database access for UI
โ โโโ logging_config.py # Logging configuration
โ โโโ adk_agent_manager.py # ADK agent management for Streamlit
โโโ tests/ # Comprehensive test suite
โโโ __init__.py
โโโ README.md # Testing documentation
โโโ test_agents.py # ADK Web agent tests
โโโ test_adk_agent_manager.py # ADK agent manager tests
โโโ test_mcp_server.py # MCP server tests
โโโ test_utils.py # Utility function tests
โโโ test_ui_components.py # UI component tests
โโโ test_streamlit_integration.py # Streamlit integration tests
โโโ run_tests.py # Test runner script
โโโ README.md # Testing documentation
๐ Educational Value
This application demonstrates key concepts students need to master:
ADK Core Concepts
- LlmAgent Creation: How to create intelligent agents with Gemini 2.0 Flash Experimental
- SequentialAgent: Built-in ADK orchestration for step-by-step agent execution
- Multi-Agent Systems: Hierarchical agent structures with
sub_agents - Session State Management: Data sharing between agents via ADK session state
- AgentTool Integration: Using agents as tools for delegation
MCP Integration Patterns
- MCPToolset Usage: Connecting agents to external services via MCP protocol
- Database MCP Server: Building enterprise-grade database access tools
- Tool Discovery: How ADK automatically discovers and adapts MCP tools
- Connection Management: Proper MCP server lifecycle management
Real-World Implementation
- Financial Domain Modeling: Practical AI application in finance
- Agent Specialization: Designing agents with focused responsibilities
- Collaborative Workflows: Agents working together to solve complex problems
- User Interface Integration: Connecting AI agents to user-facing applications
- Error Handling & Logging: Production-ready code practices
Code Quality & Best Practices
- Type Safety: Using Pydantic models and Python type hints
- Documentation: Comprehensive code comments and docstrings
- Project Structure: Modular, maintainable codebase organization
- Testing Strategies: Unit and integration testing approaches
๐ง Troubleshooting
Common Issues
-
Database Connection Failed:
- Check MySQL server is running
- Verify credentials in
.envfile - Ensure database exists
-
Google API Key Issues:
- Verify API key is valid
- Check Google AI Studio quota
- Ensure key has proper permissions
-
MCP Server Not Found:
- Verify
mcp_server/database_server.pyexists - Check file permissions
- Ensure FastMCP is installed correctly
- Verify
-
Import Errors:
- Ensure you're running from the project root directory
- Verify virtual environment is activated
- Check PYTHONPATH includes project root
- Use
python run_app.pyif direct streamlit command fails - All imports are now working correctly with proper path setup
-
Agent Initialization Failed:
- Ensure MCP server is accessible
- Check network connectivity
- Verify all required environment variables
- Check Google API key is valid
-
Streamlit Import Issues:
- Run
streamlit run streamlit_app.pyfrom project root - Avoid running from subdirectories
- Ensure all
__init__.pyfiles exist in package directories - Fixed: All import issues resolved with proper path configuration
- Run
-
Database Integration Issues:
- Fixed: All UI components now use real database data
- Fixed: Customer list dynamically loaded from database
- Fixed: Savings trend charts show real monthly data
- Fixed: Date parsing and Decimal type issues resolved
-
ADK Web Issues:
- Agents Not Showing: Make sure to run
adk web agents(with the agents directory parameter) - Agent Not Found: Ensure you're in the project root directory when running
adk web - MCP Server Timeout: Check that
mcp_server/database_server_stdio.pyis accessible - Agent Import Errors: Verify virtual environment is activated and all dependencies installed
- Database Connection: Ensure MySQL server is running and credentials are correct
- Agent Selection: Use the dropdown to select from available agents (Financial Advisor, Procedural Orchestrator, Intelligent Orchestrator)
- Agents Not Showing: Make sure to run
Debug Mode
Enable debug logging by setting in .env:
APP_DEBUG=True
APP_LOG_LEVEL=DEBUG
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฏ Application Status
The Personal Financial Advisor application is a fully functional AI-powered financial advisor ready for advanced features like streaming responses, additional specialized agents, and deployment to production environments.
๐ Future Enhancement Ideas
This application provides a solid foundation for students to explore advanced AI concepts:
Beginner Enhancements
- Add More Categories: Expand spending categories and subcategories
- Improve UI: Add more charts and better styling
- Add Validation: Implement form validation and error handling
- Custom Dashboards: Create personalized financial dashboards
Intermediate Enhancements
- Goal Recommendations: Implement AI-powered goal suggestions
- Export Features: Add PDF reports and data export
- Advanced Analytics: Add more sophisticated financial metrics
- Notification System: Implement alerts for spending limits and goal milestones
Advanced Enhancements
- Streaming Responses: Implement real-time agent streaming
- Multi-User Support: Add user authentication and multi-tenancy
- External Integrations: Connect to bank APIs or financial services
- Deployment: Deploy to Cloud Run or Vertex AI Agent Engine
- Additional Agents: Create specialized agents (Investment, Debt Management)
- Performance Optimization: Add caching and performance monitoring
Learning Exercises
- Create New Agents: Build specialized agents (e.g., InvestmentAdvisor, DebtManager)
- Custom Tools: Develop new MCP tools for external APIs
- Workflow Agents: Experiment with SequentialAgent, ParallelAgent patterns
- Advanced Orchestration: Implement conditional agent execution logic
๐ค Contributing
This is an educational project. Contributions are welcome for:
- Additional agent capabilities
- UI improvements
- Test coverage
- Documentation enhancements
๐ Acknowledgments
- Google Agent Development Kit for the AI agent framework
- Google AI Studio for Gemini model access
- Streamlit for the web application framework
- FastMCP for simplified MCP server implementation
