weather-mcp-server

weather-mcp-server

A Python MCP server that provides current weather conditions and multi-day forecasts for cities worldwide using the Open-Meteo API. It exposes tools to get current weather and forecasts without requiring an API key.

Category
Visit Server

README

Weather MCP Server

A Python-based Model Context Protocol (MCP) server that provides current weather conditions and multi-day forecasts for cities worldwide.

The server uses the Open-Meteo Geocoding API to convert city names into coordinates and the Open-Meteo Forecast API to retrieve live weather data. The results are exposed as MCP tools through Streamable HTTP and can be tested with MCP Inspector.

Demo

The server exposes two MCP tools:

get_current_weather

get_forecast

Example request:

{ "city": "Cologne", "days": 5 }

Example result:

Weather forecast for Cologne, Germany Coordinates: 50.9333, 6.95 Timezone: Europe/Berlin

Date: 2026-08-03 Conditions: Partly cloudy Maximum temperature: 28.5 °C Minimum temperature: 16.4 °C Maximum rain probability: 20% Maximum wind speed: 12.1 km/h

Demo

Weather MCP Server running in MCP Inspector

Features

Current weather information for cities worldwide

Daily forecasts for up to 7 days

Automatic city-to-coordinate lookup

Worldwide location support

Weather condition descriptions based on WMO weather codes

Maximum and minimum temperatures

Rain probability

Wind speed

Asynchronous HTTP requests with httpx

MCP tool exposure

Streamable HTTP transport

MCP Inspector compatibility

No API key required

Available MCP Tools

get_current_weather

Returns the current weather conditions for a city.

Input

{ "city": "Cologne" }

Output includes

Location and country

Local time

Weather conditions

Current temperature

Apparent temperature

Precipitation

Wind speed

get_forecast

Returns a multi-day daily weather forecast.

Input

{ "city": "Cologne", "days": 5 }

Parameters

Parameter

Type

Description

city

string

Name of the city

days

integer

Number of forecast days, from 1 to 7

Output includes

Forecast date

Weather conditions

Maximum temperature

Minimum temperature

Maximum rain probability

Maximum wind speed

Architecture

MCP Client / MCP Inspector | | Streamable HTTP v Weather MCP Server | | HTTPS requests v Open-Meteo Geocoding API Open-Meteo Forecast API

Request flow

  1. User enters a city name
  2. MCP client calls a weather tool
  3. MCP server sends the city to Open-Meteo Geocoding API
  4. Geocoding API returns latitude, longitude and timezone
  5. MCP server calls the Open-Meteo Forecast API
  6. Weather data is formatted into readable text
  7. MCP server returns the result to the client

Technologies Used

Python

Model Context Protocol Python SDK

MCPServer

Open-Meteo Geocoding API

Open-Meteo Forecast API

HTTPX

uv

Uvicorn

Streamable HTTP

MCP Inspector

Git and GitHub

Project Structure

weather-mcp-server/ ├── weather.py ├── pyproject.toml ├── uv.lock ├── README.md ├── .gitignore ├── .python-version └── src/ └── weather/ └── init.py

Optional screenshot folder:

screenshots/ └── mcp_weather_inspector.png

Requirements

Python 3.10 or newer

uv

Node.js

npm and npx

Git

Check installed versions:

python --version uv --version node --version npm --version npx --version git --version

Installation

  1. Clone the repository

git clone https://github.com/aarvijayanand/weather-mcp-server.git cd weather-mcp-server

  1. Install dependencies

uv sync

If required, install dependencies manually:

uv add "mcp[cli]" httpx

Run the MCP Server

uv run weather.py

Expected output:

INFO: Started server process INFO: Application startup complete INFO: Uvicorn running on http://127.0.0.1:8000

Server address:

http://127.0.0.1:8000

MCP endpoint:

http://127.0.0.1:8000/mcp

The /mcp endpoint is not a normal webpage. Opening it directly in a browser may show Missing session ID. This is expected because it must be accessed by an MCP client.

Test with MCP Inspector

Keep the weather server running.

Open a second PowerShell window:

npx -y @modelcontextprotocol/inspector

MCP Inspector normally opens at:

http://localhost:6274

Add the weather server

