get_seismic_data
Retrieve seismic activity data for Portugal, including earthquake information from the Azores, Continental Portugal, and Madeira regions over the past 30 days.
Instructions
Get seismic activity data for Portugal (Informação sismicidade, últimos 30 dias).
Args:
region: Region to filter ('all', 'continente', 'açores', 'madeira').
Default is 'all' for all regions.
Note: This endpoint returns the last 30 days of seismic information for
Azores Archipelago, Continental Portugal, and Madeira Archipelago.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region | No | all |
Implementation Reference
- weather.py:159-210 (handler)The main handler function for the 'get_seismic_data' tool, registered via @mcp.tool() decorator. Fetches seismic data from IPMA API endpoints for Portugal regions (all, continente, açores, madeira), handles multiple possible URLs, formats and filters the response.@mcp.tool() async def get_seismic_data(region: str = "all") -> str: """Get seismic activity data for Portugal (Informação sismicidade, últimos 30 dias). Args: region: Region to filter ('all', 'continente', 'açores', 'madeira'). Default is 'all' for all regions. Note: This endpoint returns the last 30 days of seismic information for Azores Archipelago, Continental Portugal, and Madeira Archipelago. """ # Based on API exploration, trying common patterns for seismic data # The exact endpoint might vary, trying multiple possible URLs possible_urls = [ f"{IPMA_API_BASE}/observation/seismic/latest30days.json", f"{IPMA_API_BASE}/seismic-data.json", f"{IPMA_API_BASE}/observation/seismology/events.json" ] seismic_data = None for url in possible_urls: seismic_data = await make_ipma_request(url) if seismic_data: break if not seismic_data: return """Seismic data endpoint is currently unavailable. The IPMA API provides seismic information for the last 30 days covering: - Continental Portugal - Azores Archipelago - Madeira Archipelago Please try again later or check the IPMA website directly.""" # Process and format the seismic data based on actual structure result = f"Seismic Activity (Last 30 Days)\n" result += f"Region Filter: {region}\n\n" # Add data processing logic based on actual API response structure if isinstance(seismic_data, list): filtered_events = seismic_data if region.lower() != "all": # Filter by region if the data structure supports it pass result += f"Total Events: {len(filtered_events)}\n\n" for event in filtered_events[:20]: # Show first 20 events result += f"{event}\n---\n" else: result += str(seismic_data) return result