get-minutely-forecast
Retrieve minute-by-minute precipitation forecasts for the next hour using location data. Input a city name or coordinates to access detailed weather predictions for up to 60 minutes.
Instructions
Get minute-by-minute precipitation forecast for next hour
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of minutes to forecast (1-60, default: 60) | |
| location | Yes | City name (e.g., 'New York') or coordinates (e.g., 'lat,lon') |
Implementation Reference
- src/main.ts:385-446 (handler)The execute handler function implementing the core logic for the get-minutely-forecast tool: resolves location, fetches minutely precipitation forecast from OpenWeatherMap API, formats the response as JSON with precipitation amounts and descriptions.execute: async (args, { session, log }) => { try { log.info("Getting minutely weather forecast", { location: args.location, limit: args.limit }); // Get OpenWeather client const client = getOpenWeatherClient(session as SessionData | undefined); // Configure client for this request configureClientForLocation(client, args.location); // Fetch minutely forecast data const requestedMinutes = args.limit || 60; const minutelyData = await client.getMinutelyForecast(requestedMinutes); log.info("Successfully retrieved minutely weather forecast", { location: args.location, minutes: minutelyData.length }); // Format the response const formattedForecast = JSON.stringify({ location: args.location, minutes_requested: requestedMinutes, forecast: minutelyData.map((minute, index) => ({ minute_offset: index + 1, time: minute.dt.toISOString(), precipitation: minute.weather.rain, precipitation_description: minute.weather.rain > 0 ? (minute.weather.rain < 0.1 ? 'Light rain' : minute.weather.rain < 0.5 ? 'Moderate rain' : 'Heavy rain') : 'No precipitation' })) }, null, 2); return { content: [ { type: "text", text: formattedForecast } ] }; } catch (error) { log.error("Failed to get minutely weather forecast", { error: error instanceof Error ? error.message : 'Unknown error' }); // Provide helpful error messages if (error instanceof Error) { if (error.message.includes('city not found')) { throw new Error(`Location "${args.location}" not found. Please check the spelling or try using coordinates.`); } if (error.message.includes('Invalid API key')) { throw new Error('Invalid OpenWeatherMap API key. Please check your configuration.'); } } throw new Error(`Failed to get minutely weather forecast: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
- src/main.ts:381-447 (registration)Registration of the get-minutely-forecast tool using server.addTool, including name, description, input schema, and execute handler.server.addTool({ name: "get-minutely-forecast", description: "Get minute-by-minute precipitation forecast for next hour", parameters: getMinutelyForecastSchema, execute: async (args, { session, log }) => { try { log.info("Getting minutely weather forecast", { location: args.location, limit: args.limit }); // Get OpenWeather client const client = getOpenWeatherClient(session as SessionData | undefined); // Configure client for this request configureClientForLocation(client, args.location); // Fetch minutely forecast data const requestedMinutes = args.limit || 60; const minutelyData = await client.getMinutelyForecast(requestedMinutes); log.info("Successfully retrieved minutely weather forecast", { location: args.location, minutes: minutelyData.length }); // Format the response const formattedForecast = JSON.stringify({ location: args.location, minutes_requested: requestedMinutes, forecast: minutelyData.map((minute, index) => ({ minute_offset: index + 1, time: minute.dt.toISOString(), precipitation: minute.weather.rain, precipitation_description: minute.weather.rain > 0 ? (minute.weather.rain < 0.1 ? 'Light rain' : minute.weather.rain < 0.5 ? 'Moderate rain' : 'Heavy rain') : 'No precipitation' })) }, null, 2); return { content: [ { type: "text", text: formattedForecast } ] }; } catch (error) { log.error("Failed to get minutely weather forecast", { error: error instanceof Error ? error.message : 'Unknown error' }); // Provide helpful error messages if (error instanceof Error) { if (error.message.includes('city not found')) { throw new Error(`Location "${args.location}" not found. Please check the spelling or try using coordinates.`); } if (error.message.includes('Invalid API key')) { throw new Error('Invalid OpenWeatherMap API key. Please check your configuration.'); } } throw new Error(`Failed to get minutely weather forecast: ${error instanceof Error ? error.message : 'Unknown error'}`); } } });
- src/schemas.ts:44-47 (schema)Zod schema defining the input parameters for the get-minutely-forecast tool: location (string) and optional limit (number 1-60).export const getMinutelyForecastSchema = z.object({ location: z.string().describe("City name (e.g., 'New York') or coordinates (e.g., 'lat,lon')"), limit: z.number().min(1).max(60).optional().describe("Number of minutes to forecast (1-60, default: 60)"), });