Skip to main content
Glama

get_weather_forecast

Retrieve weather forecasts for specific locations and date ranges using Malaysia Government's Open API data.

Instructions

Retrieve a weather forecast for a specific location within a given date range.

Args:
    location_name: The name or identifier of the location for which the forecast is retrieved.
    date_start: The earliest date (inclusive) to begin retrieving the weather forecast. If omitted, defaults to the current date.
    date_end: The latest date (inclusive) to stop retrieving the weather forecast. If omitted, defaults to the current date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
location_nameYes
date_startNo
date_endNo

Implementation Reference

  • The core handler function that validates input dates, queries the weather forecast API using the location and date range, processes the data with format_weather, and returns formatted forecasts separated by ---.
    async def get_weather_forecast(location_name: str, date_start: str = None, date_end: str = None) -> str:
        """Retrieve a weather forecast for a specific location within a given date range.
    
        Args:
            location_name: The name or identifier of the location for which the forecast is retrieved.
            date_start: The earliest date (inclusive) to begin retrieving the weather forecast. If omitted, defaults to the current date.
            date_end: The latest date (inclusive) to stop retrieving the weather forecast. If omitted, defaults to the current date.
        """
        if not date_start:
            date_start = current_date()
        elif not validate_date(date_start):
            return "Wrong `date_start` format given. Accepted format is 'YYYY-MM-DD'."
    
        if not date_end:
            date_end = current_date()
        elif not validate_date(date_end):
            return "Wrong `date_end` format given. Accepted format is 'YYYY-MM-DD'."
    
        forecast_url = f"{GOV_API_BASE}/weather/forecast"
        forecast_data = await make_api_request(forecast_url, {
                                                "meta": "true",
                                                "sort": "-date",
                                                "icontains": f"{location_name}@location__location_name",
                                                "date_start": f"{date_start}@date",
                                                "date_end": f"{date_end}@date",
                                            })
    
        if not forecast_data or "data" not in forecast_data:
            return "Unable to fetch weather forecast data for this location."
    
        if not forecast_data["data"]:
            return "No active weather forecast data for this time period."
    
        forecasts = [format_weather(forecast) for forecast in forecast_data["data"]]
        return "\n---\n".join(forecasts)
  • weather.py:81-81 (registration)
    The @mcp.tool() decorator registers this function as an MCP tool named 'get_weather_forecast', with schema inferred from signature and docstring.
    @mcp.tool()
  • Type annotations and docstring provide the input schema: required location_name (str), optional date_start/date_end (str, YYYY-MM-DD), returns formatted str.
    async def get_weather_forecast(location_name: str, date_start: str = None, date_end: str = None) -> str:
        """Retrieve a weather forecast for a specific location within a given date range.
    
        Args:
            location_name: The name or identifier of the location for which the forecast is retrieved.
            date_start: The earliest date (inclusive) to begin retrieving the weather forecast. If omitted, defaults to the current date.
            date_end: The latest date (inclusive) to stop retrieving the weather forecast. If omitted, defaults to the current date.
        """
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes what the tool does (retrieve forecast) but lacks details on behavioral traits such as rate limits, authentication needs, error handling, or what happens if dates are invalid. This is a significant gap for a tool with no annotation coverage.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded: the first sentence states the purpose clearly, followed by a structured 'Args' section. Every sentence adds value, with no wasted words, though the structure could be slightly more streamlined (e.g., integrating defaults into the main description).

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

Completeness3/5

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

Given no annotations, no output schema, and 3 parameters, the description is moderately complete. It covers the purpose and parameters well but lacks details on return values, error cases, or behavioral context. For a retrieval tool with no structured support, it meets minimum viability but has clear gaps in completeness.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics beyond the schema by explaining each parameter: location_name as 'name or identifier', date_start and date_end with defaults and inclusivity. This clarifies usage effectively, though it could specify date format or location identifier examples for a higher score.

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: 'Retrieve a weather forecast for a specific location within a given date range.' It specifies the verb (retrieve), resource (weather forecast), and scope (location and date range). However, it does not explicitly differentiate from sibling tools like get_earthquake_news or get_warning, which handle different types of data, so it falls short of a perfect score.

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 alternatives. It does not mention sibling tools or other contexts where this tool might be preferred or avoided. Usage is implied by the purpose but lacks explicit instructions, leaving gaps for an AI agent to infer correctly.

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

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