Skip to main content
Glama

nasa_donki

Access detailed space weather event data, including notifications and insights, by specifying event type and date range. Ideal for monitoring and analyzing cosmic phenomena. Powered by NASA's MCP Server.

Instructions

Space Weather Database Of Notifications, Knowledge, Information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endDateNoEnd date (YYYY-MM-DD)
startDateNoStart date (YYYY-MM-DD)
typeYesType of space weather event

Implementation Reference

  • The core handler function `nasaDonkiHandler` that implements the logic for the `nasa_donki` tool. It maps event types to DONKI API endpoints, fetches data using `nasaApiRequest`, adds a resource, and returns formatted content.
    export async function nasaDonkiHandler(params: DonkiParams) { try { const { type, startDate, endDate } = params; // Map the type to the appropriate endpoint const typeEndpoints: Record<string, string> = { cme: '/DONKI/CME', cmea: '/DONKI/CMEAnalysis', gst: '/DONKI/GST', ips: '/DONKI/IPS', flr: '/DONKI/FLR', sep: '/DONKI/SEP', mpc: '/DONKI/MPC', rbe: '/DONKI/RBE', hss: '/DONKI/HSS', wsa: '/DONKI/WSAEnlilSimulations', notifications: '/DONKI/notifications' }; const endpoint = typeEndpoints[type.toLowerCase()]; // Validate that the endpoint exists for the given type if (!endpoint) { return { isError: true, content: [{ type: "text", text: `Error: Invalid DONKI type "${type}". Valid types are: ${Object.keys(typeEndpoints).join(', ')}` }] }; } const queryParams: Record<string, any> = {}; // Add date parameters if provided if (startDate) queryParams.startDate = startDate; if (endDate) queryParams.endDate = endDate; // Call the NASA DONKI API const result = await nasaApiRequest(endpoint, queryParams); // Create a resource ID and register the resource const dateParams = []; if (startDate) dateParams.push(`start=${startDate}`); if (endDate) dateParams.push(`end=${endDate}`); const resourceId = `nasa://donki/${type}${dateParams.length > 0 ? '?' + dateParams.join('&') : ''}`; addResource(resourceId, { name: `DONKI ${type.toUpperCase()} Space Weather Data${startDate ? ` from ${startDate}` : ''}${endDate ? ` to ${endDate}` : ''}`, mimeType: 'application/json', text: JSON.stringify(result, null, 2) }); // Return the confirmation message and the actual data return { content: [ { type: "text", text: `Retrieved DONKI ${type.toUpperCase()} space weather data${startDate ? ` from ${startDate}` : ''}${endDate ? ` to ${endDate}` : ''}.` }, { type: "text", text: JSON.stringify(result, null, 2) } ], isError: false }; } catch (error: any) { console.error('Error in DONKI handler:', error); return { isError: true, content: [{ type: "text", text: `Error: ${error.message || 'An unexpected error occurred'}` }] }; } } // Export the handler function directly as default export default nasaDonkiHandler;
  • src/index.ts:1625-1638 (registration)
    Direct MCP request handler registration for the `nasa/donki` method, which delegates to `handleToolCall` that dynamically imports and executes the handler from `./handlers/nasa/donki`.
    // DONKI Handler server.setRequestHandler( z.object({ method: z.literal("nasa/donki"), params: z.object({ type: z.string(), startDate: z.string().optional(), endDate: z.string().optional() }).optional() }), async (request) => { return await handleToolCall("nasa/donki", request.params || {}); } );
  • Zod schema definition `DonkiSchema` (exported as `donkiParamsSchema`) used for input validation in the `nasaDonkiHandler`. Imported and typed as `DonkiParams` in the handler.
    // Define schemas for added APIs const DonkiSchema = z.object({ type: z.enum(['cme', 'cmea', 'gst', 'ips', 'flr', 'sep', 'mpc', 'rbe', 'hss', 'wsa', 'notifications']), startDate: z.string().optional(), endDate: z.string().optional() });
  • src/index.ts:913-932 (registration)
    Tool registration in the `tools/list` handler response, including name, description, and input schema for `nasa_donki`.
    name: "nasa_donki", description: "Space Weather Database Of Notifications, Knowledge, Information", inputSchema: { type: "object", properties: { type: { type: "string", description: "Type of space weather event" }, startDate: { type: "string", description: "Start date (YYYY-MM-DD)" }, endDate: { type: "string", description: "End date (YYYY-MM-DD)" } }, required: ["type"] }
  • src/index.ts:483-486 (registration)
    Tool listing in the `tools/manifest` handler response for `nasa_donki`.
    name: "nasa_donki", id: "nasa/donki", description: "Space Weather Database Of Notifications, Knowledge, Information" },

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