Skip to main content
Glama

get_forecast

Retrieve detailed weather forecasts for 1-14 days with daily summaries, hourly breakdowns, current conditions, astronomy data, and optional alerts and air quality information for any location worldwide.

Instructions

Get weather forecast for 1 to 14 days. Returns daily summaries (max/min/avg temp, rain chance, UV, wind) and hourly breakdowns. Also returns current conditions, astronomy data (sunrise/sunset/moon phase), and optionally weather alerts and air quality.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesLocation query — city name, lat/lon, zip, postcode, IATA, or IP.
daysNoNumber of forecast days (1–14). Default: 3.
alertsNoInclude government weather alerts. Default: no.
aqiNoInclude air quality data. Default: no.

Implementation Reference

  • The handler for 'get_forecast' extracts arguments from the request and calls 'weatherRequest'.
    case "get_forecast": {
      const { q, days = 3, alerts = "no", aqi = "no" } = args as {
        q: string;
        days?: number;
        alerts?: string;
        aqi?: string;
      };
      result = await weatherRequest("/forecast.json", { q, days, alerts, aqi });
      break;
    }
  • Registration of the 'get_forecast' tool with its description and input schema.
    name: "get_forecast",
    description:
      "Get weather forecast for 1 to 14 days. Returns daily summaries (max/min/avg temp, rain chance, UV, wind) and hourly breakdowns. Also returns current conditions, astronomy data (sunrise/sunset/moon phase), and optionally weather alerts and air quality.",
    inputSchema: {
      type: "object",
      properties: {
        q: {
          type: "string",
          description: "Location query — city name, lat/lon, zip, postcode, IATA, or IP.",
        },
        days: {
          type: "number",
          description: "Number of forecast days (1–14). Default: 3.",
        },
        alerts: {
          type: "string",
  • The 'weatherRequest' helper function that executes the actual API call for all weather tools.
    async function weatherRequest(
      endpoint: string,
      params: Record<string, string | number>
    ): Promise<unknown> {
      const searchParams = new URLSearchParams({ key: API_KEY! });
      for (const [k, v] of Object.entries(params)) {
        searchParams.set(k, String(v));
      }
      const url = `${BASE_URL}${endpoint}?${searchParams.toString()}`;
      const res = await fetch(url);
      const data = await res.json();
      if (!res.ok) {
        const err = data as { error?: { code: number; message: string } };
        throw new McpError(
          ErrorCode.InternalError,
          `WeatherAPI error ${err.error?.code}: ${err.error?.message ?? res.statusText}`
        );

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/weatherapicom/weatherapi-mcp'

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