#
tokens: 26292/50000 9/9 files
lines: off (toggle) GitHub
raw markdown copy
# Directory Structure

```
├── CLAUDE.md
├── LICENSE
├── mcp_client_config.json
├── README.md
├── requirements.txt
├── test_mcp_client.py
├── test_mcp_integration.py
├── test_weather_mcp.py
├── test_weather_response.json
└── weather_mcp_server.py
```

# Files

--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------

```markdown
# 🌦️ Weekly Weather MCP Server

A weather forecast MCP (Model Context Protocol) server providing **8-day global weather forecasts** and current weather conditions using the [OpenWeatherMap](https://openweathermap.org) [One Call API 3.0](https://openweathermap.org/api/one-call-3).

> This project builds upon an earlier project by [Zippland](https://github.com/Zippland/weather-mcp), with modifications to support full week forecasts and additional time-of-day data points.

<div align="center">
  <img src="https://rossshannon.github.io/weekly-weather-mcp/images/weather-mcp-thinking.gif" alt="Claude calling MCP server" width="800">
  <p><em>Animation showing Claude Desktop processing the weather data from the MCP Server</em></p>
</div>
<br>
<div align="center">
  <img src="https://rossshannon.github.io/weekly-weather-mcp/images/weather-forecast-example.png" alt="Claude displaying weather forecast" width="700">
  <p><em>Claude Desktop showing a detailed weather forecast with lawn mowing recommendations</em></p>
</div>

## Features

- 🌍 Support for querying weather conditions anywhere in the world
- 🌤️ Hourly forecasts for the next 48 hours
- 📅 Provides detailed 8-day forecasts (today + following 7 days), with morning, afternoon, and evening data points
- 🌧️ Weather summaries and precipitation probabilities
- 🌡️ Detailed weather information including temperature, humidity, wind speed, etc.
- 📍 Support for reporting results in different time zones
- 🗂️ No separate configuration file needed; API key can be passed directly through environment variables or parameters

## Usage

### 1. Get an OpenWeatherMap API Key with One Call API 3.0 Access (free)

1. Visit [OpenWeatherMap](https://openweathermap.org/) and register an account
2. Subscribe to the “One Call API 3.0” plan (offers 1,000 API calls per day for free)
3. Wait for API key activation (this can take up to an hour)

#### About the One Call API 3.0

The One Call API 3.0 provides comprehensive weather data:
- Current weather conditions
- Minute forecast for 1 hour
- Hourly forecast for 48 hours
- Daily forecast for 8 days (including today)
- National weather alerts
- Historical weather data

#### API Usage and Limits

- **Free tier**: 1,000 API calls per day
- **Default limit**: 2,000 API calls per day (can be adjusted in your account)
- **Billing**: Any calls beyond the free 1,000/day will be charged according to OpenWeatherMap pricing
- **Usage cap**: You can set a call limit in your account to prevent exceeding your budget (including capping your usage at the free tier limit so no costs can be incurred)
- If you reach your limit, you’ll receive a HTTP 429 error response

> **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.

### 2. Clone the Repository and Install Dependencies

```bash
# 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.

### 3. Run the Server

There are two ways to provide the API key:

#### Method 1: Using Environment Variables

```bash
# 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
```

#### Method 2: Provide When Calling the Tool

Run directly without setting environment variables:

```bash
python weather_mcp_server.py
```

When calling the tool, you’ll need to provide the `api_key` parameter.

### 4. Use in MCP Client Configuration

Add the following configuration to your MCP-supported client (e.g., [Claude Desktop](https://www.anthropic.com/claude-desktop) ([instructions](https://modelcontextprotocol.io/quickstart/user)), [Cursor](https://www.cursor.com/)):

```json
{
  "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:

```json
{
  "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"]
  }
}
```

### 5. Available Tools

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_weather

Get comprehensive weather data for a location including current weather (next 48 hours) and 8-day forecast with detailed information.

Returns:
- Current weather information
- Hourly forecasts for the next 48 hours
- Daily forecasts for 8 days (today + 7 days ahead)
- Morning (9 AM), afternoon (3 PM), and evening (8 PM) data points for each day
- Weather summaries and precipitation probabilities
- Detailed weather information including temperature, humidity, wind speed, etc.

Perfect for use cases like:
- “🏃‍♂️ Which days this week should I go for a run?”
- “🪴 When’s the best evening to work in my garden this week?”
- “🪁 What’s the windiest day coming up soon for flying a kite?”
- “💧 Will I need to water my garden this week or will rain take care of it?”

#### get_current_weather

Get current weather for a specified location.

Returns:
- A simplified subset of the data returned by `get_weather`
- Only the current weather information (temperature, feels like, weather condition, humidity, wind, etc.); no forecast data for future time periods
- Useful for quick queries about present conditions only

##### Location Lookup Details

The `location` parameter uses OpenWeatherMap’s geocoding to convert location names to geographic coordinates:

- Simple location names work: “Paris”, “Tokyo”, “New York”
- For better accuracy, include country codes: “Paris,FR”, “London,GB”, “Portland,US”
- For US cities, you can include state: “Portland,OR,US” or “Portland,ME,US”
- The API supports any location on Earth that OpenWeatherMap can geocode
- Location names are converted to latitude/longitude coordinates internally

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.

## Usage Examples

### Example 1: Current Weather

```
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.
```

### Example 2: Weekly Planning

```
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.

<div align="center">
  <img src="https://rossshannon.github.io/weekly-weather-mcp/images/calendar-integration-example.png" alt="Calendar event created by Claude" width="365">
  <p><em>Calendar event created by Claude based on the weather forecast</em></p>
</div>

## Troubleshooting

### API Key Issues

If you encounter an “Invalid API key” or authorization error:
1. Make sure you’ve subscribed to the “One Call API 3.0” plan. You’ll need a debit or credit card to enable your account, but you’ll only be charged if you exceed the free tier limit.
2. Remember that API key activation can take up to an hour
3. Verify you have set the `OPENWEATHER_API_KEY` correctly in environment variables, or check that you’re providing the correct `api_key` parameter when calling the tools

### Other Common Issues

- **“Location not found” error**:
  - Check for typos in location names
  - Some very small or remote locations might not be in OpenWeatherMap’s database

- **Incorrect location returned**:
  - Try using a more accurate city name or add a country code, e.g., “Beijing,CN” or “Porto,PT”
  - For US cities with common names, specify the state: “Springfield,IL,US” or “Portland,OR,US”
  - For cities with the same name in different countries, always include the country code and state if applicable: “Paris,FR” for Paris, France vs “Paris,TX,US” for Paris, Texas, USA.

- **Rate limiting (429 error)**: You’ve exceeded your API call limit. Check your OpenWeatherMap account settings.

## Development and Testing

### Testing

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.

#### Manual Client Testing

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:

1. Set your OpenWeatherMap API key:
   ```bash
   export OPENWEATHER_API_KEY="your_api_key"
   ```

2. Run the test client:
   ```bash
   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:
1. Your API key is working properly
2. The OpenWeatherMap API is accessible
3. The weather data functions are operational

If the test shows current weather data, you’re ready to configure the server with Claude Desktop, Cursor, or other MCP clients!

<div align="center">
  <img src="https://rossshannon.github.io/weekly-weather-mcp/images/weather-mcp-test-client.png" alt="Running local test client" width="800">
  <p><em>Running local test client to verify API key and installation</em></p>
</div>

#### Automated Tests

The repository includes unit and integration test files that:
- Test API key handling and validation
- Validate data parsing and formatting
- Verify error handling for API failures
- Test both exposed MCP tools: `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:

```bash
# 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.

## Credits

This project is adapted from an original [Weather MCP](https://github.com/Zippland/weather-mcp) by Zippland. The modifications include:

- Integration with OpenWeatherMap One Call API 3.0
- Extended forecast data from 2 days to 8 days (today + 7 days)
- Addition of morning, afternoon and evening data points for each day
- Hourly forecasts for the next 48 hours
- Inclusion of weather summaries, wind speed, and precipitation probabilities
- Unit tests, integration tests, and mock client test files

```

--------------------------------------------------------------------------------
/CLAUDE.md:
--------------------------------------------------------------------------------

```markdown
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Commands
- Run server: `python3 weather_mcp_server.py`
- Install dependencies: `pip3 install mcp-server requests pydantic`
- Format code: `black --skip-string-normalization weather_mcp_server.py`
- Typecheck: `mypy weather_mcp_server.py --strict`
- Run test client: `python3 test_mcp_client.py`

## Style Guidelines
- **Python Version**: 3.6+
- **Code Style**: PEP 8 compliant
- **Imports**: Group standard library, third-party, and local imports with newlines between groups
- **Type Hints**: Use type annotations for all function parameters and return values
- **Error Handling**: Use try/except blocks with specific exception types
- **Docstrings**: Use triple-quoted docstrings for all functions and classes
- **Naming**: Use snake_case for variables and functions, PascalCase for classes
- **API Key Handling**: Never hardcode API keys; use environment variables or parameters

## Architecture Notes
- Single-file MCP server based on FastMCP for OpenWeatherMap API
- Pydantic models for data validation and serialization
- Functions handle API requests with proper error handling

```

--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------

```
# Core dependencies - required for running the application
mcp-server>=0.1.3
fastmcp>=0.4.1
requests>=2.32.0
pydantic>=2.0.0

# Development dependencies - required for testing, formatting, and type checking
pytest>=7.0.0
black>=23.0.0
mypy>=1.0.0

```

--------------------------------------------------------------------------------
/mcp_client_config.json:
--------------------------------------------------------------------------------

