File size: 906 Bytes
d2a1db5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import asyncio
from src.mcp_weather_server.tools import open_meteo

class WeatherAgent:
    async def get_weather_forecast(self, latitude, longitude):
        print("Fetching 7-day weather forecast...")
        weather_forecast_response = await open_meteo.get_weather_forecast(latitude=latitude, longitude=longitude)
        if "error" in weather_forecast_response:
            print(f"Error: {weather_forecast_response['error']}")
            return None
        print("Weather forecast received.")
        return weather_forecast_response

async def main():
    agent = WeatherAgent()
    # Example usage (Patna, Bihar)
    lat = 25.6
    lon = 85.1
    forecast = await agent.get_weather_forecast(latitude=lat, longitude=lon)
    if forecast:
        print("\n--- Weather Forecast ---")
        print(forecast)
        print("----------------------")

if __name__ == "__main__":
    asyncio.run(main())