no_weather_forecast
Get weather forecasts for locations in Norway using MET Norway data. Specify a city or coordinates to receive hourly predictions for up to 72 hours ahead.
Instructions
Get weather forecast for a location in Norway using MET Norway (yr.no). Returns hourly data for the next N hours.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes | Norwegian city name or lat,lon coordinates | |
| hours | No | Hours ahead to forecast (default 24, max 72) |
Implementation Reference
- src/servers/norwegian-weather.js:153-182 (handler)The handler function for the 'no_weather_forecast' tool, which fetches weather data based on the provided location and hours.
async ({ location, hours }) => { try { const loc = await getLocation(location); const data = await fetchForecast(loc.lat, loc.lon); const ts = data.properties.timeseries; const maxHours = hours || 24; const slice = ts.slice(0, maxHours); const lines = [`## ${loc.name} — ${maxHours}h Forecast\n`]; for (const entry of slice) { const t = new Date(entry.time); const time = t.toLocaleString("nb-NO", { timeZone: "Europe/Oslo", weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" }); const inst = entry.data.instant.details; const symbol = entry.data.next_1_hours?.summary?.symbol_code || entry.data.next_6_hours?.summary?.symbol_code || ""; const precip = entry.data.next_1_hours?.details?.precipitation_amount; lines.push(`**${time}:** ${inst.air_temperature}°C, ${symbolToText(symbol)}, wind ${inst.wind_speed} m/s${precip != null ? `, ${precip} mm` : ""}`); } lines.push(`\n*MET Norway Locationforecast 2.0*`); return { content: [{ type: "text", text: lines.join("\n") }] }; } catch (err) { return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true }; } } ); } - src/servers/norwegian-weather.js:146-152 (registration)Tool registration for 'no_weather_forecast' including name, description, and input schema.
server.tool( "no_weather_forecast", "Get weather forecast for a location in Norway using MET Norway (yr.no). Returns hourly data for the next N hours.", { location: z.string().describe("Norwegian city name or lat,lon coordinates"), hours: z.number().min(1).max(72).optional().describe("Hours ahead to forecast (default 24, max 72)"), },