Skip to main content
Glama

get_daily_aggregate_forecast

Get daily weather forecast summaries for all Portuguese locations up to 3 days ahead, providing comprehensive meteorological data for planning and analysis.

Instructions

Get daily aggregated weather forecast for Portugal (Previsão Meteorológica até 3 dias, agregada por dia).

Args: day: Forecast day (0=today, 1=tomorrow, 2=day after tomorrow). Valid range: 0-2 Returns aggregated forecast for all Portuguese locations for the specified day.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dayNo

Implementation Reference

  • The handler function implementing the get_daily_aggregate_forecast tool. It validates the input day parameter (0-2), fetches aggregated daily forecast data from the IPMA API, processes it, and returns a formatted string with forecast details for sample locations across Portugal.
    @mcp.tool() async def get_daily_aggregate_forecast(day: int = 0) -> str: """Get daily aggregated weather forecast for Portugal (Previsão Meteorológica até 3 dias, agregada por dia). Args: day: Forecast day (0=today, 1=tomorrow, 2=day after tomorrow). Valid range: 0-2 Returns aggregated forecast for all Portuguese locations for the specified day. """ if day < 0 or day > 2: return "Invalid day parameter. Please use 0 (today), 1 (tomorrow), or 2 (day after tomorrow)." forecast_url = f"{IPMA_API_BASE}/forecast/meteorology/cities/daily/hp-daily-forecast-day{day}.json" forecast_data = await make_ipma_request(forecast_url) if not forecast_data or "data" not in forecast_data: return "Unable to fetch daily aggregate forecast data." result = f"""Daily Aggregate Weather Forecast Forecast Date: {forecast_data.get('forecastDate', 'Unknown')} Data Updated: {forecast_data.get('dataUpdate', 'Unknown')} Owner: {forecast_data.get('owner', 'IPMA')} Total Locations: {len(forecast_data['data'])} Sample Forecasts (first 10 locations): """ for location in forecast_data['data'][:10]: result += f""" Location ID: {location.get('globalIdLocal', 'N/A')} Position: {location.get('latitude', 'N/A')}°N, {location.get('longitude', 'N/A')}°E Temperature: {location.get('tMin', 'N/A')}°C - {location.get('tMax', 'N/A')}°C Precipitation Probability: {location.get('precipitaProb', 'N/A')}% Weather Type: {location.get('idWeatherType', 'N/A')} Wind: {location.get('predWindDir', 'N/A')} (Speed Class: {location.get('classWindSpeed', 'N/A')}) ---""" return result
  • Helper utility function used by get_daily_aggregate_forecast (and other tools) to make HTTP requests to the IPMA API endpoints with error handling and timeout.
    async def make_ipma_request(url: str) -> dict[str, Any] | list[dict[str, Any]] | None: """Make a request to the IPMA API with proper error handling.""" async with httpx.AsyncClient() as client: try: response = await client.get(url, timeout=30.0) response.raise_for_status() return response.json() except Exception: return None
  • weather.py:118-118 (registration)
    The @mcp.tool() decorator registers the get_daily_aggregate_forecast function as an MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gabriel20vieira/ipma-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server