jpl_periodic_orbits
Query NASA's JPL database for three-body periodic orbits by specifying system, family, and orbital parameters to analyze celestial mechanics.
Instructions
JPL Three-Body Periodic Orbits Database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sys | Yes | Three-body system (e.g., earth-moon, sun-earth) | |
| family | Yes | Orbit family name (e.g., halo, dro, lyapunov) | |
| libr | No | Libration point (1-5, required for some families) | |
| branch | No | Branch within family (N/S, E/W, etc., required for some families) | |
| periodmin | No | Minimum period | |
| periodmax | No | Maximum period | |
| periodunits | No | Units for period (s, h, d, TU) | |
| jacobimin | No | Minimum Jacobi constant | |
| jacobimax | No | Maximum Jacobi constant | |
| stabmin | No | Minimum stability index | |
| stabmax | No | Maximum stability index |
Implementation Reference
- Main handler function that validates inputs, transforms parameters, queries JPL SSD Periodic Orbits API, stores result as resource, and returns MCP-formatted response.
export async function periodicOrbitsHandler(args: PeriodicOrbitParams) { try { // Validate required parameters if (!args.sys || !args.family) { throw new Error('Missing required parameters: sys and family must be provided.'); } // Base URL for the Periodic Orbits API const baseUrl = 'https://ssd-api.jpl.nasa.gov/periodic_orbits.api'; // Transform parameter names from underscore to hyphenated format const transformedParams = transformParamsToHyphenated(args); // Make the API request using GET with parameters const response = await axios.get(baseUrl, { params: transformedParams }); const data = response.data; // Create a resource URI // Example: jpl://periodic-orbits?sys=earth-moon&family=halo&libr=1&branch=N let resourceUri = `jpl://periodic-orbits?sys=${encodeURIComponent(args.sys)}&family=${encodeURIComponent(args.family)}`; let resourceName = `Periodic Orbits: ${args.sys} / ${args.family}`; if (args.libr) { resourceUri += `&libr=${args.libr}`; resourceName += ` / L${args.libr}`; } if (args.branch) { resourceUri += `&branch=${encodeURIComponent(args.branch)}`; resourceName += ` / Branch ${args.branch}`; } // Potentially add filter params to URI/Name if needed for uniqueness // Add response to resources addResource(resourceUri, { name: resourceName, mimeType: "application/json", text: JSON.stringify(data, null, 2) }); // Format the response for MCP return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error: any) { let errorMessage = `Error accessing JPL Periodic Orbits API: ${error.message}`; if (error.response) { // Include more detail from the API response if available errorMessage += `\nStatus: ${error.response.status}\nData: ${JSON.stringify(error.response.data)}`; } return { content: [{ type: "text", text: errorMessage }], isError: true }; } } - TypeScript interface defining the input parameters for the periodicOrbitsHandler, matching the JPL API parameters.
interface PeriodicOrbitParams { sys: string; family: string; libr?: number; branch?: string; periodmin?: number; periodmax?: number; periodunits?: string; jacobimin?: number; jacobimax?: number; stabmin?: number; stabmax?: number; }