get_seismic_data
Retrieve recent seismic activity data for Portugal, including mainland, Azores, and Madeira regions, to monitor earthquakes and assess geological events.
Instructions
Obter dados sísmicos recentes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| area | No | Área: 'continent', 'azores', 'madeira', ou 'all' | all |
Implementation Reference
- src/index.ts:346-404 (handler)The core handler function that maps the area parameter to IPMA seismic API endpoints, fetches recent earthquake data, formats the top 10 events with details like time, location, magnitude, depth, and coordinates into a markdown text response, and returns it in MCP format. Handles no-data case and errors.private async getSeismicData(area: string) { try { let areaId: number; switch (area.toLowerCase()) { case "continent": areaId = 1; break; case "azores": areaId = 2; break; case "madeira": areaId = 3; break; default: areaId = 1; // Default to continent } const response = await fetch(`${this.baseUrl}/observation/seismic/${areaId}.json`); const data = await response.json() as ApiResponse<SeismicData>; if (!data.data || data.data.length === 0) { return { content: [ { type: "text", text: "📍 Não há dados sísmicos recentes para a área especificada." } ] }; } let result = `🌍 **Dados Sísmicos - ${area}**\n\n`; result += `🕐 Última atualização: ${data.data[0]?.dataUpdate}\n\n`; // Mostrar apenas os 10 mais recentes const recentData = data.data.slice(0, 10); recentData.forEach((earthquake: SeismicData) => { const eventTime = new Date(earthquake.time).toLocaleString('pt-PT'); result += `📅 **${eventTime}**\n`; result += `📍 Local: ${earthquake.obsRegion || 'N/A'}\n`; result += `📏 Magnitude: ${earthquake.magnitud} ${earthquake.magType}\n`; result += `🌊 Profundidade: ${earthquake.depth} km\n`; result += `🗺️ Coordenadas: ${earthquake.lat}, ${earthquake.lon}\n\n`; }); return { content: [ { type: "text", text: result } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError(ErrorCode.InternalError, `Erro ao obter dados sísmicos: ${errorMessage}`); } }
- src/index.ts:159-172 (registration)Registration of the 'get_seismic_data' tool in the ListTools handler, including its description and input schema defining an optional 'area' parameter.{ name: "get_seismic_data", description: "Obter dados sísmicos recentes", inputSchema: { type: "object", properties: { area: { type: "string", description: "Área: 'continent', 'azores', 'madeira', ou 'all'", default: "all" } } } },
- src/index.ts:35-47 (schema)TypeScript interface defining the structure of individual seismic event data from the IPMA API, used in the handler for type safety.interface SeismicData { degree: string | null; dataUpdate: string; magType: string; obsRegion: string; lon: string; source: string; depth: number; time: string; lat: string; local: string | null; magnitud: string; }
- src/index.ts:213-214 (handler)Dispatcher case in the central CallToolRequestSchema handler that invokes the specific getSeismicData method with the provided or default area argument.case "get_seismic_data": return await this.getSeismicData(toolArgs?.area || "all");