Skip to main content
Glama
jayaraj-kannan

Weather MCP Server

Weather MCP Server (OpenWeather API)

A Model Context Protocol (MCP) server built with Python and uv that provides weather information by city name using the OpenWeather API (https://api.openweathermap.org/data/2.5/weather).


Table of Contents


Related MCP server: Weather MCP Server

Features

  • Get Weather by City Name: Fetches real-time weather metrics for any city (e.g., London, Chennai, New York,US).

  • Structured JSON Output: Returns temperature (°C), feels-like (°C), humidity (%), pressure (hPa), weather conditions, and wind speed (m/s).

  • Environment Key Integration: Loads OPENWEATHER_API_KEY automatically via .env / dotenv.

  • Package Management via uv: Uses pyproject.toml and uv for reproducible builds.


Prerequisites


Step-by-Step Setup Guide

Step 1: Clone / Navigate to Project Directory

cd /Users/jayarajkannan/Learnings/project/mcp

Step 2: Environment Configuration

Create a .env file from .env.example and set your OpenWeather API key:

cp .env.example .env

Edit .env:

OPENWEATHER_API_KEY=your_actual_openweather_api_key_here

Step 3: Install Dependencies

Sync virtual environment and lockfile using uv:

uv sync

This installs mcp, httpx, and python-dotenv into the project environment.


Step 4: Run the MCP Server

You can run the server directly using uv:

uv run server.py

Or using the CLI script entry point defined in pyproject.toml:

uv run weather-mcp

Note: MCP servers communicate over stdio via JSON-RPC. Running the script directly will wait for input on stdin.


Step 5: Test Interactively with MCP Inspector

Use the official MCP Inspector to test and verify all tool calls in your browser UI:

npx @modelcontextprotocol/inspector uv run server.py
  1. Open the URL printed in the terminal (e.g. http://127.0.0.1:6274?...).

  2. Click Connect.

  3. Select the get_weather tool.

  4. Input a city name (e.g. London or Chennai) and click Run Tool.


Step 6: Run Automated Tests

Run the test suite using unittest and uv:

uv run python -m unittest test_server.py

MCP Tools Reference

get_weather

Gets current weather for a city using OpenWeather API.

Input Schema

Parameter

Type

Required

Description

city

string

Yes

City name (e.g. "London", "Chennai", "New York")

Example Response Output

{
  "city": "London",
  "country": "GB",
  "temperature_c": 21.57,
  "feels_like_c": 21.58,
  "humidity": 69,
  "pressure": 1006,
  "weather": "Clouds",
  "description": "broken clouds",
  "wind_speed_mps": 9.26
}

MCP Client Integration

Add the Weather MCP server to your MCP client configuration (e.g. Claude Desktop claude_desktop_config.json or Antigravity .mcp.json):

{
  "mcpServers": {
    "weather": {
      "command": "uv",
      "args": [
        "--directory",
        "/Users/jayarajkannan/Learnings/project/mcp",
        "run",
        "server.py"
      ],
      "env": {
        "OPENWEATHER_API_KEY": "YOUR_OPENWEATHER_API_KEY"
      }
    }
  }
}

Project Structure

├── pyproject.toml    # Project dependencies and script entry points
├── uv.lock           # Locked dependency tree
├── server.py         # Weather MCP server implementation
├── test_server.py    # Automated unit tests
├── .env.example      # Sample environment configuration
├── .env              # Local environment variables (API Key)
└── README.md         # Documentation
F
license - not found
A
quality
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

View all related MCP servers

Related MCP Connectors

  • Real-time weather conditions and multi-day forecasts via Open-Meteo — free, no API key required

  • OpenWeather MCP — wraps the OpenWeatherMap API (openweathermap.org)

  • Global weather via Open-Meteo: forecast, ERA5 archive, marine, air quality, geocoding, elevation.

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/jayaraj-kannan/mcp-weather'

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