```json
{
  "weather_forecast": {
    "command": "python",
    "args": [
      "weather_mcp_server.py"
    ],
    "env": {
      "OPENWEATHER_API_KEY": "your_openweathermap_api_key_here"
    },
    "disabled": false,
    "autoApprove": ["get_weather", "get_current_weather"]
  }
} 
```

--------------------------------------------------------------------------------
/test_mcp_client.py:
--------------------------------------------------------------------------------

```python
#!/usr/bin/env python3
"""
Simple test script for the Weather MCP Server

This script directly imports the functions from the weather_mcp_server.py
file and tests them without going through the MCP server protocol.
"""
import os
import sys
from weather_mcp_server import get_current_weather, get_weather

def main():
    """Test the weather server functions directly"""
    # Check if API key is set
    api_key = os.environ.get("OPENWEATHER_API_KEY")
    if not api_key:
        print("Error: OPENWEATHER_API_KEY environment variable not set")
        print("Please set the environment variable and try again:")
        print("  export OPENWEATHER_API_KEY=your_key_here")
        return
    print("Using API key from environment variables")

    # Location to test
    location = "New York"
    timezone_offset = -4
    
    print(f"\nTesting get_current_weather for {location}...")
    try:
        result = get_current_weather(location, api_key, timezone_offset)
        
        if 'error' in result:
            print(f"Error: {result['error']}")
        else:
            print("\nCurrent Weather:")
            print(f"Temperature: {result['temperature']}")
            print(f"Conditions: {result['weather_condition']}")
            print(f"Humidity: {result['humidity']}")
            print(f"Wind: {result['wind']['speed']} at {result['wind']['direction']}")
    except Exception as e:
        print(f"Error during execution: {str(e)}")
        import traceback
        traceback.print_exc()
    
    print(f"\nTesting get_weather (8-day forecast) for {location}...")
    try:
        result = get_weather(location, api_key, timezone_offset)
        
        if 'error' in result:
            print(f"Error: {result['error']}")
        else:
            print("\nWeather Forecast Summary:")
            print(f"Current Temperature: {result['current']['temperature']}")
            print(f"Current Conditions: {result['current']['weather_condition']}")
            print(f"\nForecasted Days: {len(result['daily_forecasts'])}")
            
            # Print a summary of each day's forecast
            print("\nDaily Forecasts:")
            for i, day in enumerate(result['daily_forecasts']):
                print(f"Day {i+1} ({day['date']}): {day['summary']}")
                
                # Find the afternoon entry for a temperature estimate
                afternoon_entries = [entry for entry in day['entries'] 
                                    if '15:00:00' in entry['time']]
                if afternoon_entries:
                    temp = afternoon_entries[0]['temperature']
                    condition = afternoon_entries[0]['weather_condition']
                    pop = afternoon_entries[0].get('pop', 'N/A')
                    print(f"  Afternoon: {temp}, {condition}, Precip: {pop}")
    except Exception as e:
        print(f"Error during execution: {str(e)}")
        import traceback
        traceback.print_exc()
    
    print("\nTest complete")

if __name__ == "__main__":
    main()
```

--------------------------------------------------------------------------------
/test_mcp_integration.py:
--------------------------------------------------------------------------------

```python
#!/usr/bin/env python3
"""
Integration tests for the Weather MCP Server
"""

import unittest
from unittest.mock import patch, MagicMock
import json
import os
import sys

# Try to import weather_mcp_server, but if mcp package is missing, mock it
try:
    import weather_mcp_server
except ModuleNotFoundError:
    # Create a mock for the FastMCP class
    sys.modules['mcp'] = MagicMock()
    sys.modules['mcp.server'] = MagicMock()
    sys.modules['mcp.server.fastmcp'] = MagicMock()
    sys.modules['mcp.server.fastmcp'].FastMCP = MagicMock()

    # Now import should work
    import weather_mcp_server


class TestMCPIntegration(unittest.TestCase):
    """Test the MCP server integration functionality"""

    def setUp(self):
        """Set up test environment"""
        # Clear environment variable to ensure tests control it
        if "OPENWEATHER_API_KEY" in os.environ:
            self.original_api_key = os.environ["OPENWEATHER_API_KEY"]
            del os.environ["OPENWEATHER_API_KEY"]
        else:
            self.original_api_key = None

        # Sample test data
        self.test_location = "New York"
        self.test_api_key = "test_api_key_123"
        self.test_timezone_offset = -4

        # Load sample response data
        with open("test_weather_response.json") as f:
            self.sample_onecall_data = json.load(f)

    def tearDown(self):
        """Clean up after tests"""
        # Restore original environment if it existed
        if self.original_api_key is not None:
            os.environ["OPENWEATHER_API_KEY"] = self.original_api_key
        elif "OPENWEATHER_API_KEY" in os.environ:
            del os.environ["OPENWEATHER_API_KEY"]

    @patch('requests.get')
    def test_mcp_get_weather_tool(self, mock_get):
        """Test the MCP get_weather tool with a simulated API response"""
        # Sample locations response
        locations_response = MagicMock()
        locations_response.status_code = 200
        locations_response.json.return_value = {
            "coord": {"lon": -74.006, "lat": 40.7128},
            "weather": [{"id": 800, "main": "Clear", "description": "clear sky", "icon": "01d"}],
            "main": {
                "temp": 5.46, "feels_like": 0.42, "temp_min": 4.0, "temp_max": 6.5,
                "pressure": 1006, "humidity": 36
            },
            "wind": {"speed": 9.17, "deg": 298},
            "clouds": {"all": 20},
            "name": "New York"
        }

        # Sample forecast response
        forecast_response = MagicMock()
        forecast_response.status_code = 200
        forecast_response.json.return_value = {
            "list": [
                # Today's forecast entries
                {
                    "dt": 1744128000,  # Today
                    "main": {
                        "temp": 5.0, "feels_like": 2.0, "temp_min": 4.0, "temp_max": 6.0,
                        "humidity": 40, "pressure": 1006
                    },
                    "weather": [{"description": "clear sky"}],
                    "clouds": {"all": 10},
                    "wind": {"speed": 5.0, "deg": 270}
                },
                # Tomorrow's forecast entries
                {
                    "dt": 1744214400,  # Tomorrow
                    "main": {
                        "temp": 6.0, "feels_like": 3.0, "temp_min": 5.0, "temp_max": 7.0,
                        "humidity": 45, "pressure": 1008
                    },
                    "weather": [{"description": "scattered clouds"}],
                    "clouds": {"all": 30},
                    "wind": {"speed": 4.5, "deg": 280}
                }
            ],
            "city": {"name": "New York"}
        }

        # Mock the geocoding API response
        geocoding_response = MagicMock()
        geocoding_response.status_code = 200
        geocoding_response.json.return_value = [
            {"name": "New York", "lat": 40.7128, "lon": -74.0060}
        ]

        # Mock the One Call API response
        onecall_response = MagicMock()
        onecall_response.status_code = 200
        onecall_response.json.return_value = {
            "lat": 40.7128,
            "lon": -74.0060,
            "timezone": "America/New_York",
            "timezone_offset": -14400,
            "current": {
                "dt": 1617979000,
                "temp": 15.2,
                "feels_like": 14.3,
                "humidity": 76,
                "wind_speed": 2.06,
                "wind_deg": 210,
                "weather": [{"description": "clear sky"}],
                "clouds": 1
            },
            "daily": [
                {
                    "dt": 1617979000,
                    "temp": {"day": 15.0, "min": 9.0, "max": 17.0, "eve": 13.0, "morn": 10.0},
                    "feels_like": {"day": 14.3, "night": 8.5, "eve": 12.5, "morn": 9.5},
                    "humidity": 76,
                    "wind_speed": 2.06,
                    "wind_deg": 210,
                    "weather": [{"description": "clear sky"}],
                    "clouds": 1,
                    "pop": 0.2,
                    "summary": "Nice day"
                }
            ],
            "hourly": [
                {
                    "dt": 1617979000,
                    "temp": 15.2,
                    "feels_like": 14.3,
                    "humidity": 76,
                    "wind_speed": 2.06,
                    "wind_deg": 210,
                    "weather": [{"description": "clear sky"}],
                    "clouds": 1,
                    "pop": 0.2
                }
            ]
        }

        # Configure the mock to return different responses for different URLs
        def side_effect(url, *args, **kwargs):
            if "onecall" in url:
                return onecall_response
            elif "geo" in url:
                return geocoding_response
            else:
                return geocoding_response

        mock_get.side_effect = side_effect

        # Set up the API key in environment
        os.environ["OPENWEATHER_API_KEY"] = self.test_api_key

        # Call the MCP tool function
        result = weather_mcp_server.get_weather(
            location=self.test_location,
            timezone_offset=self.test_timezone_offset
        )

        # Verify the result structure
        self.assertIn('daily_forecasts', result)
        self.assertIn('current', result)
        self.assertTrue(len(result['daily_forecasts']) > 0)

        # Check current weather info
        current = result['current']
        self.assertIn('temperature', current)
        self.assertIn('feels_like', current)
        self.assertIn('weather_condition', current)
        self.assertIn('humidity', current)
        self.assertIn('wind', current)

    @patch('requests.get')
    def test_mcp_get_current_weather_tool(self, mock_get):
        """Test the MCP get_current_weather tool with a simulated API response"""
        # Mock the geocoding API response
        geocoding_response = MagicMock()
        geocoding_response.status_code = 200
        geocoding_response.json.return_value = [
            {"name": "New York", "lat": 40.7128, "lon": -74.0060}
        ]

        # Mock the One Call API response
        onecall_response = MagicMock()
        onecall_response.status_code = 200
        onecall_response.json.return_value = {
            "lat": 40.7128,
            "lon": -74.0060,
            "timezone": "America/New_York",
            "timezone_offset": -14400,
            "current": {
                "dt": 1617979000,
                "temp": 15.2,
                "feels_like": 14.3,
                "humidity": 76,
                "wind_speed": 2.06,
                "wind_deg": 210,
                "weather": [{"description": "clear sky"}],
                "clouds": 1
            },
            "daily": [],
            "hourly": []
        }

        # Configure the mock to return different responses for different URLs
        def side_effect(url, *args, **kwargs):
            if "onecall" in url:
                return onecall_response
            elif "geo" in url:
                return geocoding_response
            else:
                return geocoding_response

        mock_get.side_effect = side_effect

        # Set up the API key in environment
        os.environ["OPENWEATHER_API_KEY"] = self.test_api_key

        # Call the MCP tool function
        result = weather_mcp_server.get_current_weather(
            location=self.test_location,
            timezone_offset=self.test_timezone_offset
        )

        # Verify the result is just the current weather
        self.assertIn('temperature', result)
        self.assertIn('feels_like', result)
        self.assertIn('weather_condition', result)
        self.assertIn('humidity', result)
        self.assertIn('wind', result)

    @patch('requests.get')
    def test_api_key_parameter_overrides_env(self, mock_get):
        """Test that API key provided as parameter overrides the environment variable"""
        # Mock geocoding response
        mock_geocoding = MagicMock()
        mock_geocoding.status_code = 200
        mock_geocoding.json.return_value = [
            {"name": "New York", "lat": 40.7128, "lon": -74.0060}
        ]

        # Mock One Call API response
        mock_onecall = MagicMock()
        mock_onecall.status_code = 200
        mock_onecall.json.return_value = {
            "lat": 40.7128,
            "lon": -74.0060,
            "current": {"temp": 15, "feels_like": 14, "humidity": 70,
                       "weather": [{"description": "clear"}], "wind_speed": 5, "wind_deg": 270}
        }

        # Track which API key was used
        param_api_key_used = [False]
        env_api_key_used = [False]

        # Configure the side effect to return the appropriate mock based on the URL
        def side_effect(url, *args, **kwargs):
            if "param_api_key" in url:
                param_api_key_used[0] = True
            if "env_api_key" in url:
                env_api_key_used[0] = True

            if "geo/1.0/direct" in url or "geo" in url:
                return mock_geocoding
            else:
                return mock_onecall

        mock_get.side_effect = side_effect

        # Set up environment API key
        os.environ["OPENWEATHER_API_KEY"] = "env_api_key"

        # Call the function with a different API key parameter
        weather_mcp_server.get_current_weather(
            location=self.test_location,
            api_key="param_api_key",
            timezone_offset=self.test_timezone_offset
        )

        # Check that the parameter API key was used in the request
        self.assertTrue(param_api_key_used[0], "Parameter API key wasn't used")
        self.assertFalse(env_api_key_used[0], "Environment API key was incorrectly used")


if __name__ == '__main__':
    unittest.main()

```

