get_weather_warnings
Retrieve active weather warnings for Portugal to monitor meteorological hazards and plan accordingly using IPMA data.
Instructions
Obter avisos meteorológicos ativos em Portugal
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_weather_warnings"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:299-344 (handler)The handler function that fetches active weather warnings from the IPMA API, processes them, and formats a response message.
private async getWeatherWarnings() { try { const response = await fetch(`${this.baseUrl}/forecast/warnings/warnings_www.json`); const data = await response.json() as WeatherWarning[]; 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: WeatherWarning) => { 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.ts:151-158 (registration)Tool registration in the ListTools response, including name, description, and empty input schema.
{ name: "get_weather_warnings", description: "Obter avisos meteorológicos ativos em Portugal", inputSchema: { type: "object", properties: {} } }, - src/index.ts:211-212 (registration)Dispatch case in the main CallToolRequest handler that invokes the getWeatherWarnings method.
case "get_weather_warnings": return await this.getWeatherWarnings(); - src/index.ts:26-33 (schema)TypeScript interface defining the structure of weather warning data from the API.
interface WeatherWarning { text: string; awarenessTypeName: string; idAreaAviso: string; startTime: string; awarenessLevelID: string; endTime: string; }