Skip to main content
Glama

get_hight_speed_stream

Retrieve high-speed solar wind stream data from NASA for space weather analysis. Specify date ranges to access historical HSS information for research and monitoring purposes.

Instructions

Get high speed stream (HSS) data.

Args: start_date: Start date in YYYY-MM-DD format. Defaults to 30 days before current date. end_date: End date in YYYY-MM-DD format. Defaults to current date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateNo
end_dateNo

Implementation Reference

  • The main handler function for the 'get_hight_speed_stream' tool. It makes an API request to NASA's DONKI/HSS endpoint, handles responses and errors, and uses the 'format_donki_results' helper to format the output.
    async def get_hight_speed_stream(start_date: str = None, end_date: str = None) -> str: # Note: High* Speed Stream
        """Get high speed stream (HSS) data.
        
        Args:
            start_date: Start date in YYYY-MM-DD format. Defaults to 30 days before current date.
            end_date: End date in YYYY-MM-DD format. Defaults to current date.
        """
        params = {}
        if start_date: params["startDate"] = start_date
        if end_date: params["endDate"] = end_date
        
        url = f"{NASA_API_BASE}/DONKI/HSS"
        data = await make_nasa_request(url, params)
    
        if not data: 
            return "Could not retrieve HSS data 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 HSS API. URL: {data.get('url')}"
    
        try:
            # Ensure data is a list for format_donki_results
            if not isinstance(data, list):
                logger.error(f"Unexpected non-list response from HSS API: {data}")
                return "Received unexpected data format from HSS API."
                
            return format_donki_results(data, "High Speed Streams", "hssID")
        except Exception as e:
            logger.error(f"Error processing HSS data: {str(e)}")
            return f"Error processing high speed stream data: {str(e)}"
  • Helper function used by get_hight_speed_stream (and other DONKI tools) to format the list of results into a readable string, limiting display to 10 items.
    def format_donki_results(data: list, title_prefix: str, id_key: str) -> str:
        if not data: 
            return f"No {title_prefix.lower()} data for the specified period."
        
        result = [f"{title_prefix} found: {len(data)}"]
        display_limit = 10
        count = 0
    
        for item in data:
            if count >= display_limit:
                result.append(f"n... and {len(data) - display_limit} more entries.")
                break
            
            result.append(f"nID: {item.get(id_key, 'Unknown')}")
            # Add common fields if they exist
            if 'startTime' in item: result.append(f"Start Time: {item.get('startTime', 'Unknown')}")
            if 'eventTime' in item: result.append(f"Event Time: {item.get('eventTime', 'Unknown')}")
            if 'sourceLocation' in item: result.append(f"Source Location: {item.get('sourceLocation', 'Unknown')}")
            if 'note' in item: result.append(f"Note: {item.get('note', 'N/A')}")
            if 'link' in item: result.append(f"Link: {item.get('link', 'N/A')}")
            
            # Specific fields for different DONKI types can be added here if needed
            # Example for CME:
            if id_key == 'activityID' and 'cmeAnalyses' in item:
                analyses = item.get('cmeAnalyses', [])
                if analyses:
                    result.append("  Analyses:")
                    for analysis in analyses[:2]: # Limit analyses shown
                        result.append(f"    - Time: {analysis.get('time21_5', 'N/A')}, Speed: {analysis.get('speed', 'N/A')} km/s, Type: {analysis.get('type', 'N/A')}")
            
            # Example for GST:
            if id_key == 'gstID' and 'allKpIndex' in item:
                 kp_indices = item.get('allKpIndex', [])
                 if kp_indices:
                     result.append("  Kp Indices (first 2):")
                     for kp in kp_indices[:2]:
                         result.append(f"    - Time: {kp.get('observedTime', 'N/A')}, Index: {kp.get('kpIndex', 'N/A')}")
    
            # Linked Events
            linked_events = item.get('linkedEvents', [])
            if linked_events:
                result.append("  Related event IDs (first 5):")
                result.append("    " + ", ".join([le.get('activityID', 'N/A') for le in linked_events[:5]]))
    
            result.append("-" * 40)
            count += 1
            
        return "n".join(result)
  • The @mcp.tool() decorator registers the get_hight_speed_stream function as an MCP tool.
    async def get_hight_speed_stream(start_date: str = None, end_date: str = None) -> str: # Note: High* Speed Stream
  • Shared helper function used by all tools to make HTTP requests to NASA APIs, handling JSON, binary images, and errors uniformly.
    async def make_nasa_request(url: str, params: dict = None) -> Union[dict[str, Any], List[Any], None]:
        """Make a request to the NASA API with proper error handling.
        Handles both JSON and binary (image) responses.
        """
        
        logger.info(f"Making request to: {url} with params: {params}")
        
        if params is None:
            params = {}
        
        # Ensure API key is included in parameters
        if "api_key" not in params:
            params["api_key"] = API_KEY
        
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(url, params=params, timeout=30.0, follow_redirects=True)
                response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
    
                content_type = response.headers.get("Content-Type", "").lower()
                
                if "application/json" in content_type:
                    try:
                        return response.json()
                    except json.JSONDecodeError as json_err:
                        logger.error(f"JSON decode error for URL {response.url}: {json_err}")
                        logger.error(f"Response text: {response.text[:500]}") # Log beginning of text
                        return {"error": "Failed to decode JSON response", "details": str(json_err)}
                elif content_type.startswith("image/"):
                    logger.info(f"Received binary image content ({content_type}) from {response.url}")
                    # Return a dictionary indicating binary content was received
                    return {
                        "binary_content": True, 
                        "content_type": content_type,
                        "url": str(response.url) # Return the final URL after redirects
                    }
                else:
                    # Handle other unexpected content types
                    logger.warning(f"Unexpected content type '{content_type}' received from {response.url}")
                    return {"error": f"Unexpected content type: {content_type}", "content": response.text[:500]}
    
            except httpx.HTTPStatusError as http_err:
                logger.error(f"HTTP error occurred: {http_err} - {http_err.response.status_code} for URL {http_err.request.url}")
                try:
                    # Try to get more details from response body if possible
                    error_details = http_err.response.json()
                except Exception:
                    error_details = http_err.response.text[:500]
                return {"error": f"HTTP error: {http_err.response.status_code}", "details": error_details}
            except httpx.RequestError as req_err:
                logger.error(f"Request error occurred: {req_err} for URL {req_err.request.url}")
                return {"error": "Request failed", "details": str(req_err)}
            except Exception as e:
                logger.error(f"An unexpected error occurred: {str(e)}")
                return {"error": "An unexpected error occurred", "details": str(e)}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the action ('Get') and parameters, without mentioning permissions, rate limits, data format, or any side effects. For a data retrieval tool with no annotations, this is insufficient to inform the agent about behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the purpose and then detailing parameters in a structured 'Args:' section. It avoids unnecessary words, though it could be slightly more concise by integrating the parameter details more seamlessly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a data retrieval tool with 2 parameters), no annotations, and no output schema, the description is moderately complete. It explains the purpose and parameters well, but lacks information on return values, error handling, or data scope, which are important for contextual understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates by explaining both parameters: 'start_date' and 'end_date' with format details (YYYY-MM-DD) and default values (30 days before current date and current date). This adds significant meaning beyond the bare schema, though it does not cover all potential semantics like validation rules.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Get high speed stream (HSS) data', which clarifies the verb (get) and resource (HSS data), but it does not differentiate this from sibling tools like 'get_coronal_mass_ejection' or 'get_solar_flare', which likely retrieve similar space weather data. The purpose is clear but lacks sibling distinction, making it vague in context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description does not mention any context, exclusions, or prerequisites, such as why one would choose HSS data over other solar or space weather data from sibling tools. This leaves the agent without usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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