jpl_jd_cal
Convert Julian Day numbers to calendar dates and vice versa for precise astronomical and scientific timekeeping, using the NASA MCP Server's standardized interface.
Instructions
Julian Day number to/from calendar date/time converter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cd | No | Calendar date to convert to Julian date (YYYY-MM-DD or YYYY-MM-DDThh:mm:ss format) | |
| jd | No | Julian date to convert to calendar date |
Implementation Reference
- src/handlers/jpl/jd_cal.ts:13-60 (handler)The jdCalHandler function implements the core logic of the 'jpl_jd_cal' tool. It validates input parameters (jd or cd), transforms them, calls the JPL jd_cal.api endpoint, stores the result as a resource, and returns formatted JSON response.export async function jdCalHandler(args: Record<string, any>) { try { // Base URL for the JD Calendar API const baseUrl = 'https://ssd-api.jpl.nasa.gov/jd_cal.api'; // Validate parameters if (!args.jd && !args.cd) { return { content: [{ type: "text", text: "Error: Either a Julian date (jd) or calendar date (cd) must be provided." }], isError: true }; } // 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; // Add response to resources const resourceUri = `jpl://jd_cal/${args.jd || args.cd}`; addResource(resourceUri, { name: `Julian Date / Calendar Date Conversion: ${args.jd || args.cd}`, 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 Julian Date Calendar API: ${error.message}` }], isError: true }; } }
- src/index.ts:1071-1086 (schema)Defines the input schema and metadata for the 'jpl_jd_cal' tool in the tools/list response, specifying parameters 'jd' and 'cd'.name: "jpl_jd_cal", description: "Julian Day number to/from calendar date/time converter", inputSchema: { type: "object", properties: { jd: { type: "string", description: "Julian date to convert to calendar date" }, cd: { type: "string", description: "Calendar date to convert to Julian date (YYYY-MM-DD or YYYY-MM-DDThh:mm:ss format)" } } } },
- src/index.ts:513-515 (registration)Registers the 'jpl_jd_cal' tool in the tools/manifest response with its ID and description.name: "jpl_jd_cal", id: "jpl/jd_cal", description: "Julian Day number to/from calendar date/time converter"
- src/index.ts:1896-1922 (registration)Dynamic registration and dispatch logic in handleToolCall function that imports and executes the handler for JPL tools, including 'jpl_jd_cal', based on the tool name.} else if (internalToolId.startsWith("jpl/")) { // Extract the JPL API endpoint name const endpoint = internalToolId.split("/")[1]; serverInstance?.sendLoggingMessage({ level: "info", data: `JPL Endpoint: ${endpoint}`, }); try { // Dynamic import for JPL handlers using the original slash format path serverInstance?.sendLoggingMessage({ level: "info", data: `Importing handler module: ./handlers/jpl/${endpoint}.js`, }); const handlerModule = await import(`./handlers/jpl/${endpoint}.js`); // Try to find the handler function in various export formats const handlerFunction = handlerModule.default || handlerModule[`jpl${endpoint.charAt(0).toUpperCase() + endpoint.slice(1)}Handler`] || handlerModule[`${endpoint}Handler`]; if (typeof handlerFunction === 'function') { return await handlerFunction(args); } else { throw new Error(`Handler for ${endpoint} not found in module`); } } catch (error: unknown) {