A sophisticated Model Context Protocol (MCP) agent that provides advanced weather forecasting capabilities using machine learning models, real-time weather data, and multiple AI tools integrated through the MCP framework.
This project implements a powerful weather forecasting system that combines:
- Real-time weather data from WeatherAPI
- Machine learning models for advanced predictions
- Multiple AI tools (crypto, web search, Wikipedia, etc.)
- MCP (Model Context Protocol) for seamless tool integration
- Groq AI for natural language processing
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Client Side βββββΊβ MCP Server βββββΊβ AI Services β
β (Groq + MCP) β β (FastMCP) β β (APIs & Models) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β User Interface β β Tool Manager β β External APIs β
β & Queries β β & Registry β β & ML Models β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
MCPAgent/
βββ π ClientSide-SSE-MCP.py # Main client application
βββ π ServerSideMCP.py # MCP server entry point
βββ π MCPTools/ # Core tools and services
β βββ π server.py # FastMCP server configuration
β βββ π get_weather/ # Weather data processing
β β βββ π getweather.py # Weather API integration
β βββ π loader/ # ML models and API clients
β β βββ π loader.py # Resource loader
β β βββ π ML-models/ # Pre-trained ML models
β β βββ π€ voting_regressor.joblib
β β βββ π§ feature_scaler.joblib
β β βββ π§ target_scaler.joblib
β βββ π tools/ # Available MCP tools
β βββ π€οΈ weather.py # Weather forecasting
β βββ π° trade.py # Cryptocurrency data
β βββ π web_search.py # Web search capabilities
β βββ π wiki.py # Wikipedia integration
β βββ π manga.py # Manga information
β βββ π ping.py # System utilities
β βββ π οΈ utils.py # Helper functions
βββ π .gitignore # Git ignore rules
βββ π .env.example # Environment variables template
- Python 3.8+
- pip package manager
- API keys for various services
git clone <repository-url>
cd MCPAgent
pip install -r requirements.txt # You may need to create thispip install mcp
pip install groq
pip install pandas
pip install requests
pip install joblib
pip install python-dotenv
pip install tavily-python
pip install firecrawl-py
pip install openaiCreate a .env file with the following API keys:
# AI Services
GROQ_API_KEY_2=your_groq_api_key_here
OPENROUTER=your_openrouter_api_key
# Weather Service
WEATHER_API_KEY=your_weatherapi_key
# Search Services
TAVILY_API_KEY=your_tavily_key
GOOGLE_SEARCH_API_KEY=your_google_search_key
PROGRAMMABLE_SEARCH_ENGINE_ID=your_search_engine_id
FIRECRAWL_SANE_API=your_firecrawl_key
# Financial Data
ALPHAVANTAGE_API=your_alphavantage_key| Service | Description | How to Get |
|---|---|---|
| Groq | Fast AI inference | groq.com β Console β API Keys |
| WeatherAPI | Weather data | weatherapi.com β Free tier available |
| Tavily | AI search | tavily.com β Sign up for API |
| Firecrawl | Web scraping | firecrawl.dev β Get API key |
| Google Search | Custom search | Google Cloud Console β Custom Search API |
| AlphaVantage | Financial data | alphavantage.co β Free API key |
# Run the MCP server
python run.py"What's the weather like in London?"
"Give me a 5-day forecast for New York"
"Show me hourly weather for tomorrow in Paris"
"What's the air quality in Tokyo right now?"
"What's the current Bitcoin price?"
"Show me Ethereum trading data"
"Search for recent climate change news"
"Find information about machine learning in weather prediction"
"What's happening with renewable energy stocks?"
"Tell me about meteorology from Wikipedia"
"Search for the latest manga releases"
get_weather()- Current weather and forecasts- Supports current conditions, daily/hourly forecasts
- Air quality monitoring
- Severe weather alerts
- Multiple forecast types (daily/hourly)
get_bitcoin_price()- Real-time Bitcoin pricingget_crypto_data()- Comprehensive cryptocurrency data
deep_research()- AI-powered research assistantinternet_search()- Google search integrationsearch_firecrawl()- Advanced web scrapingwikipedia_search()- Wikipedia knowledge base
get_datetime()- Date and time utilitiesget_project_structure()- Project analysisget_credits()- System informationget_summarized_manga_info()- Manga database queries
# Initialize with different AI models
client = MCPGroqClient(model="deepseek-ai/DeepSeek-V3")
# or
client = MCPGroqClient(model="llama3-8b-8192")# Daily forecast
get_weather("London", forecast=True, days=5, forecast_type="daily")
# Hourly forecast
get_weather("Paris", forecast=True, days=3, forecast_type="hourly", day_for_hourly=1)
# Current weather with air quality
get_weather("Tokyo", current=True)The project includes pre-trained ML models for enhanced weather prediction:
voting_regressor.joblib- Ensemble model for weather predictionfeature_scaler.joblib- Input feature normalizationtarget_scaler.joblib- Output scaling for predictions
These models work in conjunction with real-time API data to provide more accurate forecasts.
This project leverages MCP for:
- Tool Registration - Automatic discovery of available functions
- Type Safety - Structured parameter validation
- Scalable Architecture - Easy addition of new tools
- Client-Server Communication - Robust messaging protocol
| Service | Purpose | Documentation |
|---|---|---|
| WeatherAPI | Weather data & forecasts | docs.weatherapi.com |
| Groq | Fast AI inference | docs.groq.com |
| Tavily | AI-powered search | docs.tavily.com |
| Firecrawl | Web scraping | docs.firecrawl.dev |
| AlphaVantage | Financial data | alphavantage.co/documentation |
- β Real-time Weather Data - Current conditions and forecasts
- β ML-Enhanced Predictions - Machine learning model integration
- β Multi-tool Integration - Crypto, search, research capabilities
- β Natural Language Interface - Conversational AI interactions
- β Air Quality Monitoring - Environmental health data
- β Severe Weather Alerts - Safety notifications
- β Flexible Forecast Types - Daily, hourly, and custom ranges
- β Multiple AI Models - Support for various LLMs
- β Extensible Architecture - Easy to add new tools
The system includes robust error handling for:
- Invalid API keys
- Network connectivity issues
- Malformed queries
- API rate limiting
- Missing environment variables
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- MCP (Model Context Protocol) for the protocol framework
- Groq for lightning-fast AI inference
- WeatherAPI for comprehensive weather data
- FastMCP for the MCP server implementation
-
API Key Errors
Error: Failed to get weather data Solution: Check your .env file and ensure all API keys are valid -
Module Import Errors
Error: ModuleNotFoundError Solution: Install missing dependencies with pip install -r requirements.txt -
MCP Connection Issues
Error: Failed to connect to MCP server Solution: Ensure ServerSideMCP.py is accessible and Python path is correct
- π§ Create an issue in the repository
- π Check the API documentation for individual services
- π Review error logs for specific error messages
Made with β€οΈ for better weather forecasting and AI tool integration