A Python-based weather information system that uses the Model Control Protocol (MCP) to provide weather forecasts and alerts through a user-friendly Gradio interface.
mcp/
├── client/
│ ├── app.py # Gradio web interface
│ ├── client.py # MCP client implementation
│ └── pyproject.toml # Client dependencies
└── server/
├── weather.py # Weather service implementation
└── pyproject.toml # Server dependencies
- Real-time weather forecasts for any location using latitude and longitude
- Active weather alerts for US states
- User-friendly web interface built with Gradio
- Secure API key management
- Interactive chat-based interface
- Python 3.8 or higher
- Groq API key (for the client)
- Internet connection for weather data
- Clone the repository:
git clone <repository-url>
cd mcp- Set up the client environment:
cd client
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e .- Set up the server environment:
cd ../server
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e .- Start the server:
cd server
python weather.py- In a new terminal, start the client:
cd client
python app.py-
Open your web browser and navigate to the URL shown in the terminal (typically http://localhost:7860)
-
In the web interface:
- Enter your Groq API key
- Set the server script path (default: ./server/weather.py)
- Click "Connect" to establish connection
- Start asking questions about weather!
- "What's the weather forecast for New York City?"
- "Are there any weather alerts in California?"
- "What's the forecast for latitude 40.7128 and longitude -74.0060?"
The server provides two main endpoints:
-
get_forecast(latitude: float, longitude: float)- Returns a detailed weather forecast for the specified location
- Includes temperature, wind conditions, and detailed forecast
-
get_alerts(state: str)- Returns active weather alerts for the specified US state
- Uses two-letter state codes (e.g., CA, NY)
Contributions are welcome! Please feel free to submit a Pull Request.
[Add your license information here]