Skip to main content
Glama

Get Hourly Forecast

get_hourly_forecast
Read-onlyIdempotent

Retrieve hourly weather forecasts for any location by providing latitude and longitude, with customizable forecast duration up to 168 hours.

Instructions

Get hourly weather forecast for a location.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYesLatitude coordinate
longitudeYesLongitude coordinate
hoursNoNumber of forecast hours (default: 24)

Implementation Reference

  • The async handler that executes the 'get_hourly_forecast' tool logic. It receives {latitude, longitude, hours}, calls fetchHourlyForecast, and returns the result via okUntrusted.
    async ({ latitude, longitude, hours }) => {
      try {
        return okUntrusted(await fetchHourlyForecast(latitude, longitude, hours));
      } catch (e) {
        return errUpstreamFor("get hourly forecast", e, { retryable: true });
      }
    },
  • Input schema and tool definition for 'get_hourly_forecast'. Defines latitude, longitude (required), and hours (optional, default 24, max 168).
    {
      title: "Get Hourly Forecast",
      description: "Get hourly weather forecast for a location.",
      inputSchema: {
        latitude: z.number().min(-90).max(90).describe("Latitude coordinate"),
        longitude: z.number().min(-180).max(180).describe("Longitude coordinate"),
        hours: z
          .number()
          .int()
          .min(1)
          .max(168)
          .optional()
          .default(24)
          .describe("Number of forecast hours (default: 24)"),
      },
  • Registration of the 'get_hourly_forecast' tool via server.registerTool() inside registerWeatherTools().
    server.registerTool(
      "get_hourly_forecast",
      {
        title: "Get Hourly Forecast",
        description: "Get hourly weather forecast for a location.",
        inputSchema: {
          latitude: z.number().min(-90).max(90).describe("Latitude coordinate"),
          longitude: z.number().min(-180).max(180).describe("Longitude coordinate"),
          hours: z
            .number()
            .int()
            .min(1)
            .max(168)
            .optional()
            .default(24)
            .describe("Number of forecast hours (default: 24)"),
        },
        annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
      },
      async ({ latitude, longitude, hours }) => {
        try {
          return okUntrusted(await fetchHourlyForecast(latitude, longitude, hours));
        } catch (e) {
          return errUpstreamFor("get hourly forecast", e, { retryable: true });
        }
      },
    );
  • The fetchHourlyForecast helper function that calls the Open-Meteo API with hourly parameters and maps the response to an array of hourly forecast objects.
    export async function fetchHourlyForecast(latitude: number, longitude: number, hours: number) {
      const data = await fetchOpenMeteo(latitude, longitude, {
        hourly:
          "temperature_2m,relative_humidity_2m,apparent_temperature,weather_code,precipitation,precipitation_probability,wind_speed_10m,cloud_cover",
        forecast_hours: String(hours),
      });
      const h = data.hourly;
      return h.time.map((time: string, i: number) => ({
        time,
        temperature: h.temperature_2m[i],
        feelsLike: h.apparent_temperature[i],
        humidity: h.relative_humidity_2m[i],
        weatherCode: h.weather_code[i],
        weatherDescription: describeWeatherCode(h.weather_code[i]),
        precipitation: h.precipitation[i],
        precipitationProbability: h.precipitation_probability[i],
        windSpeed: h.wind_speed_10m[i],
        cloudCover: h.cloud_cover[i],
      }));
    }
  • Low-level fetchOpenMeteo helper that builds the URL, calls the Open-Meteo API, and returns the JSON response. Used by fetchHourlyForecast.
    async function fetchOpenMeteo(
      latitude: number,
      longitude: number,
      extra: Record<string, string>,
    ): Promise<OpenMeteoResponse> {
      const params = new URLSearchParams({
        latitude: String(latitude),
        longitude: String(longitude),
        timezone: "auto",
        ...extra,
      });
      const res = await fetch(`${BASE_URL}?${params}`, {
        signal: AbortSignal.timeout(TIMEOUT.GEOCODE),
      });
      if (!res.ok) throw new Error(`Open-Meteo API error: ${res.status} ${res.statusText}`);
      return (await res.json()) as OpenMeteoResponse;
    }
Behavior2/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. The description adds no behavioral details beyond repeating the tool's name. It does not contradict annotations, but adds no value.

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

Conciseness3/5

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

The description is a single concise sentence, but it lacks structure or any supplementary information. It is not verbose, but it also does not earn its place beyond the bare minimum.

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

Completeness2/5

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

Given the absence of an output schema, the description should provide more context about what the forecast includes (e.g., temperature, precipitation). Without it, the agent lacks critical operational understanding.

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?

Input schema has 100% description coverage for all three parameters (latitude, longitude, hours). The description does not add any additional parameter semantics; it merely restates the tool purpose. Baseline 3 is appropriate.

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 tool returns 'hourly weather forecast for a location,' specifying verb and resource. However, it does not distinguish it from sibling tools like 'get_daily_forecast' or 'get_current_weather,' which could cause confusion.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. There is no mention of context, prerequisites, or exclusions, leaving the agent without direction.

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/heznpc/AirMCP'

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