Skip to main content
Glama

get_station_data

Retrieve detailed weather data for a specific station by providing its unique identifier, sourced directly from Spain's State Meteorological Agency (AEMET) API.

Instructions

Obtain specific weather data for a weather station.

Args: station_id: Station identifier (e.g., "8416Y" for Valencia))

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
station_idYes

Implementation Reference

  • The handler function that executes the tool logic: constructs the AEMET observation API URL for the given station_id and calls the make_aemet_request helper to fetch and parse the data.
    async def get_station_data(station_id: str): """Obtain specific weather data for a weather station. Args: station_id: Station identifier (e.g., "8416Y" for Valencia)) """ url = f"{AEMET_API_BASE}/observacion/convencional/datos/estacion/{station_id}" return await make_aemet_request(url)
  • The @mcp.tool() decorator registers the get_station_data function as an MCP tool with FastMCP.
    @mcp.tool()
  • Supporting utility function that handles the HTTP requests to AEMET's two-step API process, including authentication and data parsing, used by get_station_data.
    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
  • Docstring providing the tool description and input schema: station_id as string (e.g., '8416Y'). FastMCP likely infers schema from signature.
    """Obtain specific weather data for a weather station. Args: station_id: Station identifier (e.g., "8416Y" for Valencia)) """

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