Skip to main content
Glama

get_current_weather

Retrieve current weather data including temperature, wind, humidity, pressure, UV index, visibility, and conditions for any location. Optionally includes air quality information.

Instructions

Get real-time current weather for any location. Returns temperature, wind speed and direction, humidity, pressure, UV index, visibility, feels-like temperature, and weather condition. Optionally includes air quality (AQI) data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesLocation query. Accepts: city name (London), lat/lon (51.5,-0.1), US zip (10001), UK postcode (SW1), IATA airport code (iata:LHR), IP address, or auto:ip for caller's location.
aqiNoInclude air quality data (CO, NO2, O3, SO2, PM2.5, PM10). Default: no.

Implementation Reference

  • Handler logic for the get_current_weather tool.
    case "get_current_weather": {
      const { q, aqi = "no" } = args as { q: string; aqi?: string };
      result = await weatherRequest("/current.json", { q, aqi });
      break;
    }
  • Schema registration for get_current_weather.
    {
      name: "get_current_weather",
      description:
        "Get real-time current weather for any location. Returns temperature, wind speed and direction, humidity, pressure, UV index, visibility, feels-like temperature, and weather condition. Optionally includes air quality (AQI) data.",
      inputSchema: {
        type: "object",
        properties: {
          q: {
            type: "string",
            description:
              "Location query. Accepts: city name (London), lat/lon (51.5,-0.1), US zip (10001), UK postcode (SW1), IATA airport code (iata:LHR), IP address, or auto:ip for caller's location.",
          },
          aqi: {
            type: "string",
            enum: ["yes", "no"],
            description: "Include air quality data (CO, NO2, O3, SO2, PM2.5, PM10). Default: no.",
          },
        },
        required: ["q"],
      },
  • Helper function used by tools to perform API requests.
    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}`
        );
      }
      return data;
    }

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