get_beach_data_uv
Retrieve beach forecasts or UV index data from Spain's AEMET API. Query by beach name, ID, or list by province, specifying forecast days (0 to 4).
Instructions
Query information on beaches or UV index from AEMET.
Args: name_or_code: Partial or full name of the beach, or its BEACH_ID. Also accepts 'list' or 'list:'. dias_frc: Number of forecast days, starting form 0, which means 0 days from today, to 4, which means 4 days from today. query_type: 'beach' for forecast, 'UV_index' for UV index, must be in english.
Returns: Requested information or list of matches.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dias_frc | Yes | ||
| nombre_o_codigo | Yes | ||
| tipo_consulta | No | playa |
Implementation Reference
- src/aemet_mcp/server.py:308-344 (handler)The main handler function for the 'get_beach_data_uv' tool. It handles beach name or code lookup, lists beaches if requested, constructs the AEMET API URL for beach forecasts or UV index, and fetches the data using make_aemet_request.@mcp.tool() async def get_beach_data_uv(nombre_o_codigo: str, dias_frc: int, tipo_consulta: str = "playa"): """Query information on beaches or UV index from AEMET. Args: name_or_code: Partial or full name of the beach, or its BEACH_ID. Also accepts 'list' or 'list:<province>'. dias_frc: Number of forecast days, starting form 0, which means 0 days from today, to 4, which means 4 days from today. query_type: 'beach' for forecast, 'UV_index' for UV index, must be in english. Returns: Requested information or list of matches. """ comando = normalize(nombre_o_codigo.strip()) if comando == "list": return sorted(CODIGOS_PLAYAS, key=lambda x: normalize(x["NOMBRE_PLAYA"])) if comando.startswith("list:"): provincia = normalize(comando.split("list:", 1)[1].strip()) return PROVINCIA_A_PLAYAS.get(provincia, []) if nombre_o_codigo.isdigit(): codigo = nombre_o_codigo else: coincidencias = [ p for p in CODIGOS_PLAYAS if comando in normalize(p["NOMBRE_PLAYA"]) or comando in normalize(p["NOMBRE_PROVINCIA"]) ] if len(coincidencias) == 1: codigo = str(coincidencias[0]["ID_PLAYA"]) elif coincidencias: return coincidencias else: return {"error": f"No matches found for '{nombre_o_codigo}'."} url = f"{AEMET_API_BASE}/prediccion/especifica/{'playa' if tipo_consulta == 'beach' else 'uvi'}/{codigo if tipo_consulta == 'beach' else dias_frc}" return await make_aemet_request(url)