get_weather_warnings
Retrieve active weather warnings for Portugal to monitor hazardous conditions and plan accordingly using official meteorological data.
Instructions
Obter avisos meteorológicos ativos em Portugal
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:195-240 (handler)The handler function that fetches active weather warnings from the IPMA API endpoint and formats them into a text response.async getWeatherWarnings() { try { const response = await fetch(`${this.baseUrl}/forecast/warnings/warnings_www.json`); const data = await response.json(); if (!Array.isArray(data) || data.length === 0) { return { content: [ { type: "text", text: "Não há avisos meteorológicos ativos no momento." } ] }; } let result = "**Avisos Meteorológicos Ativos**\n\n"; data.forEach((warning) => { const startDate = new Date(warning.startTime).toLocaleString('pt-PT'); const endDate = new Date(warning.endTime).toLocaleString('pt-PT'); result += `**${warning.awarenessTypeName}**\n`; result += `Área: ${warning.idAreaAviso}\n`; result += `Nível: ${warning.awarenessLevelID}\n`; result += `De: ${startDate}\n`; result += `Até: ${endDate}\n`; if (warning.text) { result += `Detalhes: ${warning.text}\n`; } result += "\n"; }); return { content: [ { type: "text", text: result } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError(ErrorCode.InternalError, `Erro ao obter avisos: ${errorMessage}`); } }
- src/index.js:52-59 (schema)Tool schema registration including name, description, and input schema (no required parameters).{ name: "get_weather_warnings", description: "Obter avisos meteorológicos ativos em Portugal", inputSchema: { type: "object", properties: {} } },
- src/index.js:110-111 (registration)Registration in the tool dispatcher switch statement that routes calls to the getWeatherWarnings handler.case "get_weather_warnings": return await this.getWeatherWarnings();