An intelligent multi-agent system that automates stock market analysis, visualization and cloud storage using natural language queries. Built with CrewAI & AWS and integrated via Model Context Protocol (MCP) for seamless AI assistant integration.
Traditional stock market analysis requires:
- Manual data retrieval from multiple sources
- Complex code writing for data visualization
- Domain expertise in both finance and programming
- Time-consuming process from query to visualization
Users want to ask simple questions like "Show me Tesla's stock performance over the last 6 months" and get actionable insights without writing code or understanding financial APIs.
This project automates the entire stock analysis workflow using a multi-agent AI system:
- Natural Language Processing: Understands plain English queries about stocks
- Intelligent Parsing: Extracts stock symbols, timeframes, and analysis requirements
- Code Generation: Automatically creates production-ready Python visualization code
- Code Execution: Validates and executes code with error handling
- Seamless Integration: Works directly within AI assistants via MCP (Model Context Protocol)
Result: Users get professional-grade stock analysis and visualizations in seconds, just by asking.
- Natural Language Interface: Ask questions in plain English
- Automatic Visualization: Generates matplotlib charts and graphs
- Code Generation & Execution: Creates and runs Python code automatically
- Error Recovery: Agents fix code errors automatically
- MCP Integration: Works with Cursor, Claude Desktop, and other MCP-compatible tools
- AWS S3 Integration: Automatically uploads generated charts to cloud storage
- CrewAI: Multi-agent orchestration
- OpenAI GPT-4o-mini: Natural language understanding & code
- FastMCP: Fast Model Context Protocol framework for building MCP servers
- Pydantic: Type-safe query parsing
- AWS S3: Cloud storage for generated visualizations
crewai>=1.8.0- Multi-agent frameworkcrewai-tools>=1.8.0- Agent tools (CodeInterpreter, etc.)fastmcp>=2.12.5- MCP server frameworkpydantic>=2.11.10- Data validationpython-dotenv>=1.1.1- Environment managementboto3>=1.34.0- AWS SDK for S3 uploads
- Python 3.12+
- uv (recommended) or
pipandvenv - AWS Account with S3 access (Create one here)
- OpenAI API Key (Get one here)
- Cursor or another MCP-compatible client (optional, for integration)
git clone <repository-url>
cd MCP-Financial-Analyst# macOS
brew install uv
# Or via pip
pip install uv
# Or standalone installer
curl -LsSf https://astral.sh/uv/install.sh | sh# Using uv (recommended)
uv syncOr using traditional pip
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt # If you have one, or install manuallyCreate a .env file in the project root:
# Required
OPENAI_API_KEY=your_openai_api_key_here
AWS_ACCESS_KEY_ID=your_aws_access_key_id
AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
AWS_REGION=us-east-1
AWS_S3_BUCKET_NAME=your-bucket-nameAdd to your ~/.cursor/mcp.json:
{
"mcpServers": {
"financial-analyst": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/MCP-Financial-Analyst",
"run",
"server.py"
]
}
}
}After updating mcp.json, restart Cursor for changes to take effect.
- Go to AWS S3 Console
- Click "Create bucket"
- Name your bucket (e.g.,
financial-analyst-plots) - Select your region
- Keep default settings and create
- Go to AWS IAM Console
- Users → Create user
- Attach policy:
AmazonS3FullAccess(or a custom policy for least privilege) - Create access key (Application running outside AWS)
- Copy Access Key ID and Secret Access Key
AWS_ACCESS_KEY_ID=AKIA... AWS_SECRET_ACCESS_KEY=your_secret_key AWS_REGION=us-east-1 AWS_S3_BUCKET_NAME=financial-analyst-plots
- Start Cursor (or your MCP client)
- Ask natural language questions:
- "Show Tesla's stock performance over the last 6 months"
- "Compare Apple and Qualcomm stocks for the past year"
- "Analyze the trading volume of Nvidia stock for the last month"
The AI assistant will use the MCP tools (analyze_stock, save_code, execute_code) automatically.
Using uv (recommended)
uv run python financial_analyst_agent.pyOr with activated venv
source .venv/bin/activate
python financial_analyst_agent.py# Using uv
uv run fastmcp dev server.py# Or direct execution
uv run python server.pyThis project is licensed under the MIT License - see the LICENSE file for details.