get_recent_earthquakes
Retrieve seismic events in Switzerland from the Swiss Seismological Service. Filter by date range, magnitude, and event type to access earthquake data.
Instructions
Get recent seismic events in and around Switzerland from the Swiss Seismological Service (SED) at ETH Zürich. Returns earthquakes and optionally quarry blasts, sorted by most recent first.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of past days to search (default: 30, max: 365) | |
| min_magnitude | No | Minimum magnitude filter (default: 0.5) | |
| limit | No | Maximum number of results to return (default: 20) | |
| include_blasts | No | Include quarry blasts in results (default: false — earthquakes only) |
Implementation Reference
- src/modules/earthquakes.ts:210-270 (handler)The handler function that implements the logic for get_recent_earthquakes, fetching and processing earthquake data from the SED service.
async function handleGetRecentEarthquakes( args: Record<string, string | number | boolean> ): Promise<string> { const days = Math.min(Number(args.days ?? 30), 365); const minMag = Number(args.min_magnitude ?? 0.5); const limit = Number(args.limit ?? 20); const includeBlasts = args.include_blasts === true || args.include_blasts === "true"; const url = buildUrl(BASE, { starttime: startTimeISO(days), minmagnitude: minMag, limit: limit, format: "text", orderby: "time", }); const raw = await fetchFdsnText(url); if (!raw) { return JSON.stringify({ count: 0, events: [], source: "Swiss Seismological Service (SED), ETH Zürich", note: "No events found for the given criteria.", }); } let events = parseFdsnText(raw); // Filter out quarry blasts unless explicitly requested if (!includeBlasts) { events = events.filter((e) => e.event_type.toLowerCase() !== "quarry blast"); } const result = JSON.stringify({ count: events.length, days_searched: days, min_magnitude: minMag, include_blasts: includeBlasts, source: "Swiss Seismological Service (SED), ETH Zürich", api: "FDSN Event Web Service — http://arclink.ethz.ch/fdsnws/event/1/", events, }); if (result.length > 50000) { // Trim to stay under 50K const trimmed = events.slice(0, Math.max(1, Math.floor(events.length * 0.8))); return JSON.stringify({ count: trimmed.length, truncated: true, days_searched: days, min_magnitude: minMag, include_blasts: includeBlasts, source: "Swiss Seismological Service (SED), ETH Zürich", api: "FDSN Event Web Service — http://arclink.ethz.ch/fdsnws/event/1/", events: trimmed, }); } return result; } - src/modules/earthquakes.ts:47-73 (schema)The schema definition for get_recent_earthquakes, defining its name, description, and input parameters.
{ name: "get_recent_earthquakes", description: "Get recent seismic events in and around Switzerland from the Swiss Seismological Service (SED) at ETH Zürich. " + "Returns earthquakes and optionally quarry blasts, sorted by most recent first.", inputSchema: { type: "object", properties: { days: { type: "number", description: "Number of past days to search (default: 30, max: 365)", }, min_magnitude: { type: "number", description: "Minimum magnitude filter (default: 0.5)", }, limit: { type: "number", description: "Maximum number of results to return (default: 20)", }, include_blasts: { type: "boolean", description: "Include quarry blasts in results (default: false — earthquakes only)", }, }, }, }, - src/modules/earthquakes.ts:379-380 (registration)The registration/dispatching logic that links the tool name "get_recent_earthquakes" to the handler function.
case "get_recent_earthquakes": return handleGetRecentEarthquakes(args);