Skip to main content
Glama

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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();
  • 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; }

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/DiogoAzevedo03/ipma-mcp-server'

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