MCP Weather Server
Description
# MCP Weather Server A FastAPI-based weather server that integrates with Home Assistant using the Model Context Protocol (MCP). This server uses OpenWeatherMap's One Call API 3.0 to provide comprehensive weather information including current conditions, daily forecasts, and…
About
# MCP Weather Server A FastAPI-based weather server that integrates with Home Assistant using the Model Context Protocol (MCP). This server uses OpenWeatherMap's One Call API 3.0 to provide comprehensive weather information including current conditions, daily forecasts, and hourly forecasts for any location. ##…
Details
- Author
- mr-ransel
- Downloads
- 314
- Categories
- Media
Jump to
- MCP integration with Home Assistant via SSE transport
- Legacy REST API for current, daily, and hourly forecasts
- Configurable metric or imperial units (temperature, wind speed)
- Location resolution with city, “City, State” (US), and full “City, State, Country” formats
- Optional location overrides in config.yaml for ambiguous city names
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP Weather ServerCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Install Python 3.7+, obtain an OpenWeatherMap API key with One Call API 3.0 access, clone the repository, install dependencies (pip install -r requirements.txt), configure the API key via environment variable (OPENWEATHER_API_KEY) or config.yaml, optionally set units and location overrides, then run python server.py. The server exposes a legacy REST API at /api/... and an MCP SSE endpoint at /mcp/sse with tools current_weather, hourly_forecast, and daily_forecast.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp weather server": {
"openweathermap-sse-mcp-server": {
"command": "python",
"args": [
"server.py"
]
}
}
}
}
McpServers
{
"openweathermap-sse-mcp-server": {
"command": "python",
"args": [
"server.py"
]
}
}
MCP Weather Server
A FastAPI-based weather server that integrates with Home Assistant using the Model Context Protocol (MCP). This server uses OpenWeatherMap's One Call API 3.0 to provide comprehensive weather information including current conditions, daily forecasts, and hourly forecasts for any location.
Prerequisites
- Python 3.7+
- OpenWeatherMap API key (with One Call API 3.0 access)
Setup
1. Clone this repository
2. Install dependencies:
pip install -r requirements.txt
3. Configure your OpenWeather API key using one of these methods:
- Set environment variable (recommended):
export OPENWEATHER_API_KEY=your_api_key_here
- Or add it to
config.yaml: settings:
api_key: your_api_key_here
Note: Environment variable takes precedence over config file.
4. (Optional) Configure additional settings in config.yaml:
# General settings
settings:
units: "imperial" # Optional: "metric" (default) or "imperial"
api_key: "your_api_key_here" # Alternative to environment variable
server:
host: "0.0.0.0" # Optional: Interface to listen on (default: "0.0.0.0")
port: 8000 # Optional: Port to listen on (default: 8000)
# Location overrides (optional)
overrides:
"lafayette": "Lafayette, CA, US"
# Add more overrides as needed
Configuration
API Key
The OpenWeather API key can be configured in two ways: 1. Environment variableOPENWEATHER_API_KEY (recommended for security)
2. config.yaml under settings.api_key
Server Settings
Configure the server's listening interface and port inconfig.yaml:
settings:
server:
host: "0.0.0.0" # Listen on all interfaces (default)
port: 8000 # Port number (default)
- host: The network interface to listen on
- "0.0.0.0": Listen on all interfaces (default)
- "127.0.0.1": Listen only on localhost
- "192.168.1.100": Listen on a specific interface
- port: The port number to listen on (default: 8000)
Units
You can choose between metric and imperial units inconfig.yaml:
- metric (default if not specified):
- Temperature: Celsius
- Wind Speed: meters per second
- imperial:
- Temperature: Fahrenheit
- Wind Speed: miles per hour
Location Overrides
The optionaloverrides section in config.yaml allows you to specify default locations for ambiguous city names. For example:
overrides:
"lafayette": "Lafayette, CA, US"
"springfield": "Springfield, IL, US"
Default Configuration
If noconfig.yaml file is present, the server will:
- Use metric units
- Listen on all interfaces (0.0.0.0:8000)
- Have no location overrides
- Require the API key to be set in the environment
Running the Server
Start the server with:
python server.py
The server will run on the configured host and port (default: http://0.0.0.0:8000)
API Endpoints
Legacy REST API
These endpoints provide traditional HTTP access:
Current Weather
GET /api/current-weather/{location}
Returns current weather including temperature, feels like temperature, humidity, wind speed, UV index, and cloud coverage.
Daily Forecast
GET /api/daily-forecast/{location}?days={number_of_days}
Returns daily forecast for up to 7 days, including day/min/max temperatures, precipitation probability, and UV index.
Hourly Forecast
GET /api/hourly-forecast/{location}?hours={number_of_hours}
Returns hourly forecast for up to 48 hours, including temperature, feels like temperature, precipitation probability, and UV index.
MCP Integration
The server implements the Model Context Protocol (MCP) for seamless integration with Home Assistant. The MCP endpoint is available at:
/mcp/sse
MCP Tools available:
- current_weather(location: str): Get current weather conditions
- hourly_forecast(location: str, hours: int = 24): Get hourly forecast
- daily_forecast(location: str, days: int = 7): Get daily forecast
Location Resolution
The server uses a flexible location resolution system:
1. If a location matches an entry in overrides config, that override is used
2. For city names without state/country, it attempts to resolve directly
3. For "City, State" format, it assumes USA (e.g., "Portland, OR" → "Portland, Oregon, US")
4. Full "City, State, Country" format is always respected
Examples:
- "London" → "London, England, GB"
- "Lafayette" → "Lafayette, California, US" (if configured in overrides)
- "Portland, OR" → "Portland, Oregon, US"
- "Melbourne, AU" → "Melbourne, Victoria, AU"
API Response Format
Weather data is returned in either metric or imperial units based on configuration:
Metric (default):
- Temperature: Celsius - Wind Speed: meters per second - Humidity: percentage - UV Index: 0-11+ scale - Precipitation Probability: 0-1 (0-100%) - Cloud Coverage: percentageImperial:
- Temperature: Fahrenheit - Wind Speed: miles per hour - Other units same as metricExample current weather response:
{
"resolved_location": "London, England, GB",
"temperature": 17.88,
"feels_like": 17.29,
"description": "few clouds",
"humidity": 60,
"wind_speed": 5.14,
"uvi": 0,
"clouds": 11,
"timestamp": "2024-04-30T13:10:15"
}
Example daily forecast response:
{
"resolved_location": "London, England, GB",
"forecast": [
{
"date": "2024-04-30",
"temp_day": 20.3,
"temp_min": 15.1,
"temp_max": 22.4,
"description": "scattered clouds",
"humidity": 70,
"wind_speed": 4.2,
"precipitation_probability": 0.3,
"uvi": 6.1
}
]
}
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.