--------------------------------------------------------------------------------
/weather_mcp_server.py:
--------------------------------------------------------------------------------

```python
# weather_mcp_server.py
from mcp.server.fastmcp import FastMCP
from pydantic import BaseModel, Field
from typing import List, Dict, Any, Optional, Union
import requests
from datetime import datetime, timedelta, timezone
import os

# Create MCP server instance
mcp = FastMCP(
    name="WeatherForecastServer",
    description="Provides global weather forecasts and current weather conditions",
    version="1.2.0"
)

# Define data models
class WindInfo(BaseModel):
    speed: str = Field(..., description="Wind speed in meters per second")
    direction: str = Field(..., description="Wind direction in degrees")

class WeatherEntry(BaseModel):
    time: str = Field(..., description="Time of the weather data")
    temperature: str = Field(..., description="Temperature in Celsius")
    feels_like: str = Field(..., description="Feels like temperature in Celsius")
    temp_min: str = Field(..., description="Minimum temperature in Celsius")
    temp_max: str = Field(..., description="Maximum temperature in Celsius")
    weather_condition: str = Field(..., description="Weather condition description")
    humidity: str = Field(..., description="Humidity percentage")
    wind: WindInfo = Field(..., description="Wind speed and direction information")
    rain: str = Field(..., description="Rainfall amount")
    clouds: str = Field(..., description="Cloud coverage percentage")
    pop: Optional[str] = Field(None, description="Probability of precipitation")

class DailyForecast(BaseModel):
    date: str = Field(..., description="Date of the forecast in YYYY-MM-DD format")
    entries: List[WeatherEntry] = Field(..., description="Weather entries for this day")
    summary: Optional[str] = Field(None, description="Summary of the day's weather")

class WeatherForecast(BaseModel):
    daily_forecasts: List[DailyForecast] = Field(..., description="Weather forecasts for up to 8 days, including today")
    current: WeatherEntry = Field(..., description="Current weather information")

# Helper function to get API key
def get_api_key(provided_key: Optional[str] = None) -> str:
    """
    Get API key, prioritizing parameter-provided key, then trying to read from environment variables

    Parameters:
        provided_key: User-provided API key (optional)

    Returns:
        API key string
    """
    if provided_key:
        return provided_key

    env_key = os.environ.get("OPENWEATHER_API_KEY")
    if env_key:
        return env_key

    raise ValueError("No API key provided and no OPENWEATHER_API_KEY found in environment variables")

# Function to get location coordinates using Geocoding API
def get_coordinates(location, api_key):
    """
    Get geographic coordinates for a location name using Geocoding API

    Parameters:
        location: Location name as string
        api_key: OpenWeatherMap API key

    Returns:
        Tuple of (latitude, longitude)
    """
    try:
        # First try the Geocoding API
        geocode_url = f"https://api.openweathermap.org/geo/1.0/direct?q={location}&limit=1&appid={api_key}"
        response = requests.get(geocode_url)
        response.raise_for_status()
        data = response.json()

        if data and len(data) > 0:
            return data[0]['lat'], data[0]['lon']

        # Fallback to current weather API if geocoding fails
        print("Geocoding API failed, falling back to current weather API for coordinates")
        fallback_url = f"https://api.openweathermap.org/data/2.5/weather?q={location}&appid={api_key}&units=metric"
        response = requests.get(fallback_url)
        response.raise_for_status()
        data = response.json()

        return data['coord']['lat'], data['coord']['lon']
    except Exception as e:
        print(f"Error getting coordinates: {str(e)}")
        raise

# Function to format timestamp to human-readable time
def format_timestamp(ts, tz_offset):
    """
    Convert Unix timestamp to human-readable time

    Parameters:
        ts: Unix timestamp
        tz_offset: Timezone offset in hours

    Returns:
        Formatted time string
    """
    tz = timezone(timedelta(hours=tz_offset))
    dt = datetime.fromtimestamp(ts, tz)
    return dt.strftime('%Y-%m-%d %H:%M:%S')

# Core weather forecast function using One Call API 3.0
def get_weather_forecast(present_location, time_zone_offset, api_key=None):
    # Get API key
    try:
        api_key = get_api_key(api_key)
    except ValueError as e:
        return {'error': str(e)}

    try:
        # Get geographic coordinates
        lat, lon = get_coordinates(present_location, api_key)

        # Call One Call API 3.0
        onecall_url = f"https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&appid={api_key}&units=metric"

        response = requests.get(onecall_url)
        response.raise_for_status()
        data = response.json()

        # Set timezone
        tz = timezone(timedelta(hours=time_zone_offset))

        # Process current weather
        current = data.get('current', {})
        current_weather = {
            'time': format_timestamp(current.get('dt', 0), time_zone_offset),
            'temperature': f"{current.get('temp', 0)} °C",
            'feels_like': f"{current.get('feels_like', 0)} °C",
            'temp_min': "N/A",  # One Call doesn't provide min/max in current
            'temp_max': "N/A",
            'weather_condition': current.get('weather', [{}])[0].get('description', 'Unknown'),
            'humidity': f"{current.get('humidity', 0)}%",
            'wind': {
                'speed': f"{current.get('wind_speed', 0)} m/s",
                'direction': f"{current.get('wind_deg', 0)} degrees"
            },
            'rain': f"{current.get('rain', {}).get('1h', 0)} mm/h" if 'rain' in current else 'No rain',
            'clouds': f"{current.get('clouds', 0)}%",
            'pop': "N/A"  # One Call doesn't provide precipitation probability in current
        }

        # Process daily forecasts
        forecasts_by_date = {}

        for day in data.get('daily', []):
            dt = datetime.fromtimestamp(day.get('dt', 0), tz)
            date_str = dt.date().strftime('%Y-%m-%d')

            # Initialize this date in the dictionary if needed
            if date_str not in forecasts_by_date:
                forecasts_by_date[date_str] = {
                    'entries': [],
                    'summary': day.get('summary', '')
                }

            # Create a forecast entry for this day
            forecast_entry = {
                'time': format_timestamp(day.get('dt', 0), time_zone_offset),
                'temperature': f"{day.get('temp', {}).get('day', 0)} °C",
                'feels_like': f"{day.get('feels_like', {}).get('day', 0)} °C",
                'temp_min': f"{day.get('temp', {}).get('min', 0)} °C",
                'temp_max': f"{day.get('temp', {}).get('max', 0)} °C",
                'weather_condition': day.get('weather', [{}])[0].get('description', 'Unknown'),
                'humidity': f"{day.get('humidity', 0)}%",
                'wind': {
                    'speed': f"{day.get('wind_speed', 0)} m/s",
                    'direction': f"{day.get('wind_deg', 0)} degrees"
                },
                'rain': f"{day.get('rain', 0)} mm" if 'rain' in day else 'No rain',
                'clouds': f"{day.get('clouds', 0)}%",
                'pop': f"{day.get('pop', 0) * 100}%"  # Convert to percentage
            }

            forecasts_by_date[date_str]['entries'].append(forecast_entry)

            # Add morning, afternoon, evening entries for richer data
            # These entries help with use cases like "when should I mow my lawn"
            day_temps = day.get('temp', {})
            feels_like = day.get('feels_like', {})

            # Morning entry (9 AM)
            morning_time = dt.replace(hour=9, minute=0, second=0)
            forecasts_by_date[date_str]['entries'].append({
                'time': morning_time.strftime('%Y-%m-%d %H:%M:%S'),
                'temperature': f"{day_temps.get('morn', 0)} °C",
                'feels_like': f"{feels_like.get('morn', 0)} °C",
                'temp_min': f"{day_temps.get('min', 0)} °C",
                'temp_max': f"{day_temps.get('max', 0)} °C",
                'weather_condition': day.get('weather', [{}])[0].get('description', 'Unknown'),
                'humidity': f"{day.get('humidity', 0)}%",
                'wind': {
                    'speed': f"{day.get('wind_speed', 0)} m/s",
                    'direction': f"{day.get('wind_deg', 0)} degrees"
                },
                'rain': f"{day.get('rain', 0)} mm" if 'rain' in day else 'No rain',
                'clouds': f"{day.get('clouds', 0)}%",
                'pop': f"{day.get('pop', 0) * 100}%"
            })

            # Afternoon entry (15 PM)
            afternoon_time = dt.replace(hour=15, minute=0, second=0)
            forecasts_by_date[date_str]['entries'].append({
                'time': afternoon_time.strftime('%Y-%m-%d %H:%M:%S'),
                'temperature': f"{day_temps.get('day', 0)} °C",
                'feels_like': f"{feels_like.get('day', 0)} °C",
                'temp_min': f"{day_temps.get('min', 0)} °C",
                'temp_max': f"{day_temps.get('max', 0)} °C",
                'weather_condition': day.get('weather', [{}])[0].get('description', 'Unknown'),
                'humidity': f"{day.get('humidity', 0)}%",
                'wind': {
                    'speed': f"{day.get('wind_speed', 0)} m/s",
                    'direction': f"{day.get('wind_deg', 0)} degrees"
                },
                'rain': f"{day.get('rain', 0)} mm" if 'rain' in day else 'No rain',
                'clouds': f"{day.get('clouds', 0)}%",
                'pop': f"{day.get('pop', 0) * 100}%"
            })

            # Evening entry (20 PM)
            evening_time = dt.replace(hour=20, minute=0, second=0)
            forecasts_by_date[date_str]['entries'].append({
                'time': evening_time.strftime('%Y-%m-%d %H:%M:%S'),
                'temperature': f"{day_temps.get('eve', 0)} °C",
                'feels_like': f"{feels_like.get('eve', 0)} °C",
                'temp_min': f"{day_temps.get('min', 0)} °C",
                'temp_max': f"{day_temps.get('max', 0)} °C",
                'weather_condition': day.get('weather', [{}])[0].get('description', 'Unknown'),
                'humidity': f"{day.get('humidity', 0)}%",
                'wind': {
                    'speed': f"{day.get('wind_speed', 0)} m/s",
                    'direction': f"{day.get('wind_deg', 0)} degrees"
                },
                'rain': f"{day.get('rain', 0)} mm" if 'rain' in day else 'No rain',
                'clouds': f"{day.get('clouds', 0)}%",
                'pop': f"{day.get('pop', 0) * 100}%"
            })

        # Process hourly forecasts and add to appropriate days
        for hour in data.get('hourly', []):
            dt = datetime.fromtimestamp(hour.get('dt', 0), tz)
            date_str = dt.date().strftime('%Y-%m-%d')

            # Skip if we don't have this date (shouldn't happen but just in case)
            if date_str not in forecasts_by_date:
                continue

            # Add the hourly forecast to the appropriate day
            hourly_entry = {
                'time': format_timestamp(hour.get('dt', 0), time_zone_offset),
                'temperature': f"{hour.get('temp', 0)} °C",
                'feels_like': f"{hour.get('feels_like', 0)} °C",
                'temp_min': "N/A",  # Hourly doesn't have min/max
                'temp_max': "N/A",
                'weather_condition': hour.get('weather', [{}])[0].get('description', 'Unknown'),
                'humidity': f"{hour.get('humidity', 0)}%",
                'wind': {
                    'speed': f"{hour.get('wind_speed', 0)} m/s",
                    'direction': f"{hour.get('wind_deg', 0)} degrees"
                },
                'rain': f"{hour.get('rain', {}).get('1h', 0)} mm/h" if 'rain' in hour else 'No rain',
                'clouds': f"{hour.get('clouds', 0)}%",
                'pop': f"{hour.get('pop', 0) * 100}%"  # Convert to percentage
            }

            # Only add hourly entries for the first 48 hours (to keep the response size reasonable)
            current_time = datetime.now(tz)
            if (dt - current_time).total_seconds() <= 48 * 3600:  # 48 hours in seconds
                forecasts_by_date[date_str]['entries'].append(hourly_entry)

        # Convert dictionary to list of daily forecasts
        daily_forecasts = []
        for date_str, forecast in sorted(forecasts_by_date.items()):
            daily_forecasts.append({
                'date': date_str,
                'entries': forecast['entries'],
                'summary': forecast.get('summary', '')
            })

        # Return structured forecast data
        return {
            'daily_forecasts': daily_forecasts,
            'current': current_weather
        }
    except requests.RequestException as e:
        return {'error': f"Request error: {str(e)}"}
    except ValueError as e:
        return {'error': f"JSON parsing error: {str(e)}"}
    except KeyError as e:
        return {'error': f"Data structure error: Missing key {str(e)}"}
    except Exception as e:
        return {'error': f"Unexpected error: {str(e)}"}

# Define MCP tools
@mcp.tool()
def get_weather(location: str, api_key: Optional[str] = None, timezone_offset: float = 0) -> Dict[str, Any]:
    """
    Get comprehensive weather data for a location including current weather and 8-day forecast with detailed information

    Parameters:
        location: Location name, e.g., "Beijing", "New York", "Tokyo"
        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)

    Returns:
        Dictionary containing current weather and detailed forecasts for 8 days (including today)
        with morning, afternoon, and evening data points for each day
    """
    # Call weather forecast function
    return get_weather_forecast(location, timezone_offset, api_key)

@mcp.tool()
def get_current_weather(location: str, api_key: Optional[str] = None, timezone_offset: float = 0) -> Dict[str, Any]:
    """
    Get current weather for a specified location

    Parameters:
        location: Location name, e.g., "Beijing", "New York", "Tokyo"
        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)

    Returns:
        Current weather information
    """
    # Get full weather information
    full_weather = get_weather(location, api_key, timezone_offset)

    # Check if an error occurred
    if 'error' in full_weather:
        return full_weather

    # Only return current weather
    if 'current' in full_weather:
        return full_weather['current']
    else:
        return {"error": "Unable to get current weather information"}

# Start server
if __name__ == "__main__":
    # Check if environment variable is set and print log information
    if os.environ.get("OPENWEATHER_API_KEY"):
        print("API key found in environment variables")
        print("API tools are ready, can be called without api_key parameter")
    else:
        print("No API key found in environment variables")
        print("API key parameter required when calling tools")

    print("Weather Forecast MCP Server running...")
    mcp.run(transport='stdio')

```

