Skip to main content
Glama
kishore341

Weather Checker

by kishore341
README.md
# β›… Weather MCP Server

A lightweight MCP (Model Context Protocol) server that exposes a single tool β€” real-time weather lookup for any location β€” to any MCP-compatible client, such as Claude Desktop.

---

## 🧠 How It Works

1. A `FastMCP` server named **"Weather Checker"** is started over **stdio transport**.
2. It exposes one async tool, `check_weather(location: str)`, callable by any connected MCP client.
3. Internally, the tool calls `get_weather()`, which hits [wttr.in](https://wttr.in) β€” a free, no-auth-required weather service β€” and returns a concise, one-line weather summary for the given location.
4. No API keys, no sign-ups, no external dependencies beyond the `mcp` package itself.

---

## πŸ—‚οΈ Project Structure

```
β”œβ”€β”€ main.py                 # MCP server entry point β€” defines and runs the check_weather tool
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── weather.py          # Fetches weather data from wttr.in
β”œβ”€β”€ pyproject.toml          # Project metadata and dependencies (uv-managed)
β”œβ”€β”€ requrements.txt          # Pip-installable dependencies
β”œβ”€β”€ uv.lock                  # Locked dependency versions
└── .python-version          # Python 3.13
```

---

## πŸ› οΈ Tech Stack

| Layer | Technology |
|---|---|
| **Protocol** | MCP (Model Context Protocol) β€” `FastMCP`, stdio transport |
| **Weather Data Source** | [wttr.in](https://wttr.in) β€” free console-friendly weather API |
| **HTTP Client** | Python standard library (`urllib.request`) |
| **Package Management** | uv |
| **Language** | Python 3.13 |

---

## βš™οΈ Local Setup

### 1. Clone the Repository
```bash
git clone https://github.com/<your-username>/<repo-name>.git
cd <repo-name>
```

### 2. Install Dependencies

Using `uv` (recommended, matches `uv.lock`):
```bash
uv sync
```

Or using standard `venv` + pip:
```bash
python -m venv .venv
source .venv/bin/activate   # On Windows: .venv\Scripts\activate
pip install -e .
```

### 3. Run the Server
```bash
python main.py
```
The server starts and communicates over **stdio** β€” it's designed to be launched by an MCP client, not accessed directly via a browser or REST call.

---

## πŸ”Œ Connecting to an MCP Client

To use this server with an MCP-compatible client (e.g. Claude Desktop), add it to the client's MCP server configuration:

```json
{
  "mcpServers": {
    "weather-checker": {
      "command": "python",
      "args": ["main.py"]
    }
  }
}
```

If using `uv`:
```json
{
  "mcpServers": {
    "weather-checker": {
      "command": "uv",
      "args": ["run", "main.py"]
    }
  }
}
```

Once connected, the client can call the `check_weather` tool directly β€” for example, asking "What's the weather in London?" will invoke `check_weather(location="London")` behind the scenes.

---

## πŸ”§ Available Tools

| Tool | Parameters | Returns | Description |
|---|---|---|---|
| `check_weather` | `location: str` (e.g. `"New York"`, `"London"`) | Concise weather summary (string) | Fetches current weather conditions for the specified location via wttr.in |

### Example Output
```
New York: β˜€οΈ   +24Β°C
```

---

## πŸ“Œ Key Features

- βœ… Zero-configuration β€” no API keys or environment variables required
- βœ… Minimal dependency footprint (`mcp[cli]` only)
- βœ… Clean separation between MCP tool definition (`main.py`) and the underlying data-fetch logic (`tools/weather.py`)
- βœ… Graceful error handling β€” returns a readable error string instead of raising on failed requests
- βœ… Async tool definition, ready to scale to additional tools in the same server

---

## πŸ“„ License

This project is for educational purposes.

TDQS

C2.9/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusion between tools, making disambiguation perfect.

Naming Consistency5/5

The single tool name 'check_weather' follows a clear verb_noun pattern, and with only one tool, consistency is trivial.

Tool Count2/5

A single tool for a weather service feels too thin; typical weather APIs offer multiple endpoints (current, forecast, alerts), so this count is insufficient for the apparent scope.

Completeness2/5

The tool set likely lacks essential features like forecasts, historical data, or location types, making it incomplete for realistic weather queries.

Maintenance

ActivityInactive
ResponsivenessNo issues