Skip to main content
Glama
dataenthu25

weather-mcp-server

by dataenthu25

Weather MCP Server

Local Model Context Protocol server in Python that fetches real weather data from the Open-Meteo API (no API key required). Exposes one tool, get_weather, over stdio.

Tool

get_weather(city: str) -> dict

Resolves the city via Open-Meteo Geocoding, fetches current conditions via Open-Meteo Forecast, and returns structured output for agents plus a human-readable summary.

Example return:

{
  "city": "Amsterdam",
  "country": "The Netherlands",
  "latitude": 52.37,
  "longitude": 4.89,
  "temperature_c": 16.8,
  "apparent_c": 15.6,
  "humidity_pct": 59,
  "wind_kph": 6.1,
  "weather_code": 0,
  "description": "Clear sky",
  "summary": "Amsterdam (The Netherlands): Clear sky, 16.8°C (feels 15.6°C), wind 6.1 kph, humidity 59%"
}

Related MCP server: Weather MCP Server

Requirements

  • Python 3.10+

  • Dependencies in requirements.txt: mcp, httpx, pydantic (dev: pytest, pytest-asyncio, respx)

Setup

python -m venv venv
./venv/bin/pip install -r requirements.txt

Run

Stdio transport (stdout is reserved for JSON-RPC — logs go to stderr):

./venv/bin/python server.py

Client config (mcp.json / claude_desktop_config.json):

{
  "mcpServers": {
    "weather": {
      "command": "<absolute-path>/my-mcp-server/venv/bin/python",
      "args": ["<absolute-path>/my-mcp-server/server.py"]
    }
  }
}

Tests

Mocked suite (no live HTTP) plus a live check:

./venv/bin/python -m pytest tests/ -v
./venv/bin/python -c "import asyncio, json, server; print(json.dumps(asyncio.run(server.get_weather('Amsterdam')), indent=2))"

Structure

server.py              MCPServer("weather") + get_weather tool, stdio entrypoint
schemas.py             WeatherOutput / GeocodedLocation pydantic models
services/geocode.py    City -> (lat, lon) via Open-Meteo Geocoding
services/weather_api.py  (lat, lon) -> current conditions via Open-Meteo Forecast
tests/                 Mocked pytest suite (respx)
requirements.txt
weather_server.py      Original hardcoded stub (kept for reference)

Notes

  • No secrets or .env needed (Open-Meteo is keyless).

  • Errors surface as ValueError with a friendly message (unknown city, timeout, HTTP error).

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Provides comprehensive weather information including current conditions, 7-day forecasts, and air quality data for any city worldwide using the Open-Meteo API. Features real-time weather data, hourly forecasts, sunrise/sunset times, and European Air Quality Index with human-readable descriptions.
    3
    16 npm
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables users to get real-time weather data for any city and generate broadcast-style weather news reports. Uses the OpenMeteo API to provide current weather conditions including temperature, humidity, and weather descriptions.
    10 npm
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides current weather information for any city worldwide using the free Open-Meteo API, enabling users to query temperature, wind speed, humidity, and weather conditions through natural language.
    10 npm
    MIT