Weather MCP Server
A production-ready MCP server that provides real-time weather information, forecasts, air quality, and weather alerts through the OpenWeatherMap API. It integrates with Claude Desktop and other MCP-compatible clients for natural language weather queries.
README
๐ฆ๏ธ Weather MCP Server for Claude Integration
A production-ready Model Context Protocol (MCP) server built using the official Python MCP SDK that provides real-time weather information, forecasts, air quality, and weather alerts through the OpenWeatherMap API.
๐ Overview
This project demonstrates how to build a local MCP Server using the official Python MCP SDK. The server exposes multiple weather-related tools that can be consumed by any MCP-compatible client such as Claude Code, MCP Inspector, or other MCP hosts.
The server communicates with the OpenWeatherMap API and returns structured weather information through the MCP protocol.
โจ Features
- ๐ค๏ธ Current Weather
- ๐ 5-Day Weather Forecast
- ๐ช๏ธ Weather Alerts
- ๐ซ๏ธ Air Quality Index
- ๐ MCP Resources
- ๐ฌ MCP Prompt Templates
- ๐ Structured Logging
- โ ๏ธ Robust Error Handling
- ๐ Standard I/O (STDIO) Transport
- ๐๏ธ Clean Layered Architecture
๐๏ธ Architecture
User
โ
โผ
Claude Desktop
Claude Code
MCP Inspector
โ
โผ
MCP Protocol (STDIO)
โ
โผ
Weather MCP Server
โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ โผ โผ
Tools Resources Prompts
โ
โผ
OpenWeatherMap REST API
โ
โผ
Weather Information
๐ Project Structure
weather-mcp/
โ
โโโ server.py
โโโ config.py
โโโ requirements.txt
โโโ README.md
โโโ .env.example
โ
โโโ models/
โ โโโ weather_model.py
โ โโโ forecast_model.py
โ
โโโ services/
โ โโโ parser.py
โ โโโ weather_api.py
โ
โโโ tools/
โ โโโ current_weather.py
โ โโโ forecast.py
โ โโโ alerts.py
โ โโโ air_quality.py
โ
โโโ prompts/
โ โโโ README.md
โ
โโโ resources/
โ โโโ README.md
โ
โโโ tests/
โ โโโ test_weather_parsing.py
โ
โโโ utils/
โโโ logger.py
โโโ helpers.py
โโโ exceptions.py
โ๏ธ Installation
Clone the repository
git clone https://github.com/PrasadMankar1309/Weather-MCP-Tool-for-the-Claude-Integration.git
cd Weather-MCP-Tool-for-the-Claude-Integration
Create a virtual environment
python -m venv .venv
Activate it
Windows
.venv\Scripts\activate
Linux / macOS
source .venv/bin/activate
Install dependencies
pip install -r requirements.txt
๐ Configuration
Create a .env file in the project root.
OPENWEATHER_API_KEY=your_api_key_here
OPENWEATHER_BASE_URL=https://api.openweathermap.org/data/2.5
REQUEST_TIMEOUT_SECONDS=10
LOG_LEVEL=INFO
You can obtain a free API key from:
https://openweathermap.org/api
โถ๏ธ Running the MCP Server
python server.py
The server communicates using the STDIO transport and is intended to be launched by an MCP-compatible client.
๐ Claude Desktop Integration
Example configuration:
{
"mcpServers": {
"weather": {
"command": "python",
"args": [
"C:/path/to/server.py"
]
}
}
}
Restart Claude Desktop after updating the configuration.
๐ Testing with MCP Inspector
Launch the MCP Inspector:
npx @modelcontextprotocol/inspector
Add a new STDIO server:
Command
python
Argument
server.py
If configured correctly, the Inspector will display:
- Tools
- Resources
- Prompts
๐ ๏ธ Available MCP Tools
| Tool | Description |
|---|---|
| Current Weather | Retrieves current weather for a city |
| Forecast | Retrieves weather forecast |
| Weather Alerts | Displays active weather alerts |
| Air Quality | Retrieves AQI information |
๐ MCP Resources
| Resource | Description |
|---|---|
| weather://supported-cities | Supported cities |
| weather://api-docs | API information |
| weather://prompt-examples | Example prompts |
๐ฌ MCP Prompt Templates
- Travel Weather Report
- Farmer Weather Report
- Weather Summary
๐ก Example Prompts
What's the weather in Pune?
Forecast for Mumbai
Weather alerts in Delhi
Air quality in London
๐ MCP Workflow
User Prompt
โ
โผ
Claude Desktop / Claude Code
โ
โผ
MCP Client
โ
โผ
Weather MCP Server
โ
โผ
OpenWeatherMap API
โ
โผ
JSON Response
โ
โผ
Claude Response
โ ๏ธ Error Handling
The server gracefully handles:
- Invalid city names
- Missing API keys
- Network failures
- Request timeouts
- API errors
๐ Future Improvements
- Hourly Forecast
- Weather Maps
- Geolocation Support
- Historical Weather
- Severe Weather Notifications
- Multi-language Support
- Docker Deployment
- Streamable HTTP Transport
๐งช Technologies Used
- Python 3.10
- Model Context Protocol (MCP)
- Official Python MCP SDK
- OpenWeatherMap API
- Dataclasses
- Logging
- dotenv
๐ค Contributing
Contributions are welcome!
- Fork the repository
- Create a feature branch
- Commit your changes
- Open a Pull Request
๐ License
This project is licensed under the MIT License.
๐จโ๐ป Author
Prasad Mankar
- GitHub: https://github.com/PrasadMankar1309
- LinkedIn: https://www.linkedin.com/in/prasad-mankar/
โญ If you found this project useful, consider giving it a star!
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.