Skip to main content
Glama
Amankhan1009

AI Weather MCP Server

by Amankhan1009
README.md
# ๐ŸŒฆ๏ธ AI Weather MCP Server

<p align="center">

![Python](https://img.shields.io/badge/Python-3.13%2B-blue)
![MCP](https://img.shields.io/badge/Model_Context_Protocol-MCP-green)
![FastMCP](https://img.shields.io/badge/FastMCP-Latest-orange)
![Docker](https://img.shields.io/badge/Docker-Ready-2496ED)
![Tests](https://img.shields.io/badge/Tests-Pytest-success)
![License](https://img.shields.io/badge/License-MIT-lightgrey)

</p>

A **production-grade Model Context Protocol (MCP) server** that combines **real-time weather data** with **LLM-powered reasoning** to deliver intelligent weather insights instead of raw numbers.

Built to demonstrate production backend engineering, clean architecture, MCP development, external API integration, asynchronous programming, Dockerization, testing, and AI reasoning.

---

# โœจ Features

## ๐ŸŒค Weather Tools

- Current Weather
- Weather Forecast
- Air Quality
- UV Index
- Sunrise & Sunset

## ๐Ÿค– AI Tools

- Clothing Recommendation
- Weather Summary
- Travel Advice
- Outdoor Activity Recommendation
- AI Weather Advisory

The guiding principle is:

> **Weather APIs provide facts. The LLM provides reasoning.**

The model never invents weather information.

---

# ๐Ÿ— Architecture

```text
MCP Client
     โ”‚
     โ–ผ
MCP Tools
     โ”‚
     โ–ผ
Services
     โ”‚
     โ–ผ
Clients
 โ”œโ”€โ”€ Weather APIs
 โ””โ”€โ”€ LLM Provider
```

Each layer has a single responsibility.

---

# ๐Ÿ“‚ Project Structure

```text
src/weather_mcp/
โ”œโ”€โ”€ server.py
โ”œโ”€โ”€ config.py
โ”œโ”€โ”€ logging_config.py
โ”œโ”€โ”€ exceptions.py
โ”œโ”€โ”€ models/
โ”œโ”€โ”€ clients/
โ”œโ”€โ”€ services/
โ””โ”€โ”€ tools/
```

---

# ๐Ÿง  Design Decisions

## Two Weather Providers

The project combines OpenWeatherMap with Open-Meteo.

OpenWeatherMap supplies current weather, forecast and air-quality data.

Open-Meteo is used for UV Index because it remains free without requiring a paid One Call subscription.

---

## AI Weather Advisory

`get_weather_alerts()` intentionally produces an **AI-generated advisory**.

It is **not** an official government weather warning.

Instead, the LLM reasons over forecast information to identify potentially concerning conditions such as:

- Heavy rain
- Strong winds
- High temperatures
- Thunderstorms

---

## Swappable LLM

The LLM layer is isolated.

Changing from Groq to OpenAI only requires configuration rather than application changes.

---

# โš™๏ธ Installation

```bash
git clone <repository-url>

cd weather-mcp-server

python3 -m venv .venv
source .venv/bin/activate

pip install -e ".[dev]"
```

---

# ๐Ÿ”‘ Configuration

Copy:

```bash
cp .env.example .env
```

Configure your API keys.

| Variable | Description |
|----------|-------------|
| WEATHER_API_KEY | OpenWeatherMap key |
| LLM_API_KEY | Groq/OpenAI key |
| LLM_PROVIDER | groq/openai |
| LLM_MODEL | Model name |

---

# โ–ถ Running

```bash
python3 -m weather_mcp.server
```

---

# ๐Ÿณ Docker

```bash
docker build -t weather-mcp-server .

docker run -i --env-file .env weather-mcp-server
```

---

Pull the pre-built image directly:

\`\`\`bash
docker pull amankhan1009/weather-mcp-server:latest
docker run -i --env-file .env amankhan1009/weather-mcp-server:latest
\`\`\`

Or build it yourself:

\`\`\`bash
docker build -t weather-mcp-server .
docker run -i --env-file .env weather-mcp-server
\`\`\`

# ๐Ÿงช Testing

```bash
pytest
```

The suite uses mocked external services for deterministic tests.

---

# ๐Ÿ”Œ MCP Clients

Compatible with:

- Claude Desktop
- MCP Inspector
- Any MCP-compatible client

---

# ๐Ÿ“ˆ Future Improvements

- Official severe weather alerts
- Additional LLM providers
- Response caching
- Streaming responses
- Structured JSON outputs

---

## ๐Ÿ‘จโ€๐Ÿ’ป Author

**Md Aman Alam**

LinkedIn: [Md Aman Alam](https://www.linkedin.com/in/md-aman-alam-a04552289/)

If you found this project useful, consider giving it a โญ on GitHub.

Maintenance

ActivitySlowing
ResponsivenessNo issues