Skip to main content
Glama

nasa_exoplanet

Query and retrieve detailed data about exoplanets from NASA's Exoplanet Archive. Specify tables, columns, filters, and limits to extract precise astronomical information.

Instructions

NASA Exoplanet Archive - data about planets beyond our solar system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of results
orderNoOrdering of results
selectNoColumns to return
tableYesDatabase table to query
whereNoFilter conditions

Implementation Reference

  • The nasaExoplanetHandler function implements the core logic of the 'nasa_exoplanet' tool. It validates parameters, constructs the API request to NASA's Exoplanet Archive, fetches data using axios, registers the full response as a resource, and returns a formatted summary of the results.
    export async function nasaExoplanetHandler(params: ExoplanetParams) { try { const { table, select, where, order, format, limit } = params; // Construct the API parameters directly - nstedAPI has different params than TAP/sync const apiParams: Record<string, any> = { table: table, format: format }; // Add optional parameters if provided if (select) { apiParams.select = select; } if (where) { apiParams.where = where; } if (order) { apiParams.order = order; } if (limit) { apiParams.top = limit; // Use 'top' instead of 'limit' for this API } // Make the request to the Exoplanet Archive const response = await axios.get(EXOPLANET_API_URL, { params: apiParams }); // Create a resource ID based on the query parameters const resourceId = `nasa://exoplanet/data?table=${table}${where ? `&where=${encodeURIComponent(where)}` : ''}${limit ? `&limit=${limit}` : ''}`; // Register the response as a resource addResource(resourceId, { name: `Exoplanet data from ${table}${where ? ` with filter` : ''}`, mimeType: format === 'json' ? 'application/json' : 'text/plain', text: format === 'json' ? JSON.stringify(response.data, null, 2) : response.data }); // Format response based on the data type if (Array.isArray(response.data) && response.data.length > 0) { // If we got an array of results const count = response.data.length; return { content: [ { type: "text", text: `Found ${count} exoplanet records from the ${table} table.` }, { type: "text", text: JSON.stringify(response.data.slice(0, 10), null, 2) + (count > 10 ? `\n... and ${count - 10} more records` : '') } ], isError: false }; } else { // If we got a different format or empty results return { content: [ { type: "text", text: `Exoplanet query complete. Results from ${table} table.` }, { type: "text", text: typeof response.data === 'string' ? response.data : JSON.stringify(response.data, null, 2) } ], isError: false }; } } catch (error: any) { console.error('Error in Exoplanet handler:', error); return { isError: true, content: [{ type: "text", text: `Error accessing NASA Exoplanet Archive: ${error.message || 'Unknown error'}` }] }; } }
  • Zod schema (exoplanetParamsSchema) and TypeScript type (ExoplanetParams) for input validation of the nasa_exoplanet tool parameters.
    export const exoplanetParamsSchema = z.object({ table: z.string(), select: z.string().optional(), where: z.string().optional(), order: z.string().optional(), format: z.enum(['json', 'csv', 'ipac', 'xml']).optional().default('json'), limit: z.number().int().min(1).max(1000).optional() }); // Define the request parameter type based on the schema export type ExoplanetParams = z.infer<typeof exoplanetParamsSchema>;
  • src/index.ts:1609-1623 (registration)
    Registers the MCP server request handler for the 'nasa/exoplanet' method, which validates input parameters and delegates execution to the shared handleToolCall function that dynamically imports and invokes the handler from src/handlers/nasa/exoplanet.ts.
    server.setRequestHandler( z.object({ method: z.literal("nasa/exoplanet"), params: z.object({ table: z.string().optional(), select: z.string().optional(), where: z.string().optional(), order: z.string().optional(), limit: z.number().optional() }).optional() }), async (request) => { return await handleToolCall("nasa/exoplanet", request.params || {}); } );
  • src/index.ts:478-480 (registration)
    Tool manifest entry declaring the 'nasa_exoplanet' tool in the MCP tools/manifest response.
    name: "nasa_exoplanet", id: "nasa/exoplanet", description: "Access NASA's Exoplanet Archive data"
  • Detailed input schema for the 'nasa_exoplanet' tool provided in the MCP tools/list response.
    name: "nasa_exoplanet", description: "NASA Exoplanet Archive - data about planets beyond our solar system", inputSchema: { type: "object", properties: { table: { type: "string", description: "Database table to query" }, select: { type: "string", description: "Columns to return" }, where: { type: "string", description: "Filter conditions" }, order: { type: "string", description: "Ordering of results" }, limit: { type: "number", description: "Maximum number of results" } }, required: ["table"] } },

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