Skip to main content
Glama

get-forecast

Retrieve a 5-day weather forecast for any city using location details. Input city name and optional country code to fetch accurate weather predictions.

Instructions

Get 5-day weather forecast for a location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityYesCity name (e.g. Beijing, London)
countryNoCountry code (e.g. CN, GB)

Implementation Reference

  • Main implementation of the get-forecast tool logic: fetches raw forecast data from service and formats it into a readable 5-day text summary.
    async getForecast(city: string, country?: string): Promise<string> {
      const forecastData = await this.weatherService.getForecast(city, country);
    
      if (!forecastData) {
        return `Failed to retrieve forecast data for ${country ? `${city}, ${country}` : city}`;
      }
    
      const forecasts = forecastData.list
        .filter((_, index) => index % 8 === 0) // Get one forecast per day
        .map(forecast => [
          `\nDate: ${forecast.dt_txt.split(" ")[0]}`,
          `Temperature: ${forecast.main.temp}°C (Feels like: ${forecast.main.feels_like}°C)`,
          `Conditions: ${forecast.weather[0].main} - ${forecast.weather[0].description}`,
          `Humidity: ${forecast.main.humidity}%`,
          `Wind Speed: ${forecast.wind.speed} m/s`,
          "---"
        ].join("\n"));
    
      return `5-day forecast for ${forecastData.city.name}, ${forecastData.city.country}:\n${forecasts.join("\n")}`;
    }
  • Registers the 'get-forecast' MCP tool with description, input schema (Zod), and handler that delegates to WeatherController.getForecast().
    server.tool(
      "get-forecast",
      "Get 5-day weather forecast for a location",
      {
        city: z.string().describe("City name (e.g. Beijing, London)"),
        country: z.string().optional().describe("Country code (e.g. CN, GB)")
      },
      async ({ city, country }) => {
        const forecastText = await weatherController.getForecast(city, country);
        return {
          content: [
            {
              type: "text",
              text: forecastText,
            },
          ],
        };
      }
    );
  • Helper method in WeatherService that constructs the API query and fetches raw forecast data from OpenWeatherMap.
    async getForecast(city: string, country?: string): Promise<ForecastData | null> {
      const query = country ? `${city},${country}` : city;
      return this.makeRequest<ForecastData>("forecast", { q: query });
    }
  • TypeScript interface defining the structure of the OpenWeather forecast response data for type safety.
    export interface ForecastData {
      list: Array<{
        dt_txt: string;
        main: {
          temp: number;
          feels_like: number;
          humidity: number;
        };
        weather: Array<{
          main: string;
          description: string;
        }>;
        wind: {
          speed: number;
          deg: number;
        };
      }>;
      city: {
        name: string;
        country: string;
      };
    } 
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves a forecast but omits critical details such as rate limits, authentication requirements, data freshness, or error handling. For a read operation without annotations, this leaves significant gaps in understanding how the tool behaves beyond its basic function.

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 front-loads the core purpose without any wasted words. It's appropriately sized for a simple tool, making it easy to parse and understand quickly. Every part of the sentence contributes directly to clarifying the tool's function.

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?

Given the lack of annotations and output schema, the description is incomplete for effective use. It doesn't explain what the forecast data includes (e.g., temperature, precipitation), how results are structured, or any limitations. For a tool with two parameters and no structured output, more contextual detail is needed to guide the agent adequately.

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 input schema has 100% description coverage, with clear documentation for both parameters ('city' and 'country'). The description adds no additional semantic context beyond implying a 'location' parameter, which is already covered by the schema. This meets the baseline score of 3, as the schema does the heavy lifting without extra value from the description.

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') and resource ('5-day weather forecast for a location'), making the purpose immediately understandable. It doesn't explicitly differentiate from the sibling 'get-current-weather' tool, which prevents a score of 5, but it's specific enough to convey what the tool does without being vague or tautological.

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 the sibling 'get-current-weather' tool. It lacks any mention of alternatives, prerequisites, or contextual usage scenarios, leaving the agent to infer based on tool names alone. This minimal guidance is insufficient for optimal tool selection.

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

Related 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/fist-maestro/mcp-servers'

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