Skip to main content
Glama

get_weather_forecast

Retrieve a 5-day weather forecast with 3-hour intervals for any city. Specify the location and optional days (1-5) to access detailed weather predictions via the Multi-MCPs server.

Instructions

Get 5-day/3-hour forecast by city name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoDays to include (1-5)
locationYes

Implementation Reference

  • The main execution handler for the get_weather_forecast tool. It validates the API key and location, fetches the forecast data using the client, and optionally limits the forecast list based on the 'days' parameter.
    async get_weather_forecast(args: Record<string, unknown>) { if (!cfg.openWeatherApiKey) throw new Error("OPENWEATHER_API_KEY is not configured"); const location = String(args.location || ""); const days = args.days ? Number(args.days) : undefined; if (!location) throw new Error("location is required"); const data: any = await client.forecastByCity(location); if (!days) return data; const count = Math.max(1, Math.min(5, days)); const list = (data as any).list || []; return { ...(data as object), list: list.slice(0, count * 8) } as any;
  • Input schema for the tool, specifying 'location' as required string and optional 'days' number.
    inputSchema: { type: "object", properties: { location: { type: "string" }, days: { type: "number", description: "Days to include (1-5)" }, }, required: ["location"], },
  • Global tool registration where registerOpenWeather() is called to include the get_weather_forecast tool (among others) in the aggregated tools and handlers list.
    const registrations: ToolRegistration[] = [ registerOpenWeather(), registerGoogleMaps(), registerNewsApi(), registerGitHub(), registerNotion(), registerTrello(), registerSpotify(), registerTwilio(), registerUnsplash(), registerCoinGecko(), ];
  • Supporting method in OpenWeatherClient that performs the actual API request to retrieve the weather forecast data for a given location.
    async forecastByCity(location: string) { return this.request("/data/2.5/forecast", { query: { q: location, appid: this.apiKey, units: "metric" }, }); }
  • Tool specification registration within the registerOpenWeather() function, defining name, description, and input schema.
    { name: "get_weather_forecast", description: "Get 5-day/3-hour forecast by city name", inputSchema: { type: "object", properties: { location: { type: "string" }, days: { type: "number", description: "Days to include (1-5)" }, }, required: ["location"], }, },

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/TaylorChen/muti-mcps'

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