nasa_neo
Access detailed information about asteroids and Near Earth Objects using start and end dates. Identify specific asteroids by their ID to track and analyze space data.
Instructions
Near Earth Object Web Service - information about asteroids
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asteroid_id | No | ID of a specific asteroid | |
| end_date | Yes | End date for asteroid search (YYYY-MM-DD) | |
| start_date | Yes | Start date for asteroid search (YYYY-MM-DD) |
Implementation Reference
- src/handlers/nasa/neo.ts:18-95 (handler)Main execution logic for the nasa_neo tool. Handles both specific asteroid lookups by ID and date-range feeds from NASA's NEO API, with error handling and resource storage.export async function nasaNeoHandler(params: NeoParams) { try { // If we're looking for a specific asteroid by ID if (params.asteroid_id) { const endpoint = `/neo/rest/v1/neo/${params.asteroid_id}`; const result = await nasaApiRequest(endpoint, {}); // Store the result as a resource addResource(`nasa://neo/${params.asteroid_id}`, { name: `Asteroid: ${result.name}`, mimeType: 'application/json', text: JSON.stringify(result, null, 2) }); // Return formatted result return { content: [ { type: "text", text: formatSingleAsteroidText(result) } ], isError: false }; } // Default to today if no dates specified let startDate = params.start_date; let endDate = params.end_date; if (!startDate) { const today = new Date(); startDate = today.toISOString().split('T')[0]; } // If no end_date, use start_date (same day) if (!endDate) { endDate = startDate; } // API limits feed to 7 days const maxDays = 7; const start = new Date(startDate); const end = new Date(endDate); const daysDiff = Math.floor((end.getTime() - start.getTime()) / (1000 * 60 * 60 * 24)); if (daysDiff > maxDays) { return { content: [ { type: "text", text: `Error: Date range too large. NEO feed is limited to ${maxDays} days.` } ], isError: true }; } // Call the NASA NEO API const endpoint = `/neo/rest/v1/feed?start_date=${startDate}&end_date=${endDate}`; const result = await nasaApiRequest(endpoint, {}); // Process and format the results return processNeoFeedResults(result, startDate, endDate); } catch (error: any) { console.error('Error in NEO handler:', error); return { content: [ { type: "text", text: `Error retrieving NEO data: ${error.message}` } ], isError: true }; } }
- src/handlers/nasa/neo.ts:6-10 (schema)Zod input validation schema for NEO parameters: optional start_date, end_date, and asteroid_id.export const neoParamsSchema = z.object({ start_date: z.string().optional(), end_date: z.string().optional(), asteroid_id: z.string().optional() });
- src/index.ts:1497-1509 (registration)MCP server request handler registration for the 'nasa/neo' method, which routes to the nasaNeoHandler via dynamic import in handleToolCall.server.setRequestHandler( z.object({ method: z.literal("nasa/neo"), params: z.object({ start_date: z.string().optional(), end_date: z.string().optional(), asteroid_id: z.string().optional() }).optional() }), async (request) => { return await handleToolCall("nasa/neo", request.params || {}); } );
- src/index.ts:728-748 (schema)JSON schema for 'nasa_neo' tool exposed in tools/list MCP endpoint.name: "nasa_neo", description: "Near Earth Object Web Service - information about asteroids", inputSchema: { type: "object", properties: { start_date: { type: "string", description: "Start date for asteroid search (YYYY-MM-DD)" }, end_date: { type: "string", description: "End date for asteroid search (YYYY-MM-DD)" }, asteroid_id: { type: "string", description: "ID of a specific asteroid" } }, required: ["start_date", "end_date"] } },
- src/index.ts:448-451 (registration)Tool 'nasa_neo' listed in tools/manifest response with id 'nasa/neo'.name: "nasa_neo", id: "nasa/neo", description: "Information about asteroids and near-Earth objects" },