nasa_firms
Access wildfire data by providing latitude, longitude, and days of interest. Retrieve critical fire information using NASA's resource management system for monitoring and analysis.
Instructions
NASA Fire Information for Resource Management System - fire data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of days of data to retrieve | |
| latitude | Yes | Latitude coordinate | |
| longitude | Yes | Longitude coordinate |
Implementation Reference
- src/handlers/nasa/firms.ts:22-124 (handler)The nasaFirmsHandler function executes the tool logic: validates params, calls FIRMS API with axios, parses CSV fire hotspot data, adds resource, returns MCP content with summary and JSON data.export async function nasaFirmsHandler(params: FirmsParams) { try { const { latitude, longitude, radius, days, source } = params; // Validate required parameters if (!process.env.NASA_API_KEY) { return { isError: true, content: [{ type: "text", text: "Error: NASA API key is required for FIRMS requests" }] }; } // Get the NASA API key from environment variables const apiKey = process.env.NASA_API_KEY; // Construct request URL const url = FIRMS_API_BASE_URL; // Send request to FIRMS API const response = await axios.get(url, { params: { lat: latitude, lon: longitude, radius: radius, days: days, source: source, api_key: apiKey } }); // Parse the CSV response into a structured format const csvData = response.data; const rows = csvData.split('\n'); if (rows.length < 2) { return { results: [] }; } const headers = rows[0].split(','); const results = rows.slice(1) .filter((row: string) => row.trim() !== '') .map((row: string) => { const values = row.split(','); const entry: Record<string, string | number> = {}; headers.forEach((header: string, index: number) => { const value = values[index] ? values[index].trim() : ''; // Try to convert numeric values const numValue = Number(value); entry[header] = !isNaN(numValue) && value !== '' ? numValue : value; }); return entry; }); // Register the response as a resource const resourceId = `nasa://firms/data?lat=${latitude}&lon=${longitude}&days=${days}&source=${source}`; const resourceData = { metadata: { latitude, longitude, radius, days, source }, results }; addResource(resourceId, { name: `Fire Data near (${latitude}, ${longitude}) for the past ${days} day(s)`, mimeType: 'application/json', text: JSON.stringify(resourceData, null, 2) }); // Return data in MCP format return { content: [ { type: "text", text: `Found ${results.length} fire hotspots near (${latitude}, ${longitude}) in the past ${days} day(s)` }, { type: "text", text: JSON.stringify(results, null, 2) } ], isError: false }; } catch (error: any) { console.error('Error in FIRMS handler:', error); return { isError: true, content: [{ type: "text", text: `Error: ${error.message || 'An unexpected error occurred'}` }] }; } }
- src/handlers/nasa/firms.ts:8-14 (schema)Zod input validation schema for nasa_firms tool parameters.export const firmsParamsSchema = z.object({ latitude: z.number(), longitude: z.number(), radius: z.number().optional().default(1.0), days: z.number().int().min(1).max(10).optional().default(1), source: z.enum(['VIIRS_SNPP_NRT', 'MODIS_NRT', 'VIIRS_NOAA20_NRT']).optional().default('VIIRS_SNPP_NRT') });
- src/index.ts:1578-1589 (registration)Registers the MCP server request handler for method 'nasa/firms', which forwards to handleToolCall loading the dynamic handler.z.object({ method: z.literal("nasa/firms"), params: z.object({ days: z.number().optional(), latitude: z.number().optional(), longitude: z.number().optional() }).optional() }), async (request) => { return await handleToolCall("nasa/firms", request.params || {}); } );
- src/index.ts:831-851 (schema)Defines the input schema for 'nasa_firms' tool in the tools/list MCP response.name: "nasa_firms", description: "NASA Fire Information for Resource Management System - fire data", inputSchema: { type: "object", properties: { latitude: { type: "number", description: "Latitude coordinate" }, longitude: { type: "number", description: "Longitude coordinate" }, days: { type: "number", description: "Number of days of data to retrieve" } }, required: ["latitude", "longitude"] } },
- src/index.ts:468-472 (registration)Lists 'nasa_firms' tool in the tools/manifest MCP response.name: "nasa_firms", id: "nasa/firms", description: "Fire Information for Resource Management System" }, {