get_station_list
Retrieve a list of weather stations from Spain's AEMET API, optionally filtered by station names or provinces for targeted weather data access.
Instructions
Get a list of all available weather stations or filter by one or more search terms, including approximate matches.
Args: search_terms: Optional terms (space or comma separated) to filter stations by name or province.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search_terms | No |
Implementation Reference
- src/aemet_mcp/server.py:177-214 (handler)The @mcp.tool()-decorated handler function that fetches the complete list of AEMET weather stations and filters them by normalized search terms matching station name or province.@mcp.tool() async def get_station_list(search_terms: str = ""): """ Get a list of all available weather stations or filter by one or more search terms, including approximate matches. Args: search_terms: Optional terms (space or comma separated) to filter stations by name or province. """ url = f"{AEMET_API_BASE}/valores/climatologicos/inventarioestaciones/todasestaciones" stations = await make_aemet_request(url) if not stations: return None if not search_terms: logger.info("No search terms provided") return stations terms = search_terms.replace(',', ' ').split() search_terms_normalized = [normalize(term) for term in terms] filtered = [] numCoincidencias = 0 for station in stations: if not isinstance(station, dict): continue nombre = normalize(station.get("nombre", "")) provincia = normalize(station.get("provincia", "")) for term in search_terms_normalized: if term in nombre or term in provincia: filtered.append(station) numCoincidencias += 1 break logger.info(f"Filtered stations: {numCoincidencias}") return filtered
- src/aemet_mcp/server.py:177-177 (registration)Registers the get_station_list tool in the FastMCP server using the @mcp.tool() decorator.@mcp.tool()