Skip to main content
Glama

nasa_osdr_files

Retrieve data files for NASA's Open Science Data Repository studies using accession numbers to access research datasets.

Instructions

NASA OSDR - Get data files for an OSD study

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accession_numberYesOSD study accession number (e.g., '87')

Implementation Reference

  • Main handler function osdrFilesHandler that executes the tool logic: validates accession_number, fetches files metadata from OSDR API, adds as resource, returns JSON.
    export async function osdrFilesHandler(args: OsdrFilesParams) {
      try {
        // Validate required parameters
        if (!args.accession_number) {
          throw new Error('Missing required parameter: accession_number must be provided.');
        }
        
        // Base URL for the OSDR API
        const baseUrl = 'https://osdr.nasa.gov/osdr/data/osd/files';
        const apiUrl = `${baseUrl}/${encodeURIComponent(args.accession_number)}`;
        
        // Make the API request using GET
        const response = await axios.get(apiUrl, {
          // OSDR API might require specific headers, e.g., Accept
          headers: {
            'Accept': 'application/json' 
          }
        });
        const data = response.data;
        
        // Create a resource URI 
        const resourceUri = `nasa://osdr/files/${encodeURIComponent(args.accession_number)}`;
        const resourceName = `OSDR Files for ${args.accession_number}`;
    
        // Add response to resources
        addResource(resourceUri, {
          name: resourceName,
          mimeType: "application/json", 
          text: JSON.stringify(data, null, 2)
        });
        
        // Format the response for MCP
        return {
          content: [{
            type: "text",
            text: JSON.stringify(data, null, 2)
          }]
        };
      } catch (error: any) {
        let errorMessage = `Error accessing NASA OSDR Files API: ${error.message}`;
        if (error.response) {
          // Include more detail from the API response if available
          errorMessage += `\nStatus: ${error.response.status}\nData: ${JSON.stringify(error.response.data)}`;
        }
        return {
          content: [{
            type: "text",
            text: errorMessage
          }],
          isError: true
        };
      }
    }
  • Type definition for input parameters: requires accession_number string.
    interface OsdrFilesParams {
      accession_number: string; 
    }
  • src/index.ts:1382-1394 (registration)
    Tool registration in tools/list handler, defining name 'nasa_osdr_files' and input schema matching the handler params.
      name: "nasa_osdr_files",
      description: "NASA OSDR - Get data files for an OSD study",
      inputSchema: {
        type: "object",
        properties: {
          accession_number: {
            type: "string",
            description: "OSD study accession number (e.g., '87')"
          }
        },
        required: ["accession_number"]
      }
    },
  • src/index.ts:1866-1886 (registration)
    Dynamic import and execution logic in handleToolCall for NASA tools, loads ./handlers/nasa/osdr_files.js and calls default export osdrFilesHandler.
    const handlerModule = await import(`./handlers/nasa/${endpoint}.js`);
    serverInstance?.sendLoggingMessage({
      level: "info",
      data: `Successfully imported handler module for: ./handlers/nasa/${endpoint}.js`,
    });
    
    // Try different potential handler function names
    const handlerFunctionName = `nasa${endpoint.charAt(0).toUpperCase() + endpoint.slice(1).replace(/-/g, '_')}Handler`; // e.g. nasaMars_roverHandler
    const simpleHandlerName = `${endpoint.replace(/-/g, '_')}Handler`; // e.g. mars_roverHandler
    
    const handlerFunction = handlerModule.default || 
                           handlerModule[handlerFunctionName] || 
                           handlerModule[simpleHandlerName];
    
    if (typeof handlerFunction === 'function') {
      serverInstance?.sendLoggingMessage({
        level: "info",
        data: `Executing handler function for ${endpoint}`,
      });
      return await handlerFunction(args);
    } else {

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