jpl_nhats
Query NASA's NHATS database to find accessible Near-Earth Objects for potential missions using delta-V, duration, and launch window parameters.
Instructions
Human-accessible NEOs (Near-Earth Objects) data
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dv | No | Minimum total delta-V (km/s). Values: 4-12, default: 12 | |
| dur | No | Minimum total mission duration (days). Values: 60-450, default: 450 | |
| stay | No | Minimum stay time (days). Values: 8, 16, 24, 32, default: 8 | |
| launch | No | Launch window (year range). Values: 2020-2025, 2025-2030, 2030-2035, 2035-2040, 2040-2045, 2020-2045, default: 2020-2045 | |
| h | No | Object's maximum absolute magnitude (mag). Values: 16-30 | |
| occ | No | Object's maximum orbit condition code. Values: 0-8 | |
| des | No | Object designation (e.g., '2000 SG344' or '433') | |
| spk | No | Object SPK-ID (e.g., '2000433') | |
| plot | No | Include base-64 encoded plot image |
Implementation Reference
- src/handlers/jpl/nhats.ts:14-75 (handler)The `nhatsHandler` function implements the core logic of the `jpl_nhats` tool. It queries the JPL NHATS API at `https://ssd-api.jpl.nasa.gov/nhats.api`, transforms input parameters, fetches data using axios, creates resource URIs like `jpl://nhats/object/{des}`, stores the JSON response as a resource, and returns formatted content or error.
export async function nhatsHandler(args: Record<string, any>) { try { // Base URL for the NHATS API const baseUrl = 'https://ssd-api.jpl.nasa.gov/nhats.api'; // Validate parameters if needed // Parameters are fairly flexible in this API, so minimal validation is needed // Transform parameter names from underscore to hyphenated format const transformedParams = transformParamsToHyphenated(args); // Make the API request const response = await axios.get(baseUrl, { params: transformedParams }); const data = response.data; // Create a resource URI that represents this query let resourceUri: string; if (args.des) { // Object mode - query for a specific object resourceUri = `jpl://nhats/object/${args.des}`; } else if (args.spk) { // Object mode - query for a specific object by SPK-ID resourceUri = `jpl://nhats/object/${args.spk}`; } else { // Summary mode - query for a list of objects with constraints const constraints = Object.entries(args) .map(([key, value]) => `${key}=${value}`) .join('&'); resourceUri = `jpl://nhats/summary${constraints ? '?' + constraints : ''}`; } // Add response to resources addResource(resourceUri, { name: args.des || args.spk ? `NHATS data for object: ${args.des || args.spk}` : 'NHATS summary data', mimeType: "application/json", text: JSON.stringify(data, null, 2) }); // Format the response return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error accessing JPL NHATS API: ${error.message}` }], isError: true }; } } // Export default for dynamic imports export default nhatsHandler;