About Weather Forecast Tool
Weather Forecast Tool is a Python MCP server for retrieving and summarizing forecasts from the MET Norway API. It accepts latitude and longitude and reports daily conditions in local time, including common weather symbols and temperature ranges.
Key features
- 01Fetch forecasts by latitude and longitude
- 02Summarize daily weather conditions
- 03Show common symbols by day period
- 04Report daily minimum and maximum temperatures
- 05Return forecasts in local time
Use cases
- 01Check a location's daily forecast
- 02Review expected weather by day period
- 03Compare daily minimum and maximum temperatures
- 04Retrieve a forecast using geographic coordinates
MCP support
The project uses FastMCP to register its `get_weather` function as a tool for MCP clients.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEWeather Forecast Tool
Description
This Python code provides a tool to fetch and summarize weather forecasts for a given location using the MET Norway API. It leverages the FastMCP framework for tool registration and uses httpx for asynchronous HTTP requests.
Features
-
Weather Forecast: The
get_weatherfunction retrieves weather forecast data for a specified latitude and longitude. -
Daily Summary: The
summarize_daily_timeseries_most_occurrencesfunction processes the raw forecast data to provide a concise daily summary, including:- Most frequent weather symbols for night, morning, afternoon, and evening.
- Minimum and maximum temperatures for the day.
- The forecast will be returned in local time.
-
HTTP Requests: The
make_net_requestfunction handles asynchronous HTTP requests to the MET Norway API. -
Weather Symbol Mapping: The
map_weather_symbolfunction translates weather symbol codes from the API into human-readable descriptions.
Dependencies
- Python 3.13+
collectionsdatetimetypingasynciojsonhttpxmcp.server.fastmcp
Setup
- Install Dependencies:
Install MCP and other dependencies as needed (see MCP documentation)
- Obtain Coordinates: You'll need the latitude and longitude for the location you want the weather forecast for.
Usage
-
Import: Import the necessary modules and initialize the FastMCP server.
from collections import Counter from datetime import datetime, timezone, timedelta from mcp.server.fastmcp import FastMCP from typing import Any import asyncio import json import httpx mcp = FastMCP("weather") -
Use the
get_weathertool:async def main(): weather_data = await get_weather(55.6761, 12.5683) # Example: Copenhagen, Denmark print(weather_data) if __name__ == "__main__": asyncio.run(main())Replace
55.6761and12.5683with the desired latitude and longitude.
Tool Definition
* get_weather(latitude: float, longitude: float) -> str
* Retrieves and formats the weather forecast for a given location.
* Arguments:
* latitude (float): The latitude of the location.
* longitude (float): The longitude of the location.
* Returns:
* str: A formatted string containing the daily weather forecast.
MCP
The code uses the FastMCP framework. Please refer to the FastMCP documentation for details on how to set up and run the server.
License
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.