nasa_eonet
Track and analyze natural events like wildfires and volcanoes using NASA's Earth Observatory data. Retrieve event details by category, status, and time range for informed decision-making.
Instructions
Earth Observatory Natural Event Tracker - natural events data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Event category (wildfires, volcanoes, etc.) | |
| days | No | Number of days to look back | |
| limit | No | Maximum number of events to return | |
| source | No | Data source | |
| status | No | Event status (open, closed) |
Implementation Reference
- src/handlers/nasa/eonet.ts:13-110 (handler)The core handler function 'nasaEonetHandler' that executes the nasa_eonet tool. It queries NASA's EONET API for natural events (wildfires, storms, etc.), handles parameters like category, days, status, with fallback broader searches if no results, registers JSON results as MCP resources, and returns success/error messages.export async function nasaEonetHandler(params: EonetParams) { try { const { category, days, source, status, limit } = params; // Build the endpoint path let endpointPath = '/v3/events'; const apiParams: Record<string, any> = {}; // Add query parameters - using more default values to ensure we get results if (days) apiParams.days = days; if (source) apiParams.source = source; if (status) apiParams.status = status; if (limit) apiParams.limit = limit; // If no status is provided, default to "all" to ensure we get some events if (!status) apiParams.status = "all"; // If no days parameter, default to 60 days to ensure we get more events if (!days) apiParams.days = 60; // If a category is specified, use the category-specific endpoint if (category) { endpointPath = `/v3/categories/${category}`; } // Use direct axios call with the EONET-specific base URL const response = await axios.get(`${EONET_API_BASE_URL}${endpointPath}`, { params: apiParams, timeout: 10000 // 10 second timeout }); // If we don't have any events, try again with broader parameters if (!response.data.events || response.data.events.length === 0) { // Reset to the main events endpoint for maximum results endpointPath = '/v3/events'; // Use broader parameters const broadParams = { status: 'all', // Get both open and closed events days: 90, // Look back further limit: limit || 50 // Increase the limit }; const broadResponse = await axios.get(`${EONET_API_BASE_URL}${endpointPath}`, { params: broadParams, timeout: 10000 }); // Register the response as a resource const resourceId = `nasa://eonet/events?days=${broadParams.days}&status=${broadParams.status}`; addResource(resourceId, { name: `EONET Events (${broadParams.days} days, ${broadParams.status} status)`, mimeType: 'application/json', text: JSON.stringify(broadResponse.data, null, 2) }); return { content: [{ type: "text", text: `Used broader search criteria due to no events found with original parameters. Found ${broadResponse.data.events?.length || 0} events.` }], isError: false }; } // Register the response as a resource const resourceParams = []; if (days) resourceParams.push(`days=${days}`); if (category) resourceParams.push(`category=${category}`); if (status) resourceParams.push(`status=${status}`); const resourceId = `nasa://eonet/events${category ? '/categories/' + category : ''}?${resourceParams.join('&')}`; addResource(resourceId, { name: `EONET Events${category ? ' (' + category + ')' : ''}`, mimeType: 'application/json', text: JSON.stringify(response.data, null, 2) }); // Return the original result return { content: [{ type: "text", text: `Found ${response.data.events?.length || 0} EONET events.` }], isError: false }; } catch (error: any) { console.error('Error in EONET handler:', error); return { isError: true, content: [{ type: "text", text: `Error: ${error.message || 'An unexpected error occurred'}` }] }; } }
- src/index.ts:1641-1655 (registration)Registers the MCP request handler for method 'nasa/eonet', validating params matching EonetParams, and delegates to handleToolCall which dynamically imports and executes the nasaEonetHandler from src/handlers/nasa/eonet.tsserver.setRequestHandler( z.object({ method: z.literal("nasa/eonet"), params: z.object({ category: z.string().optional(), days: z.number().optional(), source: z.string().optional(), status: z.string().optional(), limit: z.number().optional() }).optional() }), async (request) => { return await handleToolCall("nasa/eonet", request.params || {}); } );
- src/index.ts:493-496 (registration)Lists 'nasa_eonet' as an available tool in the tools/manifest response, with ID 'nasa/eonet' used for dynamic handler loading.name: "nasa_eonet", id: "nasa/eonet", description: "Earth Observatory Natural Event Tracker" },
- src/index.ts:965-992 (registration)Defines the 'nasa_eonet' tool in tools/list response, including full inputSchema matching the EonetParams zod schema.name: "nasa_eonet", description: "Earth Observatory Natural Event Tracker - natural events data", inputSchema: { type: "object", properties: { category: { type: "string", description: "Event category (wildfires, volcanoes, etc.)" }, days: { type: "number", description: "Number of days to look back" }, source: { type: "string", description: "Data source" }, status: { type: "string", description: "Event status (open, closed)" }, limit: { type: "number", description: "Maximum number of events to return" } } } },
- src/handlers/setup.ts:122-138 (schema)Zod schema definition for EonetParams used by the nasaEonetHandler and exported for use in MCP tool registrations.const EonetSchema = z.object({ category: z.string().optional(), days: z.number().int().positive().optional(), source: z.string().optional(), status: z.enum(['open', 'closed', 'all']).optional(), limit: z.number().int().positive().optional() }); // Convert the Express handlers to MCP handlers export const donkiParamsSchema = DonkiSchema; export type DonkiParams = z.infer<typeof donkiParamsSchema>; export const marsRoverParamsSchema = MarsRoverSchema; export type MarsRoverParams = z.infer<typeof marsRoverParamsSchema>; export const eonetParamsSchema = EonetSchema; export type EonetParams = z.infer<typeof eonetParamsSchema>;