Skip to main content
Glama
Weather MCP Server

Weather MCP Server

🌦️ 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


⭐ If you found this project useful, consider giving it a star!

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server that enables AI assistants and LLMs to access real-time weather data and forecasts by connecting to the OpenWeatherMap API.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A Docker-based MCP server that provides current weather information for cities worldwide. Enables AI assistants like Claude to fetch temperature, weather conditions, and humidity data through a standardized interface.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server built with the mcp-framework to provide weather-related tools and data to AI clients. It enables integration of weather capabilities and custom tools into the MCP ecosystem for use with platforms like Claude Desktop.
      -
    • A
      license
      A
      quality
      D
      maintenance
      A production-grade MCP server that provides real-time weather data and demonstrates the complete MCP protocol surface including tools, resources, prompts, and structured output.
      2
      2
      MIT