Skip to main content
Glama

monthly_climate_data

Retrieve monthly climate summaries from any AEMET weather station by providing station ID, year, and month. Get temperature, precipitation, and other climatological values.

Instructions

Retrieve monthly climatological data for a specific weather station.

Args: station_id: Weather station identifier (e.g., "3195" for Madrid Retiro). year: Year (YYYY). month: Month (1-12).

Returns: A JSON with the monthly climate summary.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
station_idYes
yearYes
monthYes

Implementation Reference

  • The tool handler function. It takes a station_id, year, and month, builds the AEMET API URL for monthly/annual climatological data, and delegates to the make_aemet_request helper.
    @mcp.tool()
    async def monthly_climate_data(station_id: str, year: int, month: int):
        """Retrieve monthly climatological data for a specific weather station.
        
        Args:
            station_id: Weather station identifier (e.g., "3195" for Madrid Retiro).
            year: Year (YYYY).
            month: Month (1-12).
            
        Returns:
            A JSON with the monthly climate summary.
        """
    
        url = f"{AEMET_API_BASE}/valores/climatologicos/mensualesanuales/datos/anioini/{year}/aniofin/{year}/estacion/{station_id}"
        return await make_aemet_request(url)
  • The @mcp.tool() decorator registers monthly_climate_data as an MCP tool on the FastMCP server instance.
    @mcp.tool()
  • Shared helper used by the handler. It makes an authenticated GET request to AEMET's API, follows the redirect to the actual data URL, decodes the response as latin1, and returns parsed JSON.
    async def make_aemet_request(url: str) -> dict[str, Any] | list[Any] | None:
        logger.info(f"make_aemet_request")
        headers = {
            "api_key": API_KEY,
            "Accept": "application/json"
        }
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(url, headers=headers, timeout=30.0)
                response.raise_for_status()
                data_info = response.json()
                if data_info.get("estado") == 200:
                    data_url = data_info.get("datos")
                    if data_url:
                        data_response = await client.get(data_url, timeout=30.0)
                        data_response.raise_for_status()
                        content = data_response.content.decode('latin1')
                        return json.loads(content)
                return None
            except Exception as e:
                logger.error(f"Error connecting to AEMET: {str(e)}")
                return None
  • The docstring acts as the schema/description for the MCP tool, specifying that station_id (str), year (int), and month (int) are the inputs.
    """Retrieve monthly climatological data for a specific weather station.
    
    Args:
        station_id: Weather station identifier (e.g., "3195" for Madrid Retiro).
        year: Year (YYYY).
        month: Month (1-12).
        
    Returns:
        A JSON with the monthly climate summary.
    """
Behavior2/5

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

No annotations provided. Description indicates a read operation ('retrieve') but doesn't explicitly state it's read-only or disclose any side effects. For a read tool without annotations, the description should explicitly mention it is non-destructive.

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?

Concise docstring format with Args and Returns. No unnecessary words. Efficient.

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?

Tool is simple with 3 parameters and no output schema. Description covers input parameters and return type (JSON summary), but lacks usage context and output schema details. Adequate but could be improved.

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?

Schema coverage 0%, description adds meaning by providing an example station ID ('3195' for Madrid Retiro) and specifying year format (YYYY) and month range (1-12). However, it doesn't clarify valid ranges or other constraints.

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?

Clear verb 'Retrieve' and specific resource 'monthly climatological data' for a weather station. Distinguishes from siblings like get_daily_forecast or get_historical_data by specifying monthly granularity, though no explicit differentiation.

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?

No guidance on when to use this tool vs alternatives like get_historical_data. The description does not mention any context or constraints.

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/AnCode666/aemet-mcp'

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