Skip to main content
Glama

browse_asteroids

Query NASA's asteroid dataset to access detailed information about near-Earth objects and space rocks for research and monitoring purposes.

Instructions

Browse the asteroid dataset.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'browse_asteroids' MCP tool. It calls the NASA NEO Browse API endpoint to retrieve a list of near-Earth asteroids, limits the display to 10 per page, and formats key details like ID, name, magnitude, diameter, and hazard status.
    async def browse_asteroids() -> str:
        """Browse the asteroid dataset."""
        url = f"{NASA_API_BASE}/neo/rest/v1/neo/browse"
        data = await make_nasa_request(url)
        
        if not data:
            return "Could not retrieve asteroid dataset due to a connection error."
        
        # Check for error response (must be a dictionary)
        if isinstance(data, dict) and "error" in data:
            return f"API Error: {data.get('error')} - Details: {data.get('details', 'N/A')}"
        if isinstance(data, dict) and data.get("binary_content"):
            return f"Received unexpected binary content from Browse Asteroids API. URL: {data.get('url')}"
    
        try:
            near_earth_objects = data.get('near_earth_objects', [])
            page_info = f"Page {data.get('page', {}).get('number', 'Unknown')} of {data.get('page', {}).get('total_pages', 'Unknown')}"
            total_elements = f"Total elements: {data.get('page', {}).get('total_elements', 'Unknown')}"
            
            result = [page_info, total_elements, ""]
            
            # Limit the number of asteroids displayed to avoid excessive output
            display_limit = 10 
            count = 0
            for asteroid in near_earth_objects:
                if count >= display_limit:
                    result.append(f"n... and {len(near_earth_objects) - display_limit} more asteroids on this page.")
                    break
                result.append(f"ID: {asteroid.get('id', 'Unknown')}")
                result.append(f"Name: {asteroid.get('name', 'Unknown')}")
                result.append(f"Absolute magnitude: {asteroid.get('absolute_magnitude_h', 'Unknown')}")
                result.append(f"Estimated diameter (min): {asteroid.get('estimated_diameter', {}).get('kilometers', {}).get('estimated_diameter_min', 'Unknown')} km")
                result.append(f"Estimated diameter (max): {asteroid.get('estimated_diameter', {}).get('kilometers', {}).get('estimated_diameter_max', 'Unknown')} km")
                result.append(f"Potentially hazardous: {'Yes' if asteroid.get('is_potentially_hazardous_asteroid', False) else 'No'}")
                result.append("-" * 40)
                count += 1
            
            return "n".join(result)
        except Exception as e:
            logger.error(f"Error processing Browse Asteroids data: {str(e)}")
            return f"Error processing asteroid data: {str(e)}"

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/AnCode666/nasa-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server