MCP Weather Server logo

MCP Weather Server

by mr-ransel

A FastAPI-based weather server that integrates with Home Assistant using the Model Context Protocol (MCP). It uses OpenWeatherMap's One Call API 3.0 to provide comprehensive weather information.

View on GitHub

Last updated: N/A

What is MCP Weather Server?

The MCP Weather Server is a FastAPI application that retrieves weather data from OpenWeatherMap and exposes it via a REST API and the Model Context Protocol (MCP) for integration with Home Assistant.

How to use MCP Weather Server?

  1. Clone the repository. 2. Install dependencies using pip install -r requirements.txt. 3. Configure your OpenWeatherMap API key via environment variable or config.yaml. 4. (Optional) Configure additional settings in config.yaml such as units and location overrides. 5. Run the server using python server.py. Access weather data via REST API endpoints or integrate with Home Assistant using the MCP endpoint.

Key features of MCP Weather Server

  • OpenWeatherMap One Call API 3.0 integration

  • FastAPI-based REST API

  • Model Context Protocol (MCP) support for Home Assistant integration

  • Configurable units (metric/imperial)

  • Location overrides for ambiguous city names

  • Current weather, daily forecast, and hourly forecast endpoints

Use cases of MCP Weather Server

  • Displaying weather information in Home Assistant

  • Automating home automation tasks based on weather conditions

  • Providing weather data to other applications via REST API

  • Creating custom weather dashboards

FAQ from MCP Weather Server

How do I configure my OpenWeatherMap API key?

You can configure it either by setting the environment variable OPENWEATHER_API_KEY or by adding it to the config.yaml file under settings.api_key. The environment variable takes precedence.

How do I change the units to imperial?

You can change the units to imperial by setting units: "imperial" in the config.yaml file under the settings section.

What is the MCP endpoint?

The MCP endpoint is /mcp/sse. It allows Home Assistant to communicate with the server using the Model Context Protocol.

How do I specify a default location for a city name?

You can use the overrides section in config.yaml to specify default locations for ambiguous city names. For example: overrides: {"lafayette": "Lafayette, CA, US"}

What happens if I don't provide a config.yaml file?

If no config.yaml file is present, the server will use metric units, listen on all interfaces (0.0.0.0:8000), have no location overrides, and require the API key to be set in the environment.