A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.
Finagent - AI-Powered Financial Analysis Tool
A sophisticated financial analysis system that leverages Mistral Small 4 (mistral-small-latest) and real-time market data to provide comprehensive stock analysis, automated code generation, and investment insights.
Demo

Features
- Multi-Agent AI System: Specialized agents for query parsing, code generation, and market analysis
- Real-time Stock Data: Fetches live market data using Yahoo Finance
- Automated Code Generation: Creates executable Python code for financial analysis
- News Integration: Incorporates latest market news into analysis
- MCP Server: Modern Model Context Protocol server for Claude Desktop integration
- Professional Visualizations: Generates matplotlib charts and technical analysis plots
- Risk Assessment: Provides balanced investment recommendations with proper disclaimers
Prerequisites
- Python 3.8+
- Mistral API key (for the Mistral Small 4 / mistral-small-latest model)
- Claude Desktop (for MCP integration)
- Firecrawl API key (optional, for enhanced news features)
File Structure
finagent/
├── main.py # MCP server entry point
├── financial_agents.py # Core AI agents and analysis logic
├── .env # Environment variables (create this)
├── .env.example # Environment variables template
├── requirements.txt # Python dependencies
├── README.md # This file
└── logs/ # Log files (auto-created)
Installation
- Clone the repository:
git clone <your-repo-url>
cd finagent
- Install required packages:
pip install -r requirements.txt
- Set up environment variables:
Create a
.envfile in the project root:
MISTRAL_API_KEY=your_mistral_api_key_here
FIRECRAWL_API_KEY=your_firecrawl_api_key_here # Optional
API Keys Setup
Mistral API Key (Required)
- Visit Mistral Console
- Create a new API key
- Add it to your
.envfile
Firecrawl API Key (Optional)
- Sign up at Firecrawl
- Get your API key from the dashboard
- Add it to your
.envfile for enhanced news features
Claude Desktop Integration
Setup MCP Server with Claude Desktop
Install Claude Desktop:
- Download from Claude.ai
- Install and launch the application
Configure MCP Server:
Locate your Claude Desktop config file:
- MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- MacOS:
Add Finagent Server:
Edit the config file and add:
{ "mcpServers": { "financial-analyst": { "command": "python", "args": ["/absolute/path/to/finagent/main.py"], "env": { "MISTRAL_API_KEY": "your_mistral_api_key_here", "FIRECRAWL_API_KEY": "your_firecrawl_api_key_here" } } } }Replace
/absolute/path/to/finagent/main.pywith the actual path to your main.py file.Restart Claude Desktop:
- Quit Claude Desktop completely
- Relaunch the application
- The MCP server should now be available
Verify Connection:
In Claude Desktop, you should see the financial analysis tools available. Ask Claude:
Can you analyze Apple stock for me?
Available Tools in Claude Desktop
Once configured, Claude can use these tools:
- analyze_stock: Get comprehensive stock analysis with AI insights
- execute_code: Run generated Python analysis code
- get_news: Fetch latest market news for stocks
Example Conversations with Claude Desktop
You: Analyze Tesla stock performance over the last 6 months
Claude: I'll analyze Tesla stock for you using the financial analysis tool...
[Uses analyze_stock tool]
You: What's the latest news on NVDA?
Claude: Let me fetch the latest news for NVIDIA...
[Uses get_news tool]
You: Can you execute this analysis code for me?
Claude: I'll run that code using the execution tool...
[Uses execute_code tool]
Usage
As MCP Server (Standalone)
Start the MCP server manually:
python main.py
Direct Python Usage
from financial_agents import FinancialAnalysisTeam
team = FinancialAnalysisTeam(
mistral_api_key="your_mistral_key"
)
result = team.analyze("Analyze Apple stock over the last 6 months")
print(result)
Example Queries
The system understands natural language queries:
- "Analyze Tesla stock performance over the last 3 months"
- "Compare Apple and Microsoft stocks this year"
- "Technical analysis of NVDA with RSI and MACD indicators"
- "What's the current sentiment on Bitcoin?"
- "Show me the latest news for Amazon stock"
Architecture
Core Components
- FinancialAnalysisTeam: Main orchestrator class
- MistralAgent: Base agent class using Mistral Small 4 (mistral-small-latest)
- FinancialTools: Data acquisition utilities
- MCP Server: Model Context Protocol server for Claude Desktop
Agent Specialization
- Query Parser: Extracts symbols, timeframes, and analysis requirements
- Code Generator: Creates executable Python analysis scripts
- Market Analyst: Provides professional investment insights and recommendations
Generated Analysis Includes
- Technical Indicators: RSI, MACD, Moving averages, Bollinger bands
- Price Analysis: Trend analysis, support/resistance levels
- Risk Metrics: Volatility calculations, drawdown analysis
- Visualizations: Professional charts with technical overlays
- News Integration: Latest market sentiment and news impact
- Investment Recommendations: Buy/Hold/Sell with rationale
Important Disclaimers
- This tool is for educational and research purposes only
- All analysis and recommendations are not financial advice
- Always consult with qualified financial advisors before making investment decisions
- Past performance does not guarantee future results
Troubleshooting
Common Issues
MCP Server Not Showing in Claude Desktop:
- Verify the config file path is correct
- Check that Python path in config is valid
- Ensure main.py path is absolute, not relative
- Restart Claude Desktop completely
Import Errors:
pip install -r requirements.txt
API Key Issues:
- Verify your
.envfile is in the project root - Check API keys are valid and properly formatted
- Ensure environment variables are set in Claude Desktop config
- Verify your
Data Fetching Errors:
- Check internet connection
- Verify ticker symbol validity
- Yahoo Finance may have rate limits
Code Execution Timeout:
- Large datasets may require increased timeout values
- Check for infinite loops in generated code
Debug Mode
To enable detailed logging:
export LOG_LEVEL=DEBUG
python main.py
Security
- Never commit API keys to version control
- Use environment variables for all sensitive configuration
- Regularly rotate API keys
- Monitor API usage and costs
- Keep Claude Desktop config file secure
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For questions and support:
- Open an issue on GitHub
- Check the troubleshooting section above
- Review the example queries for proper usage patterns
Made with Mistral Small 4 & Claude Desktop