Skip to main content
Glama

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
NameRequiredDescriptionDefault
asteroid_idNoID of a specific asteroid
end_dateYesEnd date for asteroid search (YYYY-MM-DD)
start_dateYesStart date for asteroid search (YYYY-MM-DD)

Implementation Reference

  • 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 }; } }
  • 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 || {}); } );
  • 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" },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ProgramComputer/NASA-MCP-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server