Skip to main content
Glama

nasa_exoplanet

Query NASA's Exoplanet Archive database to retrieve data about planets beyond our solar system using customizable filters and parameters.

Instructions

NASA Exoplanet Archive - data about planets beyond our solar system

Input Schema

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

Implementation Reference

  • Main handler function that queries the NASA Exoplanet Archive API, processes the response, adds a resource, and returns formatted content.
    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 for validating input parameters to the nasa_exoplanet tool.
    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() });
  • src/index.ts:1609-1623 (registration)
    Registers the MCP request handler for the 'nasa/exoplanet' method, which delegates to the dynamic handler import.
    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 || {}); } );
  • Input schema definition for the nasa_exoplanet tool in the 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"] }
  • src/index.ts:478-481 (registration)
    Tool listing in the tools/manifest response.
    name: "nasa_exoplanet", id: "nasa/exoplanet", description: "Access NASA's Exoplanet Archive data" },

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