Skip to content

A Python-based framework for building and managing multi-agent systems, supporting modular agent design and collaborative autonomous behaviors.

Notifications You must be signed in to change notification settings

sanepunk/MCPAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌀️ MCP Agent

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.

πŸš€ Overview

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

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client Side   │◄──►│   MCP Server    │◄──►│   AI Services   β”‚
β”‚  (Groq + MCP)   β”‚    β”‚   (FastMCP)     β”‚    β”‚ (APIs & Models) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                       β”‚                       β”‚
        β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ User Interface  β”‚    β”‚   Tool Manager  β”‚    β”‚  External APIs  β”‚
β”‚    & Queries    β”‚    β”‚   & Registry    β”‚    β”‚ & ML Models     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

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

πŸ› οΈ Installation & Setup

Prerequisites

  • Python 3.8+
  • pip package manager
  • API keys for various services

1. Clone & Install Dependencies

git clone <repository-url>
cd MCPAgent
pip install -r requirements.txt  # You may need to create this

2. Required Dependencies

pip 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 openai

3. Environment Configuration

Create 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

4. API Key Setup Guide

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

πŸš€ Usage

Quick Start

# Run the MCP server
python run.py

Example Queries

🌀️ Weather Forecasting

"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?"

πŸ’° Cryptocurrency Data

"What's the current Bitcoin price?"
"Show me Ethereum trading data"

πŸ” Research & Information

"Search for recent climate change news"
"Find information about machine learning in weather prediction"
"What's happening with renewable energy stocks?"

πŸ“š Knowledge Queries

"Tell me about meteorology from Wikipedia"
"Search for the latest manga releases"

πŸ› οΈ Available Tools

Core Weather Tools

  • get_weather() - Current weather and forecasts
    • Supports current conditions, daily/hourly forecasts
    • Air quality monitoring
    • Severe weather alerts
    • Multiple forecast types (daily/hourly)

Financial Tools

  • get_bitcoin_price() - Real-time Bitcoin pricing
  • get_crypto_data() - Comprehensive cryptocurrency data

Search & Research Tools

  • deep_research() - AI-powered research assistant
  • internet_search() - Google search integration
  • search_firecrawl() - Advanced web scraping
  • wikipedia_search() - Wikipedia knowledge base

Utility Tools

  • get_datetime() - Date and time utilities
  • get_project_structure() - Project analysis
  • get_credits() - System information
  • get_summarized_manga_info() - Manga database queries

πŸ”§ Advanced Configuration

Custom Model Usage

# Initialize with different AI models
client = MCPGroqClient(model="deepseek-ai/DeepSeek-V3")
# or
client = MCPGroqClient(model="llama3-8b-8192")

Weather Forecast Types

# 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)

🧠 Machine Learning Models

The project includes pre-trained ML models for enhanced weather prediction:

  • voting_regressor.joblib - Ensemble model for weather prediction
  • feature_scaler.joblib - Input feature normalization
  • target_scaler.joblib - Output scaling for predictions

These models work in conjunction with real-time API data to provide more accurate forecasts.

πŸ”Œ MCP (Model Context Protocol) Integration

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

🌐 API Integrations

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

🎯 Key Features

  • βœ… 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

🚨 Error Handling

The system includes robust error handling for:

  • Invalid API keys
  • Network connectivity issues
  • Malformed queries
  • API rate limiting
  • Missing environment variables

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ› Troubleshooting

Common Issues

  1. API Key Errors

    Error: Failed to get weather data
    Solution: Check your .env file and ensure all API keys are valid
    
  2. Module Import Errors

    Error: ModuleNotFoundError
    Solution: Install missing dependencies with pip install -r requirements.txt
    
  3. MCP Connection Issues

    Error: Failed to connect to MCP server
    Solution: Ensure ServerSideMCP.py is accessible and Python path is correct
    

Getting Help

  • πŸ“§ 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

About

A Python-based framework for building and managing multi-agent systems, supporting modular agent design and collaborative autonomous behaviors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages