Weather MCP Server

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.

Category
Visit Server

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.

Python MCP OpenWeather License


๐Ÿ“– 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!

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. 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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured