Skip to main content
Glama
README.md
# šŸŒ¤ļø Weather MCP Server & Chatbot Interface for Cursor

A simple, complete Python project that implements a **Model Context Protocol (MCP)** Weather Server ready for **Cursor IDE**, paired with a **Chatbot Web UI** to test and converse with the weather agent.

---

## 🌟 Features

- **🌐 MCP Server (`weather_mcp_server.py`)**: Built with FastMCP over stdio transport. Exposes weather tools to Cursor and other MCP clients.
- **⚔ Free Real-time Weather (`weather_service.py`)**: Powered by Open-Meteo. No API keys needed. Works for any city globally.
- **šŸ¤– Weather Agent (`agent.py`)**: Converts natural queries (*"Weather in Tokyo"*, *"5-day forecast for London"*, *"Air quality in Paris"*) into tool invocations.
- **šŸ’» Modern Chatbot UI (`static/` & `app.py`)**: Dark-mode, glassmorphic web interface with visual weather cards, forecast tables, and tool execution badges.
- **šŸ”Œ Cursor Integration (`.cursor/mcp.json`)**: Pre-configured JSON for Cursor settings.

---

## šŸ“ Project Structure

```
weather-mcp-chatbot/
│── .cursor/
│   └── mcp.json               # Cursor MCP configuration
│── weather_service.py         # Free Open-Meteo weather & geocoding integration
│── weather_mcp_server.py      # MCP Server (stdio transport for Cursor)
│── agent.py                   # Weather agent NLP & tool caller
│── app.py                     # FastAPI web server & chat endpoint
│── static/
│   ā”œā”€ā”€ index.html             # Chatbot UI
│   ā”œā”€ā”€ style.css              # Modern dark-mode styling
│   └── app.js                 # Chatbot frontend logic
│── test_mcp.py                # Automated test suite
│── requirements.txt           # Python dependencies
└── README.md                  # Documentation & quickstart
```

---

## šŸš€ Quickstart

### 1. Install Dependencies
```bash
pip install -r requirements.txt
```

### 2. Run the Web Chatbot UI
```bash
python app.py
```
Open your browser and navigate to: **[http://127.0.0.1:8000](http://127.0.0.1:8000)**

### 3. Run Automated Tests
```bash
python test_mcp.py
```

---

## šŸ”Œ How to Connect with Cursor

Cursor can connect directly to your Python MCP server to provide real-time weather data inside Cursor Chat / Composer.

### Option A: Using `.cursor/mcp.json` (Recommended)
1. Open this project directory in Cursor:
   ```
   File -> Open Folder -> weather-mcp-chatbot
   ```
2. The `.cursor/mcp.json` file inside the project is automatically detected by Cursor.

### Option B: Add in Cursor Settings
1. In Cursor, open **Settings** (`Ctrl + ,` or `Cmd + ,`).
2. Go to **Features** -> **MCP Servers**.
3. Click **Add New MCP Server**:
   - **Name**: `weather`
   - **Type**: `command` (stdio)
   - **Command**: `python C:\Users\admin\.gemini\antigravity\scratch\weather-mcp-chatbot\weather_mcp_server.py`
4. Click **Save** and verify the green status indicator.

### Using in Cursor Chat:
In Cursor Composer or Chat, you can now ask:
- *"What is the current weather in Tokyo?"*
- *"Check the 5-day forecast for Berlin using @weather"*
- *"What is the air quality in Paris?"*

Cursor will call the MCP tools (`get_current_weather`, `get_weather_forecast`, `get_air_quality`) to fetch live data!

---

## šŸ› ļø MCP Tools Exposed

| Tool Name | Parameters | Description |
|-----------|------------|-------------|
| `get_current_weather` | `city: str`, `units: str = "metric"` | Real-time temperature, condition, humidity, wind speed, pressure |
| `get_weather_forecast` | `city: str`, `days: int = 5`, `units: str = "metric"` | Multi-day forecast with daily high/lows and rain probabilities |
| `get_air_quality` | `city: str` | Air Quality Index (US & EU AQI), PM2.5, PM10, Ozone levels |