Skip to main content
Glama

jpl_cad

Query NASA's JPL database to identify asteroid and comet close approaches to planets within specified date ranges and distance parameters for planetary defense monitoring.

Instructions

Asteroid and comet close approaches to the planets in the past and future

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dist_maxNoMaximum approach distance (e.g., 0.05, 10LD). Default: 0.05 au
dist_minNoMinimum approach distance. Default: none
date_minNoStart date for search (YYYY-MM-DD). Default: now
date_maxNoEnd date for search (YYYY-MM-DD). Default: +60 days
bodyNoBody to find close approaches to (e.g., Earth, Mars, ALL). Default: Earth
sortNoSort field: date, dist, dist-min, v-inf, v-rel, h, object. Default: date
desNoObject designation (e.g., '2000 SG344' or '433')
spkNoObject SPK-ID (e.g., '2000433')
neoNoLimit to NEOs. Default: true
fullnameNoInclude full object name in result. Default: false

Implementation Reference

  • The main handler function cadHandler that implements the JPL Close Approach Data (CAD) API call, parameter transformation, resource creation, and error handling.
    export async function cadHandler(args: Record<string, any>) {
      try {
        // Base URL for the CAD API
        const baseUrl = 'https://ssd-api.jpl.nasa.gov/cad.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;
        let resourceName: string;
        
        if (args.des) {
          // Query for a specific object
          resourceUri = `jpl://cad/object/${args.des}`;
          resourceName = `Close approaches for object ${args.des}`;
        } else if (args.spk) {
          // Query for a specific object by SPK-ID
          resourceUri = `jpl://cad/object/${args.spk}`;
          resourceName = `Close approaches for object ${args.spk}`;
        } else {
          // Query for close approaches with constraints
          const constraints = Object.entries(args)
            .map(([key, value]) => `${key}=${value}`)
            .join('&');
          
          resourceUri = `jpl://cad/list${constraints ? '?' + constraints : ''}`;
          
          // Create a readable name based on date range and body
          const dateMin = args['date_min'] || 'now';
          const dateMax = args['date_max'] || '+60';
          const body = args.body || 'Earth';
          
          resourceName = `Close approaches to ${body} from ${dateMin} to ${dateMax}`;
        }
        
        // Add response to resources
        addResource(resourceUri, {
          name: resourceName,
          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 SB Close Approach API: ${error.message}`
          }],
          isError: true
        };
      }
    }
  • Input schema and parameter descriptions for the jpl_cad tool as defined in the tools/list handler response.
    {
      name: "jpl_cad",
      description: "Asteroid and comet close approaches to the planets in the past and future",
      inputSchema: {
        type: "object",
        properties: {
          "dist_max": {
            type: "string",
            description: "Maximum approach distance (e.g., 0.05, 10LD). Default: 0.05 au"
          },
          "dist_min": {
            type: "string",
            description: "Minimum approach distance. Default: none"
          },
          "date_min": {
            type: "string",
            description: "Start date for search (YYYY-MM-DD). Default: now"
          },
          "date_max": {
            type: "string",
            description: "End date for search (YYYY-MM-DD). Default: +60 days"
          },
          "body": {
            type: "string",
            description: "Body to find close approaches to (e.g., Earth, Mars, ALL). Default: Earth"
          },
          "sort": {
            type: "string",
            description: "Sort field: date, dist, dist-min, v-inf, v-rel, h, object. Default: date"
          },
          "des": {
            type: "string",
            description: "Object designation (e.g., '2000 SG344' or '433')"
          },
          "spk": {
            type: "string",
            description: "Object SPK-ID (e.g., '2000433')"
          },
          "neo": {
            type: "boolean",
            description: "Limit to NEOs. Default: true"
          },
          "fullname": {
            type: "boolean",
            description: "Include full object name in result. Default: false"
          }
        }
      }
    },
  • src/index.ts:522-526 (registration)
    Tool registration entry for jpl_cad in the tools/manifest response.
    {
      name: "jpl_cad",
      id: "jpl/cad",
      description: "Asteroid and comet close approaches to the planets in the past and future"
    },
  • src/index.ts:1896-1932 (registration)
    Dynamic dispatch logic in handleToolCall that imports and executes the JPL cad handler for tool name 'jpl_cad' (internal 'jpl/cad').
    } 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) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [{
            type: "text",
            text: `Error executing JPL tool '${toolName}': ${errorMessage}`
          }],
          isError: true
        };
      }
    }
  • src/index.ts:2126-2132 (registration)
    Global MCP tool registration for mcp__jplcad that routes to the jpl/cad handler.
    registerGlobalTool('mcp__jplcad', async (args: Record<string, any>) => {
      serverInstance?.sendLoggingMessage({
        level: "info",
        data: `MCP JPL CAD called with args: ${JSON.stringify(args)}`,
      });
      return await handleToolCall('jpl/cad', args);
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but reveals nothing about rate limits, authentication requirements, data freshness, pagination, error conditions, or response format. For a tool with 10 parameters and no output schema, this is a significant transparency gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for the tool's complexity and gets straight to the point with zero waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 10 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns, how results are structured, or provide any context about data sources or limitations. The description alone leaves too many unanswered questions for effective tool use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter information beyond what's already in the schema (which has 100% coverage). It doesn't explain relationships between parameters, provide examples of valid combinations, or clarify parameter interactions. With complete schema documentation, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: finding asteroid and comet close approaches to planets in past and future. It specifies the resource (asteroids/comets) and action (finding close approaches), but doesn't distinguish it from sibling tools like jpl_sentry or nasa_neo which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like jpl_sentry (impact risk assessment), jpl_scout (NEO detection), and nasa_neo (NEO data), there's clear potential overlap, but the description offers no comparison or context for choosing this specific tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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