Skip to main content
Glama

weather_forecast

Get weather forecasts for 1 to 14 days for any location using city names, coordinates, or postal codes to plan activities and prepare for conditions.

Instructions

Get weather forecast (1-14 days) for a location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesLocation query (city name, lat/lon, postal code, etc)
daysNoNumber of days (1-14)

Implementation Reference

  • Handler logic for the weather_forecast tool within the tools/call method. Validates location 'q' and days (1-14), then fetches forecast data using the shared fetch function.
    elif tool_name == "weather_forecast":
        q = arguments.get("q")
        days = arguments.get("days", 1)
        if not q:
            raise ValueError("Location (q) is required")
        if days < 1 or days > 14:
            raise ValueError("Days must be between 1 and 14")
        result = await fetch("forecast.json", {"q": q, "days": days})
        content = json.dumps(result, indent=2)
  • server.py:128-146 (registration)
    Registration of the weather_forecast tool in the tools/list response, including name, description, and input schema.
    {
        "name": "weather_forecast",
        "description": "Get weather forecast (1-14 days) for a location",
        "inputSchema": {
            "type": "object",
            "properties": {
                "q": {
                    "type": "string",
                    "description": "Location query (city name, lat/lon, postal code, etc)"
                },
                "days": {
                    "type": "integer",
                    "description": "Number of days (1-14)",
                    "default": 1
                }
            },
            "required": ["q"]
        }
    },
  • Input schema for weather_forecast tool, specifying parameters 'q' (required) and 'days' (optional, default 1).
    "inputSchema": {
        "type": "object",
        "properties": {
            "q": {
                "type": "string",
                "description": "Location query (city name, lat/lon, postal code, etc)"
            },
            "days": {
                "type": "integer",
                "description": "Number of days (1-14)",
                "default": 1
            }
        },
        "required": ["q"]
    }
  • Shared helper function that performs the actual API call to WeatherAPI.com for all weather tools, including forecast.
    async def fetch(endpoint: str, params: dict) -> dict:
        """Perform async GET to WeatherAPI and return JSON."""
        logger.debug(f"fetch() called with endpoint: {endpoint}, params: {params}")
        
        if not WEATHER_API_KEY:
            logger.error("Weather API key not set.")
            raise Exception("Weather API key not set.")
    
        params["key"] = WEATHER_API_KEY
        url = f"https://api.weatherapi.com/v1/{endpoint}"
        logger.info(f"Requesting {url}")
        
        async with httpx.AsyncClient() as client:
            logger.debug("HTTPx client created")
            try:
                resp = await client.get(url, params=params)
                logger.debug(f"HTTP response received: status={resp.status_code}")
                
                if resp.status_code != 200:
                    try:
                        error_data = resp.json()
                        detail = error_data.get("error", {}).get("message", resp.text)
                    except:
                        detail = resp.text
                    logger.error(f"WeatherAPI error {resp.status_code}: {detail}")
                    raise Exception(f"WeatherAPI error {resp.status_code}: {detail}")
                    
                data = resp.json()
                logger.debug(f"JSON parsing successful")
                logger.info(f"WeatherAPI success: {url}")
                return data
                
            except httpx.RequestError as e:
                logger.error(f"HTTPX request error: {e}")
                raise Exception(f"Request error: {e}")
            except Exception as e:
                logger.error(f"Unexpected error: {e}")
                raise Exception(f"Unexpected error: {e}")
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 what the tool does but lacks critical behavioral details such as rate limits, authentication requirements, error handling, or response format. For a tool with no annotation coverage, this is a significant gap in transparency.

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 functionality ('Get weather forecast') and includes key constraints (1-14 days, for a location) without any wasted words. It's appropriately sized for the tool's complexity.

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. It doesn't address behavioral aspects like rate limits or auth, and while the input schema is well-documented, the description fails to compensate for missing context about what the forecast returns (e.g., temperature, precipitation) or how errors are handled.

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 schema description coverage is 100%, so the input schema already fully documents both parameters (q and days). The description adds minimal value beyond the schema by implying the tool uses location queries and a day range, but doesn't provide additional syntax, format details, or usage examples. This meets the baseline for high schema coverage.

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 tool's purpose with a specific verb ('Get') and resource ('weather forecast'), and includes the time range (1-14 days) and target ('for a location'). However, it doesn't explicitly differentiate from its sibling tools (weather_current and weather_search), which would require mentioning it provides future predictions rather than current conditions or search functionality.

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 siblings (weather_current and weather_search). It doesn't mention alternatives, exclusions, or specific contexts for use, leaving the agent to infer based on tool names alone.

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/first-it-consulting/weather-mcp-server'

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