Skip to main content
Glama

get_weather_stations

Retrieve real-time observational data from Portuguese meteorological stations to monitor current weather conditions across Portugal.

Instructions

Obter dados de observação das estações meteorológicas

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that fetches current weather observations from IPMA meteorological stations API, gets station names, selects latest observations for up to 15 stations, formats temperature, humidity, pressure, wind, precipitation into a markdown text response.
    async getWeatherStations() { try { const response = await fetch(`${this.baseUrl}/observation/meteorology/stations/observations.json`); const data = await response.json(); const stationsResponse = await fetch(`${this.baseUrl}/observation/meteorology/stations/stations.json`); const stationsData = await stationsResponse.json(); const stationsInfo = stationsData.reduce((acc, station) => { acc[station.properties.idEstacao] = station.properties.localEstacao; return acc; }, {}); let result = "**Observações das Estações Meteorológicas**\n\n"; const timestamps = Object.keys(data); const latestTimestamp = timestamps[timestamps.length - 1]; const latestObservations = data[latestTimestamp]; result += `Observações de: ${latestTimestamp}\n\n`; const stationIds = Object.keys(latestObservations).slice(0, 15); stationIds.forEach((stationId) => { const obs = latestObservations[stationId]; const stationName = stationsInfo[stationId] || `Estação ${stationId}`; result += `**${stationName}**\n`; if (obs.temperatura > -99) result += `Temperatura: ${obs.temperatura}°C\n`; if (obs.humidade > -99) result += `Humidade: ${obs.humidade}%\n`; if (obs.pressao > -99) result += `Pressão: ${obs.pressao} hPa\n`; if (obs.intensidadeVento > -99) result += `Vento: ${obs.intensidadeVento} m/s\n`; if (obs.precAcumulada > -99) result += `Precipitação: ${obs.precAcumulada} mm\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 dados das estações: ${errorMessage}`); } }
  • src/index.js:82-89 (registration)
    Tool registration in the ListToolsRequestHandler response, defining the tool name, description, and input schema (no required parameters).
    { name: "get_weather_stations", description: "Obter dados de observação das estações meteorológicas", inputSchema: { type: "object", properties: {} } },
  • src/index.js:116-117 (registration)
    Switch case in CallToolRequestHandler that routes calls to the getWeatherStations handler method.
    case "get_weather_stations": return await this.getWeatherStations();
  • Input schema definition for the get_weather_stations tool, specifying an object with no properties.
    inputSchema: { type: "object", properties: {} }

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/brandao-20/mcp_server_ipma'

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