Skip to main content
Glama
robobobby

mcp-norwegian-weather

by robobobby

weather_forecast

Get hourly weather forecasts for Norwegian locations to plan activities and prepare for changing conditions. Specify a city or coordinates and forecast duration up to 72 hours.

Instructions

Get hourly weather forecast for a location in Norway using MET Norway (yr.no).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesNorwegian city name or lat,lon coordinates
hoursNoHours ahead (default 24, max 72)

Implementation Reference

  • src/index.js:138-166 (registration)
    Registration of weather_forecast tool with the MCP server, including the schema definition (location and hours parameters) and the handler function
    server.tool(
      "weather_forecast",
      "Get hourly weather forecast for a location in Norway using MET Norway (yr.no).",
      {
        location: z.string().describe("Norwegian city name or lat,lon coordinates"),
        hours: z.number().min(1).max(72).optional().describe("Hours ahead (default 24, max 72)"),
      },
      async ({ location, hours }) => {
        try {
          const loc = await getLocation(location);
          const data = await fetchForecast(loc.lat, loc.lon);
          const maxHours = hours || 24;
          const slice = data.properties.timeseries.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 };
        }
      }
    );
  • The main handler logic for weather_forecast tool that fetches forecast data, processes hourly entries, and formats output with temperature, weather conditions, wind, and precipitation
    async ({ location, hours }) => {
      try {
        const loc = await getLocation(location);
        const data = await fetchForecast(loc.lat, loc.lon);
        const maxHours = hours || 24;
        const slice = data.properties.timeseries.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 };
      }
    }
  • fetchForecast helper function that makes the actual API call to MET Norway Locationforecast 2.0 API to retrieve weather data for given coordinates
    async function fetchForecast(lat, lon) {
      const url = `${BASE_URL}/complete?lat=${lat.toFixed(4)}&lon=${lon.toFixed(4)}`;
      const res = await fetch(url, { headers: { "User-Agent": USER_AGENT } });
      if (!res.ok) throw new Error(`MET Norway API error (${res.status}): ${await res.text()}`);
      return res.json();
    }
  • getLocation helper function that resolves location input (city name or lat,lon coordinates) to actual coordinates using predefined cities or geocoding API
    async function getLocation(input) {
      const loc = resolveLocation(input);
      if (loc) return loc;
      const geo = await geocode(input);
      if (geo) return geo;
      throw new Error(`Could not find location "${input}" in Norway. Try a city name or lat,lon coordinates.`);
    }
  • symbolToText helper function that converts MET Norway weather symbol codes to human-readable weather condition descriptions
    function symbolToText(symbol) {
      if (!symbol) return "Unknown";
      const base = symbol.replace(/_(day|night|polartwilight)$/, "");
      return SYMBOL_MAP[base] || base;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions the data source ('MET Norway (yr.no)') which adds useful context about reliability and regional focus. However, it lacks behavioral details like rate limits, authentication needs, error handling, or what the forecast includes (e.g., temperature, precipitation).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It front-loads the core purpose ('Get hourly weather forecast') and includes essential context (location scope and data source) without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description provides basic purpose and scope but lacks details on behavior, return values, or error cases. For a simple read-only tool with full schema coverage, this is minimally adequate but leaves gaps in understanding how the tool behaves in practice.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters. The description doesn't add any parameter-specific details beyond what's in the schema (e.g., it doesn't clarify format for 'location' or typical values for 'hours'). Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get hourly weather forecast'), resource ('for a location in Norway'), and data source ('using MET Norway (yr.no)'). It distinguishes from the sibling 'current_weather' by specifying 'hourly forecast' versus current conditions. However, it doesn't explicitly contrast with the sibling tool name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'hourly weather forecast' and 'Norway', suggesting this is for future predictions rather than current conditions. However, it doesn't provide explicit guidance on when to use this versus the 'current_weather' sibling tool or any exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/robobobby/mcp-norwegian-weather'

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