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
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Days to include (1-5) | |
| location | Yes |
Implementation Reference
- src/apis/weather/openweather.ts:91-100 (handler)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"], },
- src/tools/register.ts:22-33 (registration)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" }, }); }
- src/apis/weather/openweather.ts:60-71 (registration)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"], }, },