A newer version of the Gradio SDK is available:
5.33.1
metadata
title: MCP Stock Analysis Hackathon
emoji: π
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.33.0
app_file: app.py
pinned: false
license: mit
π MCP Stock Analysis - Hackathon Entry
Hugging Face Gradio MCP Hackathon Submission
A distributed Model Context Protocol (MCP) implementation for real-time stock analysis, showcasing the power of connecting Gradio frontends with cloud-hosted MCP servers.
π Hackathon Details
- Event: Hugging Face Gradio MCP Hackathon
- Track: Track 1: MCP Tool / Server
- Submission Date: 10th June 2025
ποΈ Architecture
βββββββββββββββββββββββ HTTP/JSON ββββββββββββββββββββββββ
β Gradio Frontend β βββββββββββββββΊ β Modal MCP Server β
β (Hugging Face) β REST API β (Backend) β
β β β β
β - User Interface β β - MCP Protocol β
β - Stock Lookup β β - Stock Analysis β
β - Results Display β β - yfinance Data β
βββββββββββββββββββββββ ββββββββββββββββββββββββ
β¨ Features
π MCP Tools Available
- Stock Price Lookup - Real-time price, market cap, and company info
- Comprehensive Analysis - Investment scoring with buy/hold/sell recommendations
- Smart Ticker Search - Company name to ticker symbol conversion
π User Interface
- Intuitive Gradio Interface - Easy-to-use web interface
- Real-time Data - Live stock market information
- Error Handling - Robust error handling and user feedback
- Multiple Views - Tabbed interface for different functionalities
π οΈ Technical Implementation
- MCP Protocol - Full Model Context Protocol implementation
- Cloud Architecture - Scalable backend on Modal
- RESTful API - Standard HTTP/JSON communication
- Real-time Data - Uses yfinance for live market data
π Live Demo
Try the live application: [Your Hugging Face Space URL]
Backend MCP Server: https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run
π Example Usage
Stock Symbols to Try:
- Tech: AAPL, GOOGL, MSFT, TSLA, META, NVDA
- Finance: JPM, BAC, WFC, GS
- Consumer: WMT, KO, PEP, NKE
Company Names:
- apple, microsoft, tesla, amazon, netflix, nvidia
π§ Technical Stack
Frontend (Gradio)
- Framework: Gradio 4.0+
- Hosting: Hugging Face Spaces
- Language: Python
- UI Components: Tabs, JSON displays, status indicators
Backend (Modal MCP Server)
- Framework: FastAPI + Modal
- Protocol: Model Context Protocol (MCP)
- Data Source: yfinance
- Analysis: Custom investment scoring algorithm
- Hosting: Modal cloud platform
π‘ API Endpoints
MCP Server Endpoints:
GET /health
- Server health checkGET /tools
- Available MCP tools discoveryPOST /call
- Execute MCP toolsGET /
- Server information
Tool Execution Format:
{
"name": "get_stock_price",
"arguments": {
"symbol": "AAPL"
}
}
π Hackathon Innovation
What Makes This Special:
- Distributed MCP Architecture - Build on Modal.Separates frontend and backend for scalability
- Cloud-Native Design - Leverages Modal for compute and HF Spaces for interface
- Real-World Application - Practical stock analysis with investment recommendations
- User-Friendly Interface - Makes MCP accessible to non-technical users
- Robust Error Handling - Graceful handling of network and data issues
MCP Protocol Demonstration:
- Tool Discovery - Dynamic loading of available tools
- Tool Execution - Remote tool execution via HTTP
- Error Handling - Proper error propagation and user feedback
- Real-time Communication - Live data exchange between components
π Development Workflow
- Backend Development - Modal MCP server with stock analysis tools
- API Testing - Validation of MCP protocol implementation
- Frontend Creation - Gradio interface development
- Integration Testing - End-to-end functionality verification
- Deployment - Production deployment on both platforms
π Investment Analysis Algorithm
The comprehensive analysis includes:
- YTD Return Calculation - Year-to-date performance analysis
- PE Ratio Evaluation - Price-to-earnings ratio assessment
- Scoring System - 0-100 investment score
- Recommendations - Buy/Hold/Sell suggestions based on analysis
π€ Contributing
This is a hackathon submission, but feedback and suggestions are welcome!
π License
MIT License - Feel free to use and modify for your own projects.
π Acknowledgments
- Hugging Face - For hosting the Gradio frontend and organizing the hackathon
- Modal - For providing cloud compute credits and hosting the MCP server
- yfinance - For real-time stock market data
- MCP Community - For the Model Context Protocol specification
Built with β€οΈ for the Hugging Face Gradio MCP Hackathon