Skip to main content
Glama
PrasadMankar1309

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!

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

โ€“Maintainers
โ€“Response time
โ€“Release cycle
โ€“Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    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.
    Last updated
  • F
    license
    -
    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.
    Last updated
  • F
    license
    -
    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.
    Last updated
    19
  • F
    license
    A
    quality
    C
    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.
    Last updated
    2
    2

View all related MCP servers

Related MCP Connectors

  • OpenWeather MCP โ€” wraps the OpenWeatherMap API (openweathermap.org)

  • Open-Meteo MCP โ€” weather forecast + historical reanalysis + sister APIs

  • 350+ production-ready APIs through one MCP server โ€” weather, geocoding, validation, financial data.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PrasadMankar1309/Weather-MCP-Tool-for-the-Claude-Integration'

If you have feedback or need assistance with the MCP directory API, please join our Discord server