Weather MCP server which returns 7 days of detailed weather forecasts anywhere in the world
A weather forecast MCP (Model Context Protocol) server providing 8-day global weather forecasts and current weather conditions using the OpenWeatherMap One Call API 3.0.
This project builds upon an earlier project by Zippland, with modifications to support full week forecasts and additional time-of-day data points.
Animation showing Claude Desktop processing the weather data from the MCP Server
Claude Desktop showing a detailed weather forecast with lawn mowing recommendations
The One Call API 3.0 provides comprehensive weather data:
Note: API key activation can take several minutes up to an hour. If you receive authentication errors shortly after subscribing or generating a new key, wait a bit and try again later.
# Clone the repository
git clone https://github.com/rossshannon/weekly-weather-mcp.git
cd weekly-weather-mcp
# Create a virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # Linux/Mac
# OR
venv\Scripts\activate # Windows
# Install dependencies
pip3 install -r requirements.txt
This will install all the necessary dependencies to run the server and development tools.
There are two ways to provide the API key:
# Set environment variables
export OPENWEATHER_API_KEY="your_api_key" # Linux/Mac
set OPENWEATHER_API_KEY=your_api_key # Windows
# Run the server
python weather_mcp_server.py
Run directly without setting environment variables:
python weather_mcp_server.py
When calling the tool, you’ll need to provide the api_key
parameter.
Add the following configuration to your MCP-supported client (e.g., Claude Desktop (instructions), Cursor):
{
"weather_forecast": {
"command": "python3",
"args": [
"/full_path/weather_mcp_server.py"
],
"env": {
"OPENWEATHER_API_KEY": "your_openweathermap_key_here"
},
"disabled": false,
"autoApprove": ["get_weather", "get_current_weather"]
}
}
If you’re using a virtual environment, your configuration should include the full path to the Python executable in the virtual environment:
{
"weather_forecast": {
"command": "/full_path/venv/bin/python3",
"args": [
"/full_path/weather_mcp_server.py"
],
"env": {
"OPENWEATHER_API_KEY": "your_openweathermap_key_here"
},
"disabled": false,
"autoApprove": ["get_weather", "get_current_weather"]
}
}
The server exposes two tools, get_weather
and get_current_weather
. Both tools accept the same parameters:
location
: Location name as a string, e.g., “Beijing”, “New York”, “Tokyo”. The tool will handle geocoding this to a latitude/longitude coordinate.api_key
: OpenWeatherMap API key (optional, will read from environment variable if not provided)timezone_offset
: Timezone offset in hours, e.g., 8 for Beijing, -4 for New York. Default is 0 (UTC time). Times in the returned data will be accurate for this timezone.Get comprehensive weather data for a location including current weather (next 48 hours) and 8-day forecast with detailed information.
Returns:
Perfect for use cases like:
Get current weather for a specified location.
Returns:
get_weather
The location
parameter uses OpenWeatherMap’s geocoding to convert location names to geographic coordinates:
If a location can’t be found, the API will return an error. In case of ambiguous locations, try adding country or state codes for more precise results.
User: What’s the weather like in New York right now?
AI: Let me check the current weather in New York for you.
[Calling get_current_weather("New York", timezone_offset=-4)]
Current weather in New York: 5°C, few clouds, humidity 42%, wind speed 4.1m/s.
User: I need to mow my lawn this week in Boston. Which day would be best?
AI: Let me check the weather forecast for Boston to find the best day for lawn mowing.
[Calling get_weather("Boston", timezone_offset=-4)]
Looking at the Boston forecast for the week:
- Today (Monday): Light rain (28% chance), 5°C
- Tuesday: Clear, sunny, 10°C
- Wednesday: Light rain (100% chance), 9°C
- Thursday: Moderate rain (100% chance), 10°C
- Friday: Moderate rain (100% chance), 11°C
- Saturday: Partly cloudy, 13°C
- Sunday: Scattered clouds, 17°C
Tuesday would be your best option for mowing the lawn. It will be clear and sunny with no chance of rain, and the temperature will be comfortable at around 10°C.
You can combine this MCP server with others to achieve multi-step workflows. For example, once the weather has been checked, you can also tell Claude to add that as an event in your calendar to remind yourself of those plans.
Calendar event created by Claude based on the weather forecast
If you encounter an “Invalid API key” or authorization error:
OPENWEATHER_API_KEY
correctly in environment variables, or check that you’re providing the correct api_key
parameter when calling the tools“Location not found” error:
Incorrect location returned:
Rate limiting (429 error): You’ve exceeded your API call limit. Check your OpenWeatherMap account settings.
This project includes unit tests, integration tests, and mock client test files to validate the MCP server functionality. The server has been manually tested to ensure it works correctly with Claude Desktop, Cursor, and other MCP clients.
Before configuring the server with Claude Desktop or other MCP clients, you can use the included test script to verify your API key and installation:
Set your OpenWeatherMap API key:
export OPENWEATHER_API_KEY="your_api_key"
Run the test client:
python3 test_mcp_client.py
The test script directly calls the weather functions to check the current weather in New York and displays the results. This helps verify that:
If the test shows current weather data, you’re ready to configure the server with Claude Desktop, Cursor, or other MCP clients!
Running local test client to verify API key and installation
The repository includes unit and integration test files that:
get_weather
and get_current_weather
These tests require proper setup of the development environment with all dependencies installed. They’re provided as reference for future development.
To run the automated tests:
# Run unit tests
python test_weather_mcp.py
# Run integration tests
python test_mcp_integration.py
The tests use a sample API response (test_weather_response.json
) to simulate responses from the OpenWeatherMap API, so they can be run without an API key or internet connection.
These tests are provided as reference for future development and to ensure the MCP server continues to function correctly after any modifications.
This project is adapted from an original Weather MCP by Zippland. The modifications include: