Skip to main content
Glama

get_weather_warnings

Retrieve active Portuguese weather warnings for up to 3 days, including warning types, awareness levels, affected areas, and validity periods to help plan for hazardous weather conditions.

Instructions

Get Portuguese meteorological warnings for up to 3 days.

Returns current active weather warnings (Avisos Meteorológicos) including: - Warning type (precipitation, wind, fog, maritime agitation, etc.) - Awareness level (green, yellow, orange, red) - Affected area - Start and end times

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_weather_warnings' tool. It is registered via the @mcp.tool() decorator. Fetches weather warnings data from the IPMA API using the helper function, filters for active (non-green) warnings, and formats them into a structured string response listing area, type, level, description, and times.
    @mcp.tool() async def get_weather_warnings() -> str: """Get Portuguese meteorological warnings for up to 3 days. Returns current active weather warnings (Avisos Meteorológicos) including: - Warning type (precipitation, wind, fog, maritime agitation, etc.) - Awareness level (green, yellow, orange, red) - Affected area - Start and end times """ warnings_url = f"{IPMA_API_BASE}/forecast/warnings/warnings_www.json" warnings_data = await make_ipma_request(warnings_url) if not warnings_data: return "Unable to fetch weather warnings data." # Filter active warnings (not green level) active_warnings = [w for w in warnings_data if w.get("awarenessLevelID") != "green"] if not active_warnings: return "No active weather warnings at this time. All areas are at green (normal) level." result = "Active Weather Warnings:\n\n" for warning in active_warnings: result += f"""Area: {warning.get('idAreaAviso', 'N/A')} Type: {warning.get('awarenessTypeName', 'N/A')} Level: {warning.get('awarenessLevelID', 'N/A').upper()} Description: {warning.get('text', 'N/A')} Start: {warning.get('startTime', 'N/A')} End: {warning.get('endTime', 'N/A')} --- """ return result
  • Helper utility function used by the get_weather_warnings handler (and other tools) to perform HTTP GET requests to the IPMA API endpoints with timeout, error handling, and JSON parsing.
    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:23-23 (registration)
    The @mcp.tool() decorator registers the get_weather_warnings function as an MCP tool with the FastMCP server instance.
    @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