Click Add Servers

Choose Add manually

Enter:

Name: weather Transport: Streamable HTTP URL: http://127.0.0.1:8000/mcp

Save the server

Switch it to Connected

Open the Tools tab

You should see:

get_current_weather get_forecast

Test Examples

Current weather for Cologne

{ "city": "Cologne" }

Five-day forecast for Cologne

{ "city": "Cologne", "days": 5 }

Forecast for Berlin

{ "city": "Berlin", "days": 3 }

Forecast for Chennai

{ "city": "Chennai", "days": 7 }

Open-Meteo API

Open-Meteo is a weather-data service that provides current conditions and forecasts through an API.

Geocoding API

https://geocoding-api.open-meteo.com/v1/search

It converts a city name into:

latitude

longitude

country

timezone

Example:

Cologne ↓ Latitude: 50.9333 Longitude: 6.95 Timezone: Europe/Berlin

Forecast API

https://api.open-meteo.com/v1/forecast

It returns weather variables such as:

temperature_2m

apparent_temperature

weather_code

precipitation

wind_speed_10m

temperature_2m_max

temperature_2m_min

precipitation_probability_max

wind_speed_10m_max

No API key is required for this project.

Weather Codes

Code

Description

0

Clear sky

1

Mainly clear

2

Partly cloudy

3

Overcast

45

Fog

51

Light drizzle

61

Slight rain

63

Moderate rain

65

Heavy rain

71

Slight snowfall

80

Slight rain showers

95

Thunderstorm

Important Note

This project does not create its own weather prediction model.

It retrieves forecast data from Open-Meteo and exposes it through MCP tools.

A correct project description is:

A Python MCP server that retrieves and presents worldwide weather forecasts using the Open-Meteo API.

Error Handling

The project handles:

invalid city names

empty city input

invalid forecast-day values

request timeouts

HTTP errors

invalid JSON responses

missing forecast data

malformed location data

incomplete API responses

Common Problems

npx is not recognized

winget install OpenJS.NodeJS.LTS

Restart PowerShell, then check:

node --version npm --version npx --version

uv is not recognized

irm https://astral.sh/uv/install.ps1 | iex

Restart PowerShell and check:

uv --version

Missing session ID

This happens when opening the MCP endpoint directly in a browser. Use MCP Inspector or another MCP-compatible client instead.

Port 8000 is already in use

netstat -ano | findstr :8000

MCP Inspector cannot connect

Check that:

weather.py is running

the URL is exactly http://127.0.0.1:8000/mcp

the transport is Streamable HTTP

no other service is using port 8000

Learning Objectives

This project demonstrates:

Building an MCP server

Creating MCP tools

Defining tool parameters

Calling external APIs

Handling asynchronous HTTP requests

Converting city names into coordinates

Processing JSON responses

Mapping numerical weather codes

Using Streamable HTTP

Testing with MCP Inspector

Returning live external data through MCP

Using Git and GitHub for version control

Future Improvements

Hourly weather forecasts

Weekend weather summaries

Weather comparison between two cities

Rain and snow alerts

Travel-weather recommendations

Clothing suggestions

Sunrise and sunset times

Air-quality data

Historical weather data

Docker support

Cloud deployment

Automated tests

Structured JSON output

MCP resources

MCP prompts

Authentication

Rate limiting

Logging

Health-check endpoint

Suggested Additional MCP Tools

get_hourly_forecast compare_city_weather get_weekend_forecast get_rain_forecast get_weather_by_coordinates get_travel_weather_summary

GitHub Workflow

After making changes:

git status git add . git commit -m "Improve weather MCP server" git push

Repository Description

Recommended GitHub About description:

Python-based MCP weather server providing current conditions and multi-day forecasts for cities worldwide using Open-Meteo and Streamable HTTP.

Recommended GitHub topics:

mcp model-context-protocol python open-meteo weather-api streamable-http httpx uv mcp-inspector

Author

Vijay Rathnavel

Senior System Simulation Engineer with 15+ years of experience in automotive simulation, thermal systems, electrified powertrains and model-based development. Currently building expertise in Python, machine learning, MLOps and MCP.

License

This project is available for learning, demonstration and portfolio purposes.

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