Skip to main content
Glama

weather-get_daily

Retrieve daily weather forecasts for any location, with options for 1 to 15 days ahead and temperature units in Celsius or Fahrenheit.

Instructions

Get daily weather forecast for up to 15 days

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesThe city or location for which to retrieve the weather forecast.
daysNoNumber of days to forecast (1, 5, 10, or 15). Default is 5.
unitsNoTemperature unit system (metric for Celsius, imperial for Fahrenheit). Default is metric.

Implementation Reference

  • Main handler function for 'weather-get_daily' tool. Validates input with Zod, fetches location key and daily forecast from AccuWeather API, handles errors, and formats forecast data into text content array.
    export async function handler(
      args: { [x: string]: any },
      extra: RequestHandlerExtra<any, any>
    ): Promise<{ content: TextContent[] }> {
      // Validate args using the Zod schema
      let validatedArgs: z.infer<typeof inputSchema>;
      try {
        validatedArgs = inputSchema.parse(args);
      } catch (error) {
        if (error instanceof z.ZodError) {
          const errorMessages = error.errors
            .map((e) => `${e.path.join('.')}: ${e.message}`)
            .join(', ');
          return { content: [{ type: 'text', text: `Invalid input: ${errorMessages}` }] };
        }
        return { content: [{ type: 'text', text: 'An unexpected error occurred during input validation.' }] };
      }
    
      const { location, days = 5, units = "metric" } = validatedArgs;
      const apiKey = process.env.ACCUWEATHER_API_KEY;
      if (!apiKey) {
        return { content: [{ type: 'text', text: 'Error: AccuWeather API key not configured' }] };
      }
    
      try {
        // Step 1: Get location key
        const locationUrl = `https://dataservice.accuweather.com/locations/v1/cities/search?apikey=${apiKey}&q=${encodeURIComponent(location)}`;
        const locationResp = await axios.get(locationUrl);
    
        if (!locationResp.data || locationResp.data.length === 0) {
          return { content: [{ type: 'text', text: `No location found for: ${location}` }] };
        }
    
        const locationKey = locationResp.data[0].Key;
    
        // Get valid forecast period (AccuWeather supports 1, 5, 10, or 15 days)
        let forecastDays = 5; // default
        if (days === 1) forecastDays = 1;
        else if (days <= 5) forecastDays = 5;
        else if (days <= 10) forecastDays = 10;
        else forecastDays = 15;
    
        // Step 2: Get forecast with location key
        const forecastUrl = `https://dataservice.accuweather.com/forecasts/v1/daily/${forecastDays}day/${locationKey}?apikey=${apiKey}&metric=${units === "metric" ? "true" : "false"}`;
        const forecastResp = await axios.get(forecastUrl);
        const data = forecastResp.data;
    
        if (!data || !data.DailyForecasts || !Array.isArray(data.DailyForecasts) || data.DailyForecasts.length === 0) {
          return {
            content: [{ type: 'text', text: `No daily forecast data available for location: ${location}` }]
          };
        }
    
        const degreeSymbol = "°";
        const unitSymbol = units === "metric" ? "C" : "F";
    
        const content: TextContent[] = data.DailyForecasts.map((day: any) => {
          const date = new Date(day.Date);
          const formattedDate = date.toLocaleDateString('en-US', { 
            weekday: 'long', 
            year: 'numeric', 
            month: 'short', 
            day: 'numeric' 
          });
          
          return {
            type: 'text',
            text: `${formattedDate}: ${day.Temperature.Minimum.Value}${degreeSymbol}${unitSymbol} to ${day.Temperature.Maximum.Value}${degreeSymbol}${unitSymbol}, Day: ${day.Day.IconPhrase}, Night: ${day.Night.IconPhrase}${day.Day.HasPrecipitation || day.Night.HasPrecipitation ? ' (Precipitation expected)' : ''}`
          };
        });
    
        return { content };
      } catch (error) {
        console.error("WeatherDailyTool handler error:", error);
        let errorMessage = "An error occurred while fetching weather data.";
    
        if (axios.isAxiosError(error)) {
          if (error.response?.status === 401) {
            errorMessage = "Invalid AccuWeather API key. Please check your credentials.";
          } else if (error.response?.status === 404) {
            errorMessage = `Location not found: ${location}`;
          } else if (error.response) {
            errorMessage = `AccuWeather API error (${error.response.status}): ${error.response.data?.Message || error.message}`;
          } else if (error.request) {
            errorMessage = "Network error: Unable to connect to AccuWeather API.";
          }
        }
    
        return { content: [{ type: 'text', text: errorMessage }] };
      }
    }
  • JSON schema definition for the tool's input parameters, used for registration and validation.
    export const inputJsonSchema = {
      type: "object",
      description: "Parameters for the daily weather-forecast tool",
      properties: {
        location: {
          type: "string",
          description: "The location to fetch the daily forecast for",
        },
        days: {
          type: "number",
          description: "Number of days to forecast (1, 5, 10, or 15). Default is 5.",
          enum: [1, 5, 10, 15]
        },
        units: {
          type: "string",
          description: "Temperature unit system (metric for Celsius, imperial for Fahrenheit). Default is metric.",
          enum: ["metric", "imperial"]
        }
      },
      required: ["location"],
      additionalProperties: false,
    };
  • Zod schema for runtime input validation within the handler.
    export const inputShape = {
      location: z.string().min(1, "Location must be at least 1 character"),
      days: z.number().int().min(1).max(15).default(5).optional().describe("Number of days for forecast (1-15)"),
      units: z.enum(["imperial", "metric"]).default("metric").optional().describe("Temperature unit system")
    };
    
    export const inputSchema = z.object(inputShape).describe("Get daily weather forecast");
  • src/index.ts:31-54 (registration)
    Tool definition object including name, description, and input schema, used for registration.
    const dailyWeatherTool: Tool = {
      name: "weather-get_daily",
      description: "Get daily weather forecast for up to 15 days",
      inputSchema: {
        type: "object",
        properties: {
          location: {
            type: "string",
            description: "The city or location for which to retrieve the weather forecast."
          },
          days: {
            type: "number",
            description: "Number of days to forecast (1, 5, 10, or 15). Default is 5.",
            enum: [1, 5, 10, 15]
          },
          units: {
            type: "string",
            description: "Temperature unit system (metric for Celsius, imperial for Fahrenheit). Default is metric.",
            enum: ["metric", "imperial"]
          }
        },
        required: ["location"]
      }
    };
  • src/index.ts:83-86 (registration)
    Dispatch logic in CallToolRequestSchema handler that routes to the dailyHandler when tool name matches.
    if (request.params.name === "weather-get_hourly") {
      return await hourlyHandler(args, {} as RequestHandlerExtra<any, any>);
    } else if (request.params.name === "weather-get_daily") {
      return await dailyHandler(args, {} as RequestHandlerExtra<any, any>);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool 'gets' data (implying read-only) but doesn't mention rate limits, authentication requirements, data freshness, error conditions, or what the forecast includes (e.g., temperature, precipitation). For a weather API tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core purpose without unnecessary words. It's appropriately front-loaded with the main action and scope, making it easy to parse quickly. Every word earns its place in this compact formulation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a weather forecasting tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what data the forecast returns (temperature, conditions, etc.), how results are structured, whether there are usage limits, or authentication requirements. The combination of missing behavioral context and output information creates significant gaps for an agent trying to use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter-specific information beyond what's already in the schema (which has 100% coverage). It mentions 'up to 15 days' which aligns with the 'days' parameter enum, but doesn't provide additional context about parameter interactions, defaults, or practical usage examples. With complete schema documentation, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get daily weather forecast') and scope ('for up to 15 days'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from its sibling 'weather-get_hourly' beyond the 'daily' vs 'hourly' naming, missing an opportunity to clarify the distinction in forecast granularity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus its sibling 'weather-get_hourly' or any alternatives. It mentions 'up to 15 days' but doesn't explain when to choose different day counts or why one might prefer daily over hourly forecasts, leaving usage context entirely implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/TimLukaHorstmann/mcp-weather'

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