🌦️ Claude Weather Agent (MCP-Enabled)
This project enables Claude to interact with live weather data (current + forecast) using the OpenWeather API via an MCP (Multi-Command Protocol) server.
It includes:
- FastMCP server using Python
- Weather tools (
get_weatherandget_forecast) - Environment variable-based API security
- Easy integration with
claude_desktop_config.py
🚀 How to Run the MCP Server
- Clone this repo and navigate into it:
git clone https://github.com/ChandekarDhruvin/claude-openweather-mcp.git
cd claude-weather-agent/weather
- Install dependencies:
pip install -r requirements.txt
- Create a
.envfile in the same directory asweather.py:
OPENWEATHER_API_KEY=your_openweather_api_key
- Start the MCP server manually (for testing):
python weather.py
🧠 Tools Exposed to Claude
| Tool | Parameters | Description |
|---|---|---|
get_weather |
city: str, country: str = "IN" |
Returns current weather conditions. |
get_forecast |
city: str, country: str = "IN" |
Provides a 5-day forecast (around noon). |
🛠️ Claude Integration: claude_desktop_config.py
Add the following to your Claude config to auto-start the MCP server:
{
"mcpServers": {
"weather": {
"command": "C:\\\\path\\\\to\\\\uv.exe",
"args": [
"--directory",
"C:\\\\path\\\\to\\\\weather\\\\folder",
"run",
"C:\\\\path\\\\to\\\\weather\\\\weather.py"
]
}
}
}
📝 Note: You must adjust the path to match your local Python virtual environment and directory structure.
📂 Project Structure
weather/
├── weather.py # Main FastMCP server with weather tools
├── .env # Contains the OpenWeather API key
├── requirements.txt # Dependencies
└── README.md # You're reading it!
🔒 Environment Variables
Using python-dotenv, we securely load the OpenWeather API key from a .env file.
from dotenv import load_dotenv
import os
load_dotenv()
OPENWEATHER_API_KEY = os.getenv("OPENWEATHER_API_KEY")
✅ Requirements
Add this in your requirements.txt:
httpx
python-dotenv
fastmcp
User: What's the weather like in Mumbai today?
Claude:
Current weather in Mumbai, IN:
Condition: Clear (clear sky)
Temperature: 32°C (Feels like 35°C)
Humidity: 58%
Wind Speed: 3.5 m/s
Reference
https://modelcontextprotocol.io/
Recommend MCP Servers 💡
youtube-mcp
A MCP server for interacting with YouTube videos and retrieving subtitles to enable LLMs to analyze video content.
@agree-able/room-mcp
A command-line tool for using MCP (Model Context Protocol) with the Room protocol, enabling AI agents like Claude to create virtual rooms for coordinated goal accomplishment.
bluesky-context-server
A Model Context Protocol (MCP) server that enables MCP clients like Claude Desktop to interact with Bluesky, allowing users to query profiles, search posts, and get timelines.
arjunkmrm/lta-mcp
An MCP server for Singapore's Land Transport Authority (LTA) DataMall API, providing real-time access to transportation information including bus arrivals, traffic conditions, and train service updates
fibery-mcp-server
This MCP (Model Context Protocol) server provides integration between Fibery and any LLM provider supporting the MCP protocol (e.g., Claude for Desktop), allowing you to interact with your Fibery workspace using natural language.
Gemini Email Generator
An MCP server that uses Google's Gemini Flash 2 AI to generate email subjects and detailed thinking processes, designed for seamless integration with Claude Desktop.