--------------------------------------------------------------------------------
/test_weather_mcp.py:
--------------------------------------------------------------------------------

```python
#!/usr/bin/env python3
"""
Unit tests for the Weather MCP Server
"""
import unittest
from unittest.mock import patch, MagicMock
import os
from datetime import datetime, timezone, timedelta
import json
import sys
import importlib.util

# Create mock classes and modules needed for testing
class MockField:
    def __init__(self, *args, **kwargs):
        self.description = kwargs.get('description', '')

class MockBaseModel:
    pass

# Mock modules needed for testing
sys.modules['mcp'] = MagicMock()
sys.modules['mcp.server'] = MagicMock()
sys.modules['mcp.server.fastmcp'] = MagicMock()
sys.modules['mcp.server.fastmcp'].FastMCP = MagicMock()
sys.modules['pydantic'] = MagicMock()
sys.modules['pydantic'].BaseModel = MockBaseModel
sys.modules['pydantic'].Field = MockField

# Make mcp.tool() return the function itself, not a mock
def mock_tool_decorator():
    def decorator(func):
        return func
    return decorator

sys.modules['mcp.server.fastmcp'].FastMCP().tool = mock_tool_decorator

# Now import should work
import weather_mcp_server


class TestWeatherMCP(unittest.TestCase):
    """Test the Weather MCP server functionality"""

    def setUp(self):
        """Set up test environment"""
        # Clear environment variable to ensure tests control it
        if "OPENWEATHER_API_KEY" in os.environ:
            self.original_api_key = os.environ["OPENWEATHER_API_KEY"]
            del os.environ["OPENWEATHER_API_KEY"]
        else:
            self.original_api_key = None

        # Sample test data
        self.test_location = "New York"
        self.test_api_key = "test_api_key_123"
        self.test_timezone_offset = -4

        # Sample response data
        with open("test_weather_response.json") as f:
            self.sample_onecall_data = json.load(f)

        # Sample current weather response
        self.sample_current_weather = {
            "coord": {"lon": -74.006, "lat": 40.7128},
            "weather": [{"id": 800, "main": "Clear", "description": "clear sky", "icon": "01d"}],
            "base": "stations",
            "main": {
                "temp": 5.46,
                "feels_like": 0.42,
                "temp_min": 4.0,
                "temp_max": 6.5,
                "pressure": 1006,
                "humidity": 36
            },
            "visibility": 10000,
            "wind": {"speed": 9.17, "deg": 298},
            "clouds": {"all": 20},
            "dt": 1744128000,
            "sys": {
                "type": 2,
                "id": 2039034,
                "country": "US",
                "sunrise": 1744108059,
                "sunset": 1744154851
            },
            "timezone": -14400,
            "id": 5128581,
            "name": "New York",
            "cod": 200
        }

    def tearDown(self):
        """Clean up after tests"""
        # Restore original environment if it existed
        if self.original_api_key is not None:
            os.environ["OPENWEATHER_API_KEY"] = self.original_api_key
        elif "OPENWEATHER_API_KEY" in os.environ:
            del os.environ["OPENWEATHER_API_KEY"]

    def test_get_api_key_from_param(self):
        """Test getting API key from parameter"""
        api_key = weather_mcp_server.get_api_key(self.test_api_key)
        self.assertEqual(api_key, self.test_api_key)

    def test_get_api_key_from_env(self):
        """Test getting API key from environment variable"""
        os.environ["OPENWEATHER_API_KEY"] = self.test_api_key
        api_key = weather_mcp_server.get_api_key()
        self.assertEqual(api_key, self.test_api_key)

    def test_get_api_key_missing(self):
        """Test error when API key is missing"""
        with self.assertRaises(ValueError):
            weather_mcp_server.get_api_key()

    @patch('weather_mcp_server.requests.get')
    def test_get_weather_success(self, mock_get):
        """Test successful weather forecast retrieval"""
        # Mock the geocoding API response
        mock_geocoding_response = MagicMock()
        mock_geocoding_response.status_code = 200
        mock_geocoding_response.json.return_value = [
            {"name": "New York", "lat": 40.7128, "lon": -74.0060}
        ]

        # Mock the One Call API response
        mock_onecall_response = MagicMock()
        mock_onecall_response.status_code = 200
        mock_onecall_response.json.return_value = {
            "lat": 40.7128,
            "lon": -74.0060,
            "timezone": "America/New_York",
            "timezone_offset": -14400,
            "current": {
                "dt": 1617979000,
                "temp": 15.2,
                "feels_like": 14.3,
                "humidity": 76,
                "wind_speed": 2.06,
                "wind_deg": 210,
                "weather": [{"description": "clear sky"}],
                "clouds": 1
            },
            "daily": [
                {
                    "dt": 1617979000,
                    "temp": {"day": 15.0, "min": 9.0, "max": 17.0, "eve": 13.0, "morn": 10.0},
                    "feels_like": {"day": 14.3, "night": 8.5, "eve": 12.5, "morn": 9.5},
                    "humidity": 76,
                    "wind_speed": 2.06,
                    "wind_deg": 210,
                    "weather": [{"description": "clear sky"}],
                    "clouds": 1,
                    "pop": 0.2,
                    "summary": "Nice day"
                }
            ],
            "hourly": [
                {
                    "dt": 1617979000,
                    "temp": 15.2,
                    "feels_like": 14.3,
                    "humidity": 76,
                    "wind_speed": 2.06,
                    "wind_deg": 210,
                    "weather": [{"description": "clear sky"}],
                    "clouds": 1,
                    "pop": 0.2
                }
            ]
        }

        # Configure the mock to return different responses for different URLs
        def side_effect(url, *args, **kwargs):
            if "onecall" in url:
                return mock_onecall_response
            elif "geo" in url:
                return mock_geocoding_response
            else:
                # Fallback to current weather API for coordinates
                return mock_geocoding_response

        mock_get.side_effect = side_effect

        # Call the function with test data
        result = weather_mcp_server.get_weather(
            self.test_location,
            self.test_api_key,
            self.test_timezone_offset
        )

        # Check the result
        self.assertIn('daily_forecasts', result)
        self.assertIn('current', result)
        self.assertTrue(len(result['daily_forecasts']) > 0)

        # Verify API was called with the right parameters
        mock_get.assert_called()

        # Verify the structure of the returned data
        self.assertIn('time', result['current'])
        self.assertIn('temperature', result['current'])
        self.assertIn('weather_condition', result['current'])

        # Verify daily forecast structure
        first_day = result['daily_forecasts'][0]
        self.assertIn('date', first_day)
        self.assertIn('entries', first_day)
        self.assertIn('summary', first_day)

    @patch('weather_mcp_server.requests.get')
    def test_get_current_weather_success(self, mock_get):
        """Test successful current weather retrieval"""
        # Mock the geocoding API response
        mock_geocoding_response = MagicMock()
        mock_geocoding_response.status_code = 200
        mock_geocoding_response.json.return_value = [
            {"name": "New York", "lat": 40.7128, "lon": -74.0060}
        ]

        # Mock the One Call API response
        mock_onecall_response = MagicMock()
        mock_onecall_response.status_code = 200
        mock_onecall_response.json.return_value = {
            "lat": 40.7128,
            "lon": -74.0060,
            "timezone": "America/New_York",
            "timezone_offset": -14400,
            "current": {
                "dt": 1617979000,
                "temp": 15.2,
                "feels_like": 14.3,
                "humidity": 76,
                "wind_speed": 2.06,
                "wind_deg": 210,
                "weather": [{"description": "clear sky"}],
                "clouds": 1
            },
            "daily": [],
            "hourly": []
        }

        # Configure the mock to return different responses for different URLs
        def side_effect(url, *args, **kwargs):
            if "onecall" in url:
                return mock_onecall_response
            elif "geo" in url:
                return mock_geocoding_response
            else:
                # Fallback to current weather API for coordinates
                return mock_geocoding_response

        mock_get.side_effect = side_effect

        # Call the function
        result = weather_mcp_server.get_current_weather(
            self.test_location,
            self.test_api_key,
            self.test_timezone_offset
        )

        # Verify the structure of the returned data
        self.assertIn('time', result)
        self.assertIn('temperature', result)
        self.assertIn('weather_condition', result)
        self.assertEqual(result['weather_condition'], 'clear sky')

    @patch('weather_mcp_server.requests.get')
    def test_api_error_handling(self, mock_get):
        """Test error handling for API failures"""
        # Mock an API error response
        mock_response = MagicMock()
        mock_response.status_code = 401
        mock_response.raise_for_status.side_effect = Exception("API Error")
        mock_get.return_value = mock_response

        # Call the function
        result = weather_mcp_server.get_weather(
            self.test_location,
            self.test_api_key,
            self.test_timezone_offset
        )

        # Verify error is returned
        self.assertIn('error', result)

    def test_env_variable_priority(self):
        """Test that provided API key takes priority over environment variable"""
        os.environ["OPENWEATHER_API_KEY"] = "env_api_key"
        api_key = weather_mcp_server.get_api_key("provided_api_key")
        self.assertEqual(api_key, "provided_api_key")

    @patch('weather_mcp_server.requests.get')
    def test_location_not_found(self, mock_get):
        """Test handling when location is not found"""
        # Mock the geo API response for location not found
        mock_response = MagicMock()
        mock_response.status_code = 200
        mock_response.json.return_value = []  # Empty response means location not found
        mock_get.return_value = mock_response

        # Since we're using a new get_coordinates function, we need to mock how it raises the exception
        mock_get.side_effect = KeyError("coord")

        # Call the function
        result = weather_mcp_server.get_weather("NonExistentLocation", self.test_api_key)

        # Verify error is returned
        self.assertIn('error', result)

    @patch('weather_mcp_server.get_weather')
    def test_get_current_weather_error_propagation(self, mock_get_weather):
        """Test that errors from get_weather are propagated to get_current_weather"""
        # Mock an error from get_weather
        mock_get_weather.return_value = {"error": "Test error"}

        # Call get_current_weather
        result = weather_mcp_server.get_current_weather(
            self.test_location,
            self.test_api_key,
            self.test_timezone_offset
        )

        # Verify error is propagated
        self.assertIn('error', result)
        self.assertEqual(result['error'], "Test error")

    @patch('weather_mcp_server.get_weather')
    def test_get_current_weather_missing_current(self, mock_get_weather):
        """Test handling when get_weather returns data without 'current' field"""
        # Mock results from get_weather without 'current' field
        mock_get_weather.return_value = {
            "daily_forecasts": [{"date": "2023-01-01", "entries": [], "summary": ""}]
        }

        # Call get_current_weather
        result = weather_mcp_server.get_current_weather(
            self.test_location,
            self.test_api_key,
            self.test_timezone_offset
        )

        # Verify error is returned
        self.assertIn('error', result)
        self.assertEqual(result['error'], "Unable to get current weather information")

    @patch('weather_mcp_server.requests.get')
    def test_geocoding_fallback(self, mock_get):
        """Test that geocoding falls back to current weather API when geocoding API returns no results"""
        # First create empty geocoding response
        empty_geocoding_response = MagicMock()
        empty_geocoding_response.status_code = 200
        empty_geocoding_response.json.return_value = []  # Empty response to trigger fallback
        
        # Create fallback current weather API response with coordinates
        fallback_response = MagicMock()
        fallback_response.status_code = 200
        fallback_response.json.return_value = {
            "coord": {"lat": 40.7128, "lon": -74.0060},
            "weather": [{"description": "clear sky"}],
            "main": {"temp": 15.0},
            "name": "New York"
        }
        
        # Create onecall API response for after coordinates are found
        onecall_response = MagicMock()
        onecall_response.status_code = 200
        onecall_response.json.return_value = {
            "lat": 40.7128,
            "lon": -74.0060,
            "timezone": "America/New_York",
            "timezone_offset": -14400,
            "current": {
                "dt": 1617979000,
                "temp": 15.2,
                "feels_like": 14.3,
                "humidity": 76,
                "wind_speed": 2.06,
                "wind_deg": 210,
                "weather": [{"description": "clear sky"}],
                "clouds": 1
            },
            "daily": [
                {
                    "dt": 1617979000,
                    "temp": {"day": 15.0, "min": 9.0, "max": 17.0, "eve": 13.0, "morn": 10.0},
                    "feels_like": {"day": 14.3, "night": 8.5, "eve": 12.5, "morn": 9.5},
                    "humidity": 76,
                    "wind_speed": 2.06,
                    "wind_deg": 210,
                    "weather": [{"description": "clear sky"}],
                    "clouds": 1,
                    "pop": 0.2,
                    "summary": "Nice day"
                }
            ],
            "hourly": []
        }
        
        # Configure the mock to return different responses based on the URL
        # First geocoding returns empty, then fallback to current weather API works, then onecall API works
        call_count = [0]
        
        def side_effect(url, *args, **kwargs):
            call_count[0] += 1
            
            if "onecall" in url:
                return onecall_response
            elif "geo/1.0/direct" in url:
                return empty_geocoding_response
            elif "data/2.5/weather" in url:
                # This is the fallback API
                return fallback_response
            else:
                return empty_geocoding_response
        
        mock_get.side_effect = side_effect
        
        # Call the function
        result = weather_mcp_server.get_weather(
            self.test_location, 
            self.test_api_key, 
            self.test_timezone_offset
        )
        
        # Verify we got valid results indicating the fallback worked
        self.assertIn('daily_forecasts', result)
        self.assertIn('current', result)
        
        # Check that we called the APIs in the right order
        # Should be at least 3 calls: geocoding, fallback, onecall
        self.assertGreaterEqual(call_count[0], 3)


if __name__ == '__main__':
    unittest.main()

```

--------------------------------------------------------------------------------
/test_weather_response.json:
--------------------------------------------------------------------------------

```json
{
  "lat": 40.7127,
  "lon": -74.006,
  "timezone": "America/New_York",
  "timezone_offset": -14400,
  "current": {
    "dt": 1744127650,
    "sunrise": 1744108059,
    "sunset": 1744154851,
    "temp": 5.46,
    "feels_like": -0.36,
    "pressure": 1006,
    "humidity": 36,
    "dew_point": -7.48,
    "uvi": 5.17,
    "clouds": 20,
    "visibility": 10000,
    "wind_speed": 12.35,
    "wind_deg": 290,
    "wind_gust": 16.98,
    "weather": [
      {
        "id": 801,
        "main": "Clouds",
        "description": "few clouds",
        "icon": "02d"
      }
    ]
  },
  "minutely": [
    {
      "dt": 1744127700,
      "precipitation": 0
    },
    {
      "dt": 1744127760,
      "precipitation": 0
    },
    {
      "dt": 1744127820,
      "precipitation": 0
    },
    {
      "dt": 1744127880,
      "precipitation": 0
    },
    {
      "dt": 1744127940,
      "precipitation": 0
    },
    {
      "dt": 1744128000,
      "precipitation": 0
    },
    {
      "dt": 1744128060,
      "precipitation": 0
    },
    {
      "dt": 1744128120,
      "precipitation": 0
    },
    {
      "dt": 1744128180,
      "precipitation": 0
    },
    {
      "dt": 1744128240,
      "precipitation": 0
    },
    {
      "dt": 1744128300,
      "precipitation": 0
    },
    {
      "dt": 1744128360,
      "precipitation": 0
    },
    {
      "dt": 1744128420,
      "precipitation": 0
    },
    {
      "dt": 1744128480,
      "precipitation": 0
    },
    {
      "dt": 1744128540,
      "precipitation": 0
    },
    {
      "dt": 1744128600,
      "precipitation": 0
    },
    {
      "dt": 1744128660,
      "precipitation": 0
    },
    {
      "dt": 1744128720,
      "precipitation": 0
    },
    {
      "dt": 1744128780,
      "precipitation": 0
    },
    {
      "dt": 1744128840,
      "precipitation": 0
    },
    {
      "dt": 1744128900,
      "precipitation": 0
    },
    {
      "dt": 1744128960,
      "precipitation": 0
    },
    {
      "dt": 1744129020,
      "precipitation": 0
    },
    {
      "dt": 1744129080,
      "precipitation": 0
    },
    {
      "dt": 1744129140,
      "precipitation": 0
    },
    {
      "dt": 1744129200,
      "precipitation": 0
    },
    {
      "dt": 1744129260,
      "precipitation": 0
    },
    {
      "dt": 1744129320,
      "precipitation": 0
    },
    {
      "dt": 1744129380,
      "precipitation": 0
    },
    {
      "dt": 1744129440,
      "precipitation": 0
    },
    {
      "dt": 1744129500,
      "precipitation": 0
    },
    {
      "dt": 1744129560,
      "precipitation": 0
    },
    {
      "dt": 1744129620,
      "precipitation": 0
    },
    {
      "dt": 1744129680,
      "precipitation": 0
    },
    {
      "dt": 1744129740,
      "precipitation": 0
    },
    {
      "dt": 1744129800,
      "precipitation": 0
    },
    {
      "dt": 1744129860,
      "precipitation": 0
    },
    {
      "dt": 1744129920,
      "precipitation": 0
    },
    {
      "dt": 1744129980,
      "precipitation": 0
    },
    {
      "dt": 1744130040,
      "precipitation": 0
    },
    {
      "dt": 1744130100,
      "precipitation": 0
    },
    {
      "dt": 1744130160,
      "precipitation": 0
    },
    {
      "dt": 1744130220,
      "precipitation": 0
    },
    {
      "dt": 1744130280,
      "precipitation": 0
    },
    {
      "dt": 1744130340,
      "precipitation": 0
    },
    {
      "dt": 1744130400,
      "precipitation": 0
    },
    {
      "dt": 1744130460,
      "precipitation": 0
    },
    {
      "dt": 1744130520,
      "precipitation": 0
    },
    {
      "dt": 1744130580,
      "precipitation": 0
    },
    {
      "dt": 1744130640,
      "precipitation": 0
    },
    {
      "dt": 1744130700,
      "precipitation": 0
    },
    {
      "dt": 1744130760,
      "precipitation": 0
    },
    {
      "dt": 1744130820,
      "precipitation": 0
    },
    {
      "dt": 1744130880,
      "precipitation": 0
    },
    {
      "dt": 1744130940,
      "precipitation": 0
    },
    {
      "dt": 1744131000,
      "precipitation": 0
    },
    {
      "dt": 1744131060,
      "precipitation": 0
    },
    {
      "dt": 1744131120,
      "precipitation": 0
    },
    {
      "dt": 1744131180,
      "precipitation": 0
    },
    {
      "dt": 1744131240,
      "precipitation": 0
    }
  ],
  "hourly": [
    {
      "dt": 1744124400,
      "temp": 5.12,
      "feels_like": -0.06,
      "pressure": 1006,
      "humidity": 35,
      "dew_point": -8.07,
      "uvi": 4.15,
      "clouds": 16,
      "visibility": 10000,
      "wind_speed": 9.3,
      "wind_deg": 298,
      "wind_gust": 12.46,
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744128000,
      "temp": 5.46,
      "feels_like": 0.42,
      "pressure": 1006,
      "humidity": 36,
      "dew_point": -7.48,
      "uvi": 5.17,
      "clouds": 20,
      "visibility": 10000,
      "wind_speed": 9.17,
      "wind_deg": 298,
      "wind_gust": 12.71,
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744131600,
      "temp": 5.56,
      "feels_like": 0.48,
      "pressure": 1006,
      "humidity": 33,
      "dew_point": -8.4,
      "uvi": 5.38,
      "clouds": 16,
      "visibility": 10000,
      "wind_speed": 9.43,
      "wind_deg": 294,
      "wind_gust": 13.34,
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744135200,
      "temp": 6.04,
      "feels_like": 1.02,
      "pressure": 1006,
      "humidity": 30,
      "dew_point": -9.1,
      "uvi": 4.85,
      "clouds": 13,
      "visibility": 10000,
      "wind_speed": 9.8,
      "wind_deg": 292,
      "wind_gust": 14.26,
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744138800,
      "temp": 6.42,
      "feels_like": 1.23,
      "pressure": 1007,
      "humidity": 28,
      "dew_point": -9.59,
      "uvi": 3.77,
      "clouds": 68,
      "visibility": 10000,
      "wind_speed": 10.99,
      "wind_deg": 297,
      "wind_gust": 15.04,
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744142400,
      "temp": 6.29,
      "feels_like": 1,
      "pressure": 1008,
      "humidity": 28,
      "dew_point": -9.69,
      "uvi": 2.43,
      "clouds": 84,
      "visibility": 10000,
      "wind_speed": 11.25,
      "wind_deg": 302,
      "wind_gust": 15.13,
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744146000,
      "temp": 6,
      "feels_like": 0.7,
      "pressure": 1009,
      "humidity": 30,
      "dew_point": -10.33,
      "uvi": 1.22,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 10.86,
      "wind_deg": 304,
      "wind_gust": 15.76,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744149600,
      "temp": 5.53,
      "feels_like": 0.31,
      "pressure": 1011,
      "humidity": 32,
      "dew_point": -9.75,
      "uvi": 0.43,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 9.91,
      "wind_deg": 303,
      "wind_gust": 15.95,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744153200,
      "temp": 4.82,
      "feels_like": -0.28,
      "pressure": 1012,
      "humidity": 37,
      "dew_point": -8.57,
      "uvi": 0,
      "clouds": 81,
      "visibility": 10000,
      "wind_speed": 8.69,
      "wind_deg": 305,
      "wind_gust": 15.6,
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744156800,
      "temp": 3.9,
      "feels_like": -1.32,
      "pressure": 1014,
      "humidity": 39,
      "dew_point": -9.04,
      "uvi": 0,
      "clouds": 68,
      "visibility": 10000,
      "wind_speed": 8.2,
      "wind_deg": 311,
      "wind_gust": 14.82,
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744160400,
      "temp": 3.05,
      "feels_like": -2.19,
      "pressure": 1015,
      "humidity": 39,
      "dew_point": -9.78,
      "uvi": 0,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 7.51,
      "wind_deg": 318,
      "wind_gust": 14.23,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744164000,
      "temp": 2.29,
      "feels_like": -3.06,
      "pressure": 1016,
      "humidity": 39,
      "dew_point": -10.26,
      "uvi": 0,
      "clouds": 1,
      "visibility": 10000,
      "wind_speed": 7.23,
      "wind_deg": 315,
      "wind_gust": 14.55,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744167600,
      "temp": 1.63,
      "feels_like": -3.9,
      "pressure": 1017,
      "humidity": 40,
      "dew_point": -10.5,
      "uvi": 0,
      "clouds": 1,
      "visibility": 10000,
      "wind_speed": 7.19,
      "wind_deg": 310,
      "wind_gust": 14.97,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744171200,
      "temp": 1.13,
      "feels_like": -4.56,
      "pressure": 1018,
      "humidity": 41,
      "dew_point": -10.78,
      "uvi": 0,
      "clouds": 1,
      "visibility": 10000,
      "wind_speed": 7.25,
      "wind_deg": 303,
      "wind_gust": 14.83,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744174800,
      "temp": 0.71,
      "feels_like": -4.98,
      "pressure": 1019,
      "humidity": 41,
      "dew_point": -11.07,
      "uvi": 0,
      "clouds": 1,
      "visibility": 10000,
      "wind_speed": 6.94,
      "wind_deg": 297,
      "wind_gust": 14.36,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744178400,
      "temp": 2.43,
      "feels_like": -2.74,
      "pressure": 1020,
      "humidity": 41,
      "dew_point": -11.31,
      "uvi": 0,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 6.87,
      "wind_deg": 294,
      "wind_gust": 13.91,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744182000,
      "temp": 0.18,
      "feels_like": -5.66,
      "pressure": 1021,
      "humidity": 42,
      "dew_point": -11.37,
      "uvi": 0,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 6.95,
      "wind_deg": 294,
      "wind_gust": 13.52,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744185600,
      "temp": -0.05,
      "feels_like": -5.9,
      "pressure": 1021,
      "humidity": 42,
      "dew_point": -11.37,
      "uvi": 0,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 6.83,
      "wind_deg": 297,
      "wind_gust": 12.79,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744189200,
      "temp": -0.19,
      "feels_like": -6.02,
      "pressure": 1022,
      "humidity": 43,
      "dew_point": -11.41,
      "uvi": 0,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 6.68,
      "wind_deg": 300,
      "wind_gust": 12.1,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744192800,
      "temp": -0.29,
      "feels_like": -5.99,
      "pressure": 1023,
      "humidity": 43,
      "dew_point": -11.52,
      "uvi": 0,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 6.36,
      "wind_deg": 303,
      "wind_gust": 11.11,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744196400,
      "temp": -0.29,
      "feels_like": -5.86,
      "pressure": 1024,
      "humidity": 43,
      "dew_point": -11.54,
      "uvi": 0.1,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 6.08,
      "wind_deg": 306,
      "wind_gust": 10.29,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744200000,
      "temp": 0.1,
      "feels_like": -5.39,
      "pressure": 1025,
      "humidity": 40,
      "dew_point": -11.88,
      "uvi": 0.51,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 6.13,
      "wind_deg": 311,
      "wind_gust": 9.08,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744203600,
      "temp": 0.97,
      "feels_like": -4.04,
      "pressure": 1025,
      "humidity": 37,
      "dew_point": -12.31,
      "uvi": 1.41,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 5.63,
      "wind_deg": 315,
      "wind_gust": 7.75,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744207200,
      "temp": 2.26,
      "feels_like": -2.06,
      "pressure": 1025,
      "humidity": 31,
      "dew_point": -13.24,
      "uvi": 2.75,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 4.94,
      "wind_deg": 313,
      "wind_gust": 6.88,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744210800,
      "temp": 3.6,
      "feels_like": -0.08,
      "pressure": 1025,
      "humidity": 26,
      "dew_point": -14.24,
      "uvi": 4.24,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 4.38,
      "wind_deg": 303,
      "wind_gust": 6.28,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744214400,
      "temp": 5.06,
      "feels_like": 2,
      "pressure": 1025,
      "humidity": 22,
      "dew_point": -15.3,
      "uvi": 5.41,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 3.88,
      "wind_deg": 293,
      "wind_gust": 5.93,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744218000,
      "temp": 6.34,
      "feels_like": 3.67,
      "pressure": 1024,
      "humidity": 19,
      "dew_point": -16.12,
      "uvi": 5.75,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 3.71,
      "wind_deg": 280,
      "wind_gust": 6.06,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744221600,
      "temp": 7.71,
      "feels_like": 5.29,
      "pressure": 1024,
      "humidity": 17,
      "dew_point": -16.16,
      "uvi": 5.23,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 3.81,
      "wind_deg": 269,
      "wind_gust": 6.26,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744225200,
      "temp": 8.85,
      "feels_like": 6.62,
      "pressure": 1023,
      "humidity": 18,
      "dew_point": -14.73,
      "uvi": 4.07,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 3.93,
      "wind_deg": 265,
      "wind_gust": 6.27,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744228800,
      "temp": 9.63,
      "feels_like": 7.38,
      "pressure": 1022,
      "humidity": 19,
      "dew_point": -13.16,
      "uvi": 2.6,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 4.38,
      "wind_deg": 261,
      "wind_gust": 6.42,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744232400,
      "temp": 10.13,
      "feels_like": 7.75,
      "pressure": 1022,
      "humidity": 21,
      "dew_point": -11.51,
      "uvi": 1.31,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 4.86,
      "wind_deg": 257,
      "wind_gust": 6.5,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744236000,
      "temp": 10.17,
      "feels_like": 7.87,
      "pressure": 1023,
      "humidity": 24,
      "dew_point": -10.02,
      "uvi": 0.45,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 4.43,
      "wind_deg": 251,
      "wind_gust": 5.99,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744239600,
      "temp": 9.65,
      "feels_like": 7.78,
      "pressure": 1024,
      "humidity": 28,
      "dew_point": -8.42,
      "uvi": 0,
      "clouds": 3,
      "visibility": 10000,
      "wind_speed": 3.58,
      "wind_deg": 224,
      "wind_gust": 5.21,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744243200,
      "temp": 8.97,
      "feels_like": 6.94,
      "pressure": 1025,
      "humidity": 35,
      "dew_point": -6.02,
      "uvi": 0,
      "clouds": 5,
      "visibility": 10000,
      "wind_speed": 3.59,
      "wind_deg": 183,
      "wind_gust": 4.91,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744246800,
      "temp": 8.19,
      "feels_like": 5.9,
      "pressure": 1025,
      "humidity": 42,
      "dew_point": -4.31,
      "uvi": 0,
      "clouds": 11,
      "visibility": 10000,
      "wind_speed": 3.76,
      "wind_deg": 171,
      "wind_gust": 5.35,
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744250400,
      "temp": 7.85,
      "feels_like": 5.36,
      "pressure": 1025,
      "humidity": 48,
      "dew_point": -2.75,
      "uvi": 0,
      "clouds": 11,
      "visibility": 10000,
      "wind_speed": 4.01,
      "wind_deg": 167,
      "wind_gust": 4.86,
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744254000,
      "temp": 7.31,
      "feels_like": 3.9,
      "pressure": 1025,
      "humidity": 50,
      "dew_point": -2.36,
      "uvi": 0,
      "clouds": 10,
      "visibility": 10000,
      "wind_speed": 5.8,
      "wind_deg": 201,
      "wind_gust": 7.94,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744257600,
      "temp": 6.35,
      "feels_like": 2.7,
      "pressure": 1026,
      "humidity": 53,
      "dew_point": -2.68,
      "uvi": 0,
      "clouds": 11,
      "visibility": 10000,
      "wind_speed": 5.77,
      "wind_deg": 214,
      "wind_gust": 9.56,
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744261200,
      "temp": 6.03,
      "feels_like": 2.77,
      "pressure": 1026,
      "humidity": 57,
      "dew_point": -1.97,
      "uvi": 0,
      "clouds": 29,
      "visibility": 10000,
      "wind_speed": 4.68,
      "wind_deg": 211,
      "wind_gust": 9.05,
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744264800,
      "temp": 6.05,
      "feels_like": 3.2,
      "pressure": 1026,
      "humidity": 57,
      "dew_point": -1.78,
      "uvi": 0,
      "clouds": 41,
      "visibility": 10000,
      "wind_speed": 3.91,
      "wind_deg": 214,
      "wind_gust": 7.73,
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744268400,
      "temp": 6.03,
      "feels_like": 3.74,
      "pressure": 1026,
      "humidity": 58,
      "dew_point": -1.66,
      "uvi": 0,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 3,
      "wind_deg": 214,
      "wind_gust": 6.34,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744272000,
      "temp": 6.13,
      "feels_like": 4.04,
      "pressure": 1026,
      "humidity": 59,
      "dew_point": -1.45,
      "uvi": 0,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 2.75,
      "wind_deg": 201,
      "wind_gust": 6.13,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744275600,
      "temp": 6.22,
      "feels_like": 3.86,
      "pressure": 1026,
      "humidity": 61,
      "dew_point": -0.96,
      "uvi": 0,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 3.17,
      "wind_deg": 194,
      "wind_gust": 6.7,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744279200,
      "temp": 6.28,
      "feels_like": 3.82,
      "pressure": 1026,
      "humidity": 64,
      "dew_point": -0.13,
      "uvi": 0,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 3.33,
      "wind_deg": 182,
      "wind_gust": 6.94,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04n"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744282800,
      "temp": 6.37,
      "feels_like": 3.87,
      "pressure": 1026,
      "humidity": 67,
      "dew_point": 0.58,
      "uvi": 0.08,
      "clouds": 97,
      "visibility": 10000,
      "wind_speed": 3.43,
      "wind_deg": 189,
      "wind_gust": 6.93,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744286400,
      "temp": 7.22,
      "feels_like": 4.48,
      "pressure": 1026,
      "humidity": 64,
      "dew_point": 0.89,
      "uvi": 0.41,
      "clouds": 98,
      "visibility": 10000,
      "wind_speed": 4.21,
      "wind_deg": 183,
      "wind_gust": 7.87,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744290000,
      "temp": 8.01,
      "feels_like": 4.92,
      "pressure": 1026,
      "humidity": 60,
      "dew_point": 0.7,
      "uvi": 1.33,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 5.45,
      "wind_deg": 177,
      "wind_gust": 8.13,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    },
    {
      "dt": 1744293600,
      "temp": 8.91,
      "feels_like": 5.67,
      "pressure": 1026,
      "humidity": 55,
      "dew_point": 0.31,
      "uvi": 1.92,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 6.56,
      "wind_deg": 171,
      "wind_gust": 8.7,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "pop": 0
    }
  ],
  "daily": [
    {
      "dt": 1744128000,
      "sunrise": 1744108059,
      "sunset": 1744154851,
      "moonrise": 1744140420,
      "moonset": 1744101780,
      "moon_phase": 0.37,
      "summary": "Expect a day of partly cloudy with rain",
      "temp": {
        "day": 5.46,
        "min": 1.63,
        "max": 7.67,
        "night": 1.63,
        "eve": 5.53,
        "morn": 5.07
      },
      "feels_like": {
        "day": 0.42,
        "night": -3.9,
        "eve": 0.31,
        "morn": 0.76
      },
      "pressure": 1006,
      "humidity": 36,
      "dew_point": -7.48,
      "wind_speed": 11.25,
      "wind_deg": 302,
      "wind_gust": 15.95,
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": 20,
      "pop": 0.28,
      "rain": 0.19,
      "uvi": 5.38
    },
    {
      "dt": 1744214400,
      "sunrise": 1744194363,
      "sunset": 1744241313,
      "moonrise": 1744230540,
      "moonset": 1744189500,
      "moon_phase": 0.4,
      "summary": "Expect a day of partly cloudy with clear spells",
      "temp": {
        "day": 5.06,
        "min": -0.29,
        "max": 10.17,
        "night": 7.31,
        "eve": 10.17,
        "morn": -0.29
      },
      "feels_like": {
        "day": 2,
        "night": 3.9,
        "eve": 7.87,
        "morn": -5.99
      },
      "pressure": 1025,
      "humidity": 22,
      "dew_point": -15.3,
      "wind_speed": 7.25,
      "wind_deg": 303,
      "wind_gust": 14.83,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": 0,
      "pop": 0,
      "uvi": 5.75
    },
    {
      "dt": 1744300800,
      "sunrise": 1744280668,
      "sunset": 1744327776,
      "moonrise": 1744320600,
      "moonset": 1744277040,
      "moon_phase": 0.43,
      "summary": "Expect a day of partly cloudy with rain",
      "temp": {
        "day": 9,
        "min": 6.03,
        "max": 9.5,
        "night": 7.53,
        "eve": 7.75,
        "morn": 6.28
      },
      "feels_like": {
        "day": 5.46,
        "night": 4.88,
        "eve": 3.88,
        "morn": 3.82
      },
      "pressure": 1025,
      "humidity": 55,
      "dew_point": 0.26,
      "wind_speed": 8.08,
      "wind_deg": 154,
      "wind_gust": 11.96,
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": 100,
      "pop": 1,
      "rain": 1.6,
      "uvi": 3.75
    },
    {
      "dt": 1744387200,
      "sunrise": 1744366973,
      "sunset": 1744414239,
      "moonrise": 1744410600,
      "moonset": 1744364580,
      "moon_phase": 0.46,
      "summary": "There will be rain today",
      "temp": {
        "day": 8.77,
        "min": 7.14,
        "max": 10.63,
        "night": 10.25,
        "eve": 10.63,
        "morn": 7.73
      },
      "feels_like": {
        "day": 5.71,
        "night": 9.81,
        "eve": 9.86,
        "morn": 4.98
      },
      "pressure": 1019,
      "humidity": 89,
      "dew_point": 7,
      "wind_speed": 8.72,
      "wind_deg": 103,
      "wind_gust": 18.17,
      "weather": [
        {
          "id": 501,
          "main": "Rain",
          "description": "moderate rain",
          "icon": "10d"
        }
      ],
      "clouds": 100,
      "pop": 1,
      "rain": 35.75,
      "uvi": 0.55
    },
    {
      "dt": 1744473600,
      "sunrise": 1744453279,
      "sunset": 1744500702,
      "moonrise": 1744500660,
      "moonset": 1744452060,
      "moon_phase": 0.5,
      "summary": "You can expect rain in the morning, with partly cloudy in the afternoon",
      "temp": {
        "day": 9.98,
        "min": 8.32,
        "max": 11.11,
        "night": 8.32,
        "eve": 11.11,
        "morn": 9.66
      },
      "feels_like": {
        "day": 9.98,
        "night": 5.85,
        "eve": 10.65,
        "morn": 8.1
      },
      "pressure": 1009,
      "humidity": 97,
      "dew_point": 9.5,
      "wind_speed": 5.56,
      "wind_deg": 136,
      "wind_gust": 11.82,
      "weather": [
        {
          "id": 501,
          "main": "Rain",
          "description": "moderate rain",
          "icon": "10d"
        }
      ],
      "clouds": 100,
      "pop": 1,
      "rain": 14.82,
      "uvi": 0.3
    },
    {
      "dt": 1744560000,
      "sunrise": 1744539586,
      "sunset": 1744587164,
      "moonrise": 1744590720,
      "moonset": 1744539660,
      "moon_phase": 0.52,
      "summary": "You can expect partly cloudy in the morning, with clearing in the afternoon",
      "temp": {
        "day": 9.56,
        "min": 7.37,
        "max": 13.26,
        "night": 8.42,
        "eve": 13.26,
        "morn": 7.51
      },
      "feels_like": {
        "day": 8.44,
        "night": 5.15,
        "eve": 12.13,
        "morn": 5.46
      },
      "pressure": 1011,
      "humidity": 70,
      "dew_point": 4.25,
      "wind_speed": 7.08,
      "wind_deg": 316,
      "wind_gust": 10.32,
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "clouds": 100,
      "pop": 0,
      "uvi": 1
    },
    {
      "dt": 1744646400,
      "sunrise": 1744625894,
      "sunset": 1744673627,
      "moonrise": 1744680960,
      "moonset": 1744627440,
      "moon_phase": 0.55,
      "summary": "Expect a day of partly cloudy with clear spells",
      "temp": {
        "day": 12.6,
        "min": 7.84,
        "max": 17.57,
        "night": 14.48,
        "eve": 17.57,
        "morn": 7.84
      },
      "feels_like": {
        "day": 11.06,
        "night": 13.39,
        "eve": 16.4,
        "morn": 5.03
      },
      "pressure": 1015,
      "humidity": 44,
      "dew_point": 0.46,
      "wind_speed": 5.46,
      "wind_deg": 319,
      "wind_gust": 11.02,
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03d"
        }
      ],
      "clouds": 32,
      "pop": 0,
      "uvi": 1
    },
    {
      "dt": 1744732800,
      "sunrise": 1744712202,
      "sunset": 1744760090,
      "moonrise": 1744771140,
      "moonset": 1744715460,
      "moon_phase": 0.58,
      "summary": "There will be partly cloudy today",
      "temp": {
        "day": 18.38,
        "min": 11.81,
        "max": 23.53,
        "night": 16.57,
        "eve": 22.17,
        "morn": 11.81
      },
      "feels_like": {
        "day": 17.92,
        "night": 15.46,
        "eve": 21.3,
        "morn": 11.06
      },
      "pressure": 1005,
      "humidity": 63,
      "dew_point": 10.97,
      "wind_speed": 8.5,
      "wind_deg": 251,
      "wind_gust": 14.82,
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": 65,
      "pop": 0,
      "uvi": 1
    }
  ],
  "alerts": [
    {
      "sender_name": "NWS Upton NY",
      "event": "Freeze Warning",
      "start": 1744171200,
      "end": 1744203600,
      "description": "* WHAT...Sub-freezing temperatures as low as 28 expected.\n\n* WHERE...Portions of northeastern New Jersey and southeastern New\nYork.\n\n* WHEN...From midnight tonight to 9 AM EDT Wednesday.\n\n* IMPACTS...Freezing temperatures could kill crops and other\nsensitive vegetation.",
      "tags": [
        "Extreme low temperature"
      ]
    }
  ]
}
```