Skip to main content
Glama

get_historical_data

Retrieve historical meteorological data for a specific station using its identifier and a date range.

Instructions

Obtain historical meteorological data for a specific station.

Args: station_id: Identifier of the station (e.g. "3195" for Madrid Retiro) start_date: Start date in format YYYYY-MM-DD end_date: End date in format YYYYY-MM-DD

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
station_idYes
start_dateYes
end_dateYes

Implementation Reference

  • The actual handler function for the get_historical_data tool. It constructs the AEMET API URL for daily climatological data and delegates to make_aemet_request for the HTTP call and response parsing.
    @mcp.tool()
    async def get_historical_data(station_id: str, start_date: str, end_date: str):
        """Obtain historical meteorological data for a specific station.
        
        Args:
            station_id: Identifier of the station (e.g. "3195" for Madrid Retiro)
            start_date: Start date in format YYYYY-MM-DD
            end_date: End date in format YYYYY-MM-DD
        """
    
        start = start_date + "T00:00:00UTC"
        end = end_date + "T23:59:59UTC"
        url = f"{AEMET_API_BASE}/valores/climatologicos/diarios/datos/fechaini/{start}/fechafin/{end}/estacion/{station_id}"
        return await make_aemet_request(url)
  • The tool is registered via the @mcp.tool() decorator on line 248, which is the FastMCP framework's way of registering an MCP tool.
    @mcp.tool()
  • The make_aemet_request helper function that performs the HTTP request to the AEMET API using an API key, handles the redirect to the actual data URL, and decodes the response from latin1.
    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
Behavior2/5

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

No annotations provided; description only states it obtains data but does not disclose any behavioral traits such as read-only nature, data availability limitations, rate limits, or error handling. Misses opportunity to inform agent about API constraints.

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?

Relatively concise docstring with purpose and parameter list. Every sentence adds value, but the format could be more streamlined without the 'Args' boilerplate.

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?

No output schema; description does not explain what the returned data looks like (e.g., fields, structure). Lacks examples or details on station availability, making it incomplete for an agent to fully understand usage.

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 has 0% description coverage; description compensates by explaining station_id (with example), start_date and end_date formats. Adds significant meaning beyond schema titles, though date format has a typo (5 Y's).

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

Purpose5/5

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

Clearly states 'Obtain historical meteorological data for a specific station', specifying verb (obtain), resource (historical meteorological data), and scope (specific station). Distinguishes from siblings like get_daily_forecast (forecast) and get_station_data (likely current/summary).

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

Usage Guidelines3/5

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

Implies usage for historical data ranges via name and description, but no explicit guidance on when to use this vs siblings (e.g., get_station_data, monthly_climate_data). No exclusion criteria or alternatives mentioned